@@ -74,12 +74,12 @@ namespace QuantLib {
7474 119u , 247u , 15u , 143u , 79u , 207u , 47u , 175u , 111u , 239u , 31u , 159u , 95u , 223u ,
7575 63u , 191u , 127u , 255u };
7676
77- std::uint32_t reverseBits (std::uint32_t x) {
77+ inline std::uint32_t reverseBits (std::uint32_t x) {
7878 return (bitReverseTable[x & 0xff ] << 24 ) | (bitReverseTable[(x >> 8 ) & 0xff ] << 16 ) |
7979 (bitReverseTable[(x >> 16 ) & 0xff ] << 8 ) | (bitReverseTable[(x >> 24 ) & 0xff ]);
8080 }
8181
82- std::uint32_t laine_karras_permutation (std::uint32_t x, std::uint32_t seed) {
82+ inline std::uint32_t laine_karras_permutation (std::uint32_t x, std::uint32_t seed) {
8383 x += seed;
8484 x ^= x * 0x6c50b47cu ;
8585 x ^= x * 0xb82f1e52u ;
@@ -88,26 +88,38 @@ namespace QuantLib {
8888 return x;
8989 }
9090
91- std::uint32_t nested_uniform_scramble (std::uint32_t x, std::uint32_t seed) {
91+ inline std::uint32_t nested_uniform_scramble (std::uint32_t x, std::uint32_t seed) {
9292 x = reverseBits (x);
9393 x = laine_karras_permutation (x, seed);
9494 x = reverseBits (x);
9595 return x;
9696 }
9797
9898 // the results depend a lot on the details of the hash_combine() function that is used
99- // we use the 64bit version of hash_combine () as it is implemented here:
99+ // we use hash_combine() calling hash(), hash_mix () as implemented here:
100100 // https://github.com/boostorg/container_hash/blob/boost-1.83.0/include/boost/container_hash/hash.hpp#L560
101+ // https://github.com/boostorg/container_hash/blob/boost-1.83.0/include/boost/container_hash/hash.hpp#L115
101102 // https://github.com/boostorg/container_hash/blob/boost-1.83.0/include/boost/container_hash/detail/hash_mix.hpp#L67
102103
103- void local_hash_combine ( std::uint64_t & x, const uint64_t v ) {
104+ inline std::uint64_t local_hash_mix (std:: uint64_t x ) {
104105 const std::uint64_t m = 0xe9846af9b1a615d ;
105- x += 0x9e3779b9 + std::hash<std::uint64_t >()(v);
106106 x ^= x >> 32 ;
107107 x *= m;
108108 x ^= x >> 32 ;
109109 x *= m;
110110 x ^= x >> 28 ;
111+ return x;
112+ }
113+
114+ inline std::uint64_t local_hash (const std::uint64_t v) {
115+ std::uint64_t seed = 0 ;
116+ seed = (v >> 32 ) + local_hash_mix (seed);
117+ seed = (v & 0xFFFFFFFF ) + local_hash_mix (seed);
118+ return seed;
119+ }
120+
121+ inline std::uint64_t local_hash_combine (std::uint64_t x, const uint64_t v) {
122+ return local_hash_mix (x + 0x9e3779b9 + local_hash (v));
111123 }
112124 }
113125
@@ -119,7 +131,7 @@ namespace QuantLib {
119131 do {
120132 std::uint64_t seed = group4Seeds_[group++];
121133 for (Size g = 0 ; g < 4 && i < dimensionality_; ++g, ++i) {
122- local_hash_combine (seed, g);
134+ seed = local_hash_combine (seed, g);
123135 integerSequence_[i] =
124136 nested_uniform_scramble (integerSequence_[i], static_cast <std::uint32_t >(seed));
125137 }
0 commit comments