Constructs a XorshiftEngine generator seeded with x0.
Advances the random sequence.
(Re)seeds the generator.
Always false (random generators are infinite ranges).
Returns the current number in the random sequence.
Captures a range state.
Mark this as a Rng
Largest generated value.
Smallest generated value.
Word size of this xorshift generator and the return type of opCall.
The number of bits of state of this generator. This must be a positive multiple of the size in bits of UIntType. If nbits is large this struct may occupy slightly more memory than this so it can use a circular counter instead of shifting the entire array.
The direction and magnitude of the 1st shift. Positive means left, negative means right.
The direction and magnitude of the 2nd shift. Positive means left, negative means right.
The direction and magnitude of the 3rd shift. Positive means left, negative means right.
Note: For historical compatibility when nbits == 192 and UIntType is uint a legacy hybrid PRNG is used consisting of a 160-bit xorshift combined with a 32-bit counter. This combined generator has period equal to the least common multiple of 2^^160 - 1 and 2^^32.
Previous versions of XorshiftEngine did not provide any mechanism to specify the directions of the shifts, taking each shift as an unsigned magnitude. For backwards compatibility, because three shifts in the same direction cannot result in a full-period XorshiftEngine, when all three of sa, sb, sc, are positive XorshiftEngine` treats them as unsigned magnitudes and uses shift directions to match the old behavior of XorshiftEngine.
Not every set of shifts results in a full-period xorshift generator. The template does not currently at compile-time perform a full check for maximum period but in a future version might reject parameters resulting in shorter periods.
alias Xorshift96 = XorshiftEngine!(uint, 96, 10, 5, 26); auto rnd = Xorshift96(42); auto num = rnd.front; // same for each run assert(num == 2704588748);
Xorshift generator. Implemented according to Xorshift RNGs (Marsaglia, 2003) when the size is small. For larger sizes the generator uses Sebastino Vigna's optimization of using an index to avoid needing to rotate the internal array.
Period is 2 ^^ nbits - 1 except for a legacy 192-bit uint version (see note below).