![]() |
Home | Libraries | People | FAQ | More |
boost::random::mwc64x32
// In header: <boost/random/mwcx.hpp> class mwc64x32 { public: // private static functions static words_type modulus() noexcept; // public member functions result_type next() noexcept; };
This is MWC64X/32, a scrambled multiply-with-carry generator with 32-bit digits, lag one, and period approximately 2^63, from "Scrambled Multiply-with-Carry Pseudorandom Number Generators" by Sebastiano Vigna (https://arxiv.org/abs/2610.27313). It returns 32-bit values, and it is an alternative to mwc128x32 with a smaller state (64 bits), meant for environments in which registers are scarce, such as GPUs. It needs just a 32 x 32 -> 64-bit multiplication.
The output is scrambled by X: it is the most recent digit xored with the carry, as in David Thomas's MWC64X generator. The underlying generator simulates a multiplicative congruential generator with prime modulus m = 0xfff145f8 * 2^32 - 1 and multiplier 2^(-32) mod m.
discard() computes the state up to 2^64 - 1 steps ahead in time logarithmic in the number of steps, and jump(c, e) advances the generator by c * 2^e steps, which makes it possible to obtain non-overlapping subsequences at distances larger than discard() can express. jump(1, 32) is equivalent to the jump() function of the reference implementation: it can be used to generate 2^31 non-overlapping subsequences for parallel computations. jump(1, 48) is equivalent to long_jump(): it can be used to generate 2^15 starting points, from each of which jump(1, 32) will generate 2^16 non-overlapping subsequences for parallel distributed computations.
The state is formed by a 32-bit digit x and a 32-bit carry c, and it is read as the integer x + c * 2^32, which must be nonzero and smaller than m. This generator is not suitable for cryptographic purposes.