GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::randomness::Xoroshiro128PlusPlusEngine Class Reference

Implementation of the xoroshiro128++ pseudorandom number generator that provides the API required for a standard uniform random bit generator, so that it can be plugged into any of the random number distributions provided by the standard library. More...

#include <GREM/core/randomness.hpp>

Public Types

using result_type = uint64_t
using State = Array<uint64_t, 2>

Public Member Functions

constexpr Xoroshiro128PlusPlusEngine () noexcept
constexpr Xoroshiro128PlusPlusEngine (result_type seedValue) noexcept
constexpr Xoroshiro128PlusPlusEngine (const State &state) noexcept
constexpr void seed (result_type seedValue=default_seed) noexcept
constexpr result_type operator() () noexcept
constexpr void discard (unsigned long long z) noexcept
constexpr void jump () noexcept
 Advance the internal state 2^64 times.
constexpr void longJump () noexcept
 Advance the internal state 2^96 times.
constexpr void setState (const State &newState) noexcept
 Set the value representation of the internal state.
constexpr State getState () const noexcept
 Get the value representation of the internal state.
constexpr bool operator== (const Xoroshiro128PlusPlusEngine &other) const noexcept

Static Public Member Functions

static constexpr result_type min ()
static constexpr result_type max ()

Static Public Attributes

static constexpr result_type default_seed = SplitMix64Engine::default_seed

Friends

template<typename CharT, typename Traits>
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &stream, const Xoroshiro128PlusPlusEngine &engine)
template<typename CharT, typename Traits>
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &stream, Xoroshiro128PlusPlusEngine &engine)

Detailed Description

Implementation of the xoroshiro128++ pseudorandom number generator that provides the API required for a standard uniform random bit generator, so that it can be plugged into any of the random number distributions provided by the standard library.

This engine is small, fast and fairly high quality compared to most of the pseudorandom number generators in the standard library (as of C++20).

Warning
This engine does not produce cryptographcially secure randomness and should therefore not be used in situations that require a CSPRNG.
See also
https://prng.di.unimi.it/ for more information.

Member Typedef Documentation

◆ result_type

◆ State

Constructor & Destructor Documentation

◆ Xoroshiro128PlusPlusEngine() [1/3]

grem::randomness::Xoroshiro128PlusPlusEngine::Xoroshiro128PlusPlusEngine ( )
inlineconstexprnoexcept

◆ Xoroshiro128PlusPlusEngine() [2/3]

grem::randomness::Xoroshiro128PlusPlusEngine::Xoroshiro128PlusPlusEngine ( result_type seedValue)
inlineexplicitconstexprnoexcept

◆ Xoroshiro128PlusPlusEngine() [3/3]

grem::randomness::Xoroshiro128PlusPlusEngine::Xoroshiro128PlusPlusEngine ( const State & state)
inlineexplicitconstexprnoexcept

Member Function Documentation

◆ min()

constexpr result_type grem::randomness::Xoroshiro128PlusPlusEngine::min ( )
inlinestaticnodiscardconstexpr

◆ max()

constexpr result_type grem::randomness::Xoroshiro128PlusPlusEngine::max ( )
inlinestaticnodiscardconstexpr

◆ seed()

void grem::randomness::Xoroshiro128PlusPlusEngine::seed ( result_type seedValue = default_seed)
inlineconstexprnoexcept

◆ operator()()

result_type grem::randomness::Xoroshiro128PlusPlusEngine::operator() ( )
inlineconstexprnoexcept

◆ discard()

void grem::randomness::Xoroshiro128PlusPlusEngine::discard ( unsigned long long z)
inlineconstexprnoexcept

◆ jump()

void grem::randomness::Xoroshiro128PlusPlusEngine::jump ( )
inlineconstexprnoexcept

Advance the internal state 2^64 times.

◆ longJump()

void grem::randomness::Xoroshiro128PlusPlusEngine::longJump ( )
inlineconstexprnoexcept

Advance the internal state 2^96 times.

◆ setState()

void grem::randomness::Xoroshiro128PlusPlusEngine::setState ( const State & newState)
inlineconstexprnoexcept

Set the value representation of the internal state.

Parameters
newStatenew state of the engine to set the state to.
Note
This function is mainly intended to be used for deserialization.
See also
getState()

◆ getState()

State grem::randomness::Xoroshiro128PlusPlusEngine::getState ( ) const
inlinenodiscardconstexprnoexcept

Get the value representation of the internal state.

Returns
the internal state of the engine.
Note
This function is mainly intended to be used for serialization.
See also
setState()

◆ operator==()

bool grem::randomness::Xoroshiro128PlusPlusEngine::operator== ( const Xoroshiro128PlusPlusEngine & other) const
inlinenodiscardconstexprnoexcept

◆ operator<<

template<typename CharT, typename Traits>
std::basic_ostream< CharT, Traits > & operator<< ( std::basic_ostream< CharT, Traits > & stream,
const Xoroshiro128PlusPlusEngine & engine )
friend

◆ operator>>

template<typename CharT, typename Traits>
std::basic_istream< CharT, Traits > & operator>> ( std::basic_istream< CharT, Traits > & stream,
Xoroshiro128PlusPlusEngine & engine )
friend

Member Data Documentation

◆ default_seed

result_type grem::randomness::Xoroshiro128PlusPlusEngine::default_seed = SplitMix64Engine::default_seed
staticconstexpr

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