Celeritas 0.7.0-dev.264+develop.12c52268
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
celeritas::XorwowRngEngine Class Reference

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 >
 
using RngStateInitializer_t = XorwowRngStateInitializer
 

Public Member Functions

 XorwowRngEngine (ParamsRef const &params, StateRef const &state, TrackSlotId tid)
 Construct from state and persistent data.
 
XorwowRngEngineoperator= (Initializer_t const &)
 Initialize the RNG engine.
 
XorwowRngEngineoperator= (RngStateInitializer_t const &)
 Initialize the RNG engine with a state initializer.
 
result_type operator() ()
 Generate a 32-bit pseudorandom number using the 'xorwow' engine.
 
void discard (ull_int count)
 Advance the state count times.
 
RngStateInitializer_t branch ()
 Generate a branched and (hopefully) decorreleated RNG.
 

Static Public Member Functions

static constexpr result_type min ()
 Lowest value potentially generated.
 
static constexpr result_type max ()
 Highest value potentially generated.
 

Detailed Description

Generate random data using the XORWOW algorithm.

The XorwowRngEngine uses a C++11-like interface to generate random data using Marasglia's modified xorshift generator (marsaglia-xorshift-2003). 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.

Initialization 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 (matsumoto-defects-2007).

For a description of the jump ahead method using the polynomial representation of the recurrence, see haramato-jump-2008.

The jump polynomials were precomputed using a python script. 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-rng-2008.

Member Function Documentation

◆ branch()

XorwowRngEngine::RngStateInitializer_t celeritas::XorwowRngEngine::branch ( )
inline

Generate a branched and (hopefully) decorreleated RNG.

Todo:
There are good reasons to believe that an RNG that is based on XOR operations may not be decorrelated when XORing the state. Work on an improved methodology may be warranted.

The documentation for this class was generated from the following file: