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 of Xoroshiro256 is initialized using the SplitMix 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.

[2] https://prng.di.unimi.it/

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.

Public Static Attributes

static constexpr short bytes = 8

The number of bytes generated.

static constexpr uint64_t max_val = UINT64_MAX

The largest possible value generated.

static constexpr uint64_t min_val = 1

The smallest possible value generated.