![]() |
Home | Libraries | People | FAQ | More |
boost::random::mwc128x
// In header: <boost/random/mwcx.hpp> class mwc128x { public: // private static functions static words_type modulus() noexcept; // public member functions result_type next() noexcept; };
This is MWC128X, a scrambled multiply-with-carry generator with 64-bit digits, lag one, and period approximately 2^127, from "Scrambled Multiply-with-Carry Pseudorandom Number Generators" by Sebastiano Vigna (https://arxiv.org/abs/2610.27313). It is an alternative to mwc192x with a smaller state (128 bits), and it passes all tests we are aware of. It is slightly slower than mwc192x, as each multiplication needs the result of the previous step.
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 = 0xff6da236274e252e * 2^64 - 1 and multiplier 2^(-64) 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, 64) is equivalent to the jump() function of the reference implementation: it can be used to generate 2^63 non-overlapping subsequences for parallel computations. jump(1, 96) is equivalent to long_jump(): it can be used to generate 2^31 starting points, from each of which jump(1, 64) will generate 2^32 non-overlapping subsequences for parallel distributed computations.
The state is formed by a 64-bit digit x and a 64-bit carry c, and it is read as the integer x + c * 2^64, which must be nonzero and smaller than m. This generator is not suitable for cryptographic purposes.