A random generator based off the xorshift* algorithm.
The state is represented as an integer that, with each generation, performs exclusive OR (XOR) operations on different left/right bit shifts of itself. The *
in xorshift*
refers to a final multiplication that is applied to the output value. The final multiplication is essentially a nonlinear transformation that makes the algorithm stronger than a plain XOR shift.
Pigweed's implementation augments xorshift*
with an ability to inject entropy to reseed the generator throughout its lifetime. When entropy is injected, the results of the generator are no longer completely deterministic based on the original seed.
See also Xorshift RNGs and An experimental exploration of Marsaglia's xorshift generators, scrambled.
Public Member Functions | |
XorShiftStarRng64 (uint64_t initial_seed) | |
void | Get (ByteSpan dest) final |
void | InjectEntropyBits (uint32_t data, uint_fast8_t num_bits) final |
![]() | |
template<class T > | |
void | GetInt (T &dest) |
template<class T > | |
void | GetInt (T &dest, const T &exclusive_upper_bound) |
virtual void | Get (ByteSpan dest)=0 |
virtual void | InjectEntropyBits (uint32_t data, uint_fast8_t num_bits)=0 |
void | InjectEntropy (ConstByteSpan data) |
Injects entropy into the pool byte-by-byte. | |