Xoshiro C++ implementation

Pseudo random number generators (PRNG).

This implementation has been adapted from

template<typename G>
concept uniform_random_bit_generator
#include <libfork/schedule/ext/random.hpp>

Like std::uniform_random_bit_generator, but also requires a nested result_type.

constexpr impl::seed_t lf::ext::seed = {}

A tag to disambiguate seeding from copy construction.

class xoshiro

A <random> compatible implementation of the xoshiro256** 1.0 PRNG.

From the original:

This is xoshiro256** 1.0, one of our all-purpose, rock-solid generators. It has excellent (sub-ns) speed, a state (256 bits) that is large enough for any parallel application, and it passes all tests we are aware of.

Public Types

using result_type = std::uint64_t

Required by named requirement: UniformRandomBitGenerator

Public Functions

constexpr xoshiro() = default

Construct a new xoshiro with a fixed default-seed.

template<uniform_random_bit_generator PRNG>
inline xoshiro(impl::seed_t, PRNG &&dev) noexcept

Construct and seed the PRNG from some other generator.

inline explicit constexpr xoshiro(std::array<result_type, 4> const &my_seed) noexcept

Construct and seed the PRNG.

Parameters:

my_seed – The PRNG’s seed, must not be everywhere zero.

inline constexpr auto jump() noexcept -> void

This is the jump function for the generator.

It is equivalent to 2^128 calls to operator(); it can be used to generate 2^128 non-overlapping sub-sequences for parallel computations.

inline constexpr auto long_jump() noexcept -> void

This is the long-jump function for the generator.

It is equivalent to 2^192 calls to operator(); it can be used to generate 2^64 starting points, from each of which jump() will generate 2^64 non-overlapping sub-sequences for parallel distributed computations.

inline constexpr auto operator()() noexcept -> result_type

Generate a random bit sequence and advance the state of the generator.

Returns:

A pseudo-random number.

Public Static Functions

static inline constexpr auto max() noexcept -> result_type

Get the maximum value of the generator.

Returns:

The maximum value that xoshiro::operator() can return.

static inline constexpr auto min() noexcept -> result_type

Get the minimum value of the generator.

Returns:

The minimum value that xoshiro::operator() can return.