Xoroshiro¶
-
class Xoroshiro256¶
The
Xoroshiro
family of random number generators was created by David Blackman and Sebastiano Vigna.Xoroshiro
consists of a linear generator (i.e., a LFSR, or linear-feedback shift register) and a scrambler. A linear generator produces a bit sequence using a xor, rotate, shift and another xor. This sequence is then passed to a scrambler to improve its quality. HighFM uses the++
scrambler, i.e., applies a sum, a rotation and then another sum to the bit sequence. The internal state ofXoroshiro256
is initialized using theSplitMix
generator.Xoroshiro is currently used in the JavaScript engines of Chrome, Safari and Firefox.
References:
[1] D. Blackman and S. Vigna, “Scrambled Linear Pseudorandom Number Generators”, ACM Trans. Math. Softw., vol. 47, no. 4, pp. 1–32, Dec. 2021, doi: 10.1145/3460772.
Public Functions
-
inline Xoroshiro256(state_type seed = default_seed, state_type stream = default_stream)¶
Creates a new instance of the Xoroshiro256 generator. This routine uses a SplitMix64 generator to populate the 256-bit internal state.
- Parameters:
seed – [in] seed for the SplitMix64 generator(optional)
stream – [in] stream for the SplitMix64 generator(optional)
-
inline Xoroshiro256(state_type seeds[4])¶
Creates a new instance of the Xoroshiro256 generator and initialize its 256-bit internal state using
seeds
.- Parameters:
seeds – [in] initial state
-
inline Xoroshiro256(const Xoroshiro256 &other)¶
Creates a new instance of the Xoroshiro256 generator from an
other
instance.- Parameters:
other – [in] Xoroshiro256 generator to use as the data source
-
inline Xoroshiro256 &operator=(const Xoroshiro256 &other)¶
Copy the internal state from
other
.- Parameters:
other – [in] Xoroshiro256 generator to use as the data source
- Returns:
*this
-
virtual ~Xoroshiro256() = default¶
Default destructor.
-
inline void seed(uint64_t seed = default_seed, uint64_t stream = default_stream)¶
Populate the internal state using the SplitMix64 generator.
- Parameters:
seed – [in] seed for the SplitMix64 generator
stream – [in] stream for the SplitMix64 generator(optional)
-
inline void seed(uint64_t state[4])¶
Set the internal state to
state
.- Parameters:
state – [in] 256-bit number to use as the data source
-
inline constexpr uint64_t next()¶
Advances the generator state and generates a new pseudorandom 64-bits integer.
-
inline constexpr uint64_t operator()()¶
Advances the generator state and generates a new pseudorandom 64-bits integer.
-
inline Xoroshiro256(state_type seed = default_seed, state_type stream = default_stream)¶