Returns the next prng value. pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 This is the lrand64 generator.
| 153 | // pRNG is: aX+b mod c with a = 0x5DEECE66D, b = 0xB, c = 1<<48 |
| 154 | // This is the lrand64 generator. |
| 155 | inline uint64_t Sampler::NextRandom(uint64_t rnd) { |
| 156 | const uint64_t prng_mult = 0x5DEECE66DLL; |
| 157 | const uint64_t prng_add = 0xB; |
| 158 | const uint64_t prng_mod_power = 48; |
| 159 | const uint64_t prng_mod_mask = |
| 160 | ~((~static_cast<uint64_t>(0)) << prng_mod_power); |
| 161 | return (prng_mult * rnd + prng_add) & prng_mod_mask; |
| 162 | } |
| 163 | |
| 164 | // Adapted from //util/math/fastmath.[h|cc] by Noam Shazeer |
| 165 | // This mimics the VeryFastLog2 code in those files |
no outgoing calls