Celeritas
0.5.0-56+6b053cd
|
Generate random data using the XORWOW algorithm. More...
#include <XorwowRngEngine.hh>
Public Types | |
Type aliases | |
using | uint_t = XorwowUInt |
using | result_type = uint_t |
using | Initializer_t = XorwowRngInitializer |
using | ParamsRef = NativeCRef< XorwowRngParamsData > |
using | StateRef = NativeRef< XorwowRngStateData > |
Public Member Functions | |
CELER_FUNCTION | XorwowRngEngine (ParamsRef const ¶ms, StateRef const &state, TrackSlotId tid) |
Construct from state and persistent data. | |
CELER_FUNCTION XorwowRngEngine & | operator= (Initializer_t const &) |
Initialize the RNG engine. More... | |
CELER_FUNCTION result_type | operator() () |
Generate a 32-bit pseudorandom number using the 'xorwow' engine. | |
CELER_FUNCTION void | discard (ull_int count) |
Advance the state count times. | |
Static Public Member Functions | |
static CELER_CONSTEXPR_FUNCTION result_type | min () |
Lowest value potentially generated. | |
static CELER_CONSTEXPR_FUNCTION result_type | max () |
Highest value potentially generated. | |
Generate random data using the XORWOW algorithm.
The XorwowRngEngine uses a C++11-like interface to generate random data. The sampling of uniform floating point data is done with specializations to the GenerateCanonical class.
The resize
function for XorwowRngStateData
will fully randomize the state at initialization. Alternatively, the state can be initialized with a seed, subsequence, and offset.
See Marsaglia (2003) for the theory underlying the algorithm and the the "example" xorwow
that combines an xorshift output with a Weyl sequence (https://www.jstatsoft.org/index.php/jss/article/view/v008i14/916).
For a description of the jump ahead method using the polynomial representation of the recurrence, see: Haramoto, H., Matsumoto, M., Nishimura, T., Panneton, F., L’Ecuyer, P. 2008. "Efficient jump ahead for F2-linear random number generators". INFORMS Journal on Computing. https://pubsonline.informs.org/doi/10.1287/ijoc.1070.0251.
The jump polynomials were precomputed using https://github.com/celeritas-project/utils/blob/main/prng/xorwow-jump.py. For a more detailed description of how to calculate the jump polynomials using Knuth's square-and-multiply algorithm in \( O(k^2 log d) \) time (where k is the number of bits in the state and d is the number of steps to skip ahead), see: Collins, J. 2008. "Testing, Selection, and Implementation of Random Number Generators". ARL-TR-4498. https://apps.dtic.mil/sti/pdfs/ADA486637.pdf.
|
inline |
Initialize the RNG engine.
This moves the state ahead to the given subsequence (a subsequence has size 2^67) and skips offset
random numbers.
It is recommended to initialize the state using a very different generator from the one being initialized to avoid correlations. Here the 64-bit SplitMix64 generator is used for initialization (See Matsumoto, Wada, Kuramoto, and Ashihara, "Common defects in initialization of pseudorandom number generators". https://dl.acm.org/doi/10.1145/1276927.1276928.)