Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
arene::base::testing::prng_xoshiro Class Reference

pseudorandom number generator implementing the xoshiro256++ algorithm More...

Public Types

using result_type = std::uint64_t
 prng result type
 
using seed_type = std::uint64_t
 seed argument type
 

Public Member Functions

constexpr prng_xoshiro () noexcept
 construct the generator with a seed of zero
 
constexpr prng_xoshiro (seed_type initial_seed) noexcept
 construct the generator with an explicit seed
 
constexpr auto operator() () noexcept -> result_type
 generate the next pseudorandom value and advance the internal state
 

Static Public Member Functions

static constexpr auto max () noexcept -> result_type
 largest value that operator() can return
 
static constexpr auto min () noexcept -> result_type
 smallest value that operator() can return
 

Detailed Description

pseudorandom number generator implementing the xoshiro256++ algorithm

xoshiro256++ is a general-purpose PRNG designed by David Blackman and Sebastiano Vigna. It offers sub-nanosecond speed, a 256-bit state space large enough for parallel applications, and passes all known statistical test suites.

The generator satisfies the C++ UniformRandomBitGenerator named requirement, so it can be used with standard library distributions and algorithms that accept a URBG.

A single 64-bit seed is expanded into the full 256-bit internal state using the SplitMix64 generator, as recommended by the xoshiro authors. This ensures the state is never all-zero (the only disallowed state) for any seed value.

See also
https://prng.di.unimi.it/
https://prng.di.unimi.it/xoshiro256plusplus.c

Member Typedef Documentation

◆ result_type

◆ seed_type

Constructor & Destructor Documentation

◆ prng_xoshiro() [1/2]

arene::base::testing::prng_xoshiro::prng_xoshiro ( seed_type initial_seed)
inlineexplicitconstexprnoexcept

construct the generator with an explicit seed

Parameters
initial_seedinitial seed value

◆ prng_xoshiro() [2/2]

arene::base::testing::prng_xoshiro::prng_xoshiro ( )
inlineconstexprnoexcept

construct the generator with a seed of zero

Member Function Documentation

◆ max()

static constexpr auto arene::base::testing::prng_xoshiro::max ( ) -> result_type
inlinestaticconstexprnoexcept

largest value that operator() can return

Returns
~min()

◆ min()

static constexpr auto arene::base::testing::prng_xoshiro::min ( ) -> result_type
inlinestaticconstexprnoexcept

smallest value that operator() can return

Returns
zero

◆ operator()()

auto arene::base::testing::prng_xoshiro::operator() ( ) -> result_type
inlineconstexprnoexcept

generate the next pseudorandom value and advance the internal state

Returns
a uniformly distributed 64-bit pseudorandom value in the range [min(), max()]
See also
https://prng.di.unimi.it/xoshiro256plusplus.c

The documentation for this class was generated from the following file: