Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::SplitMix64_Rng Class Reference

SplitMix64: a random number generator whose state is a word of 64 bits. More...

#include <ah-random.H>

Collaboration diagram for Aleph::SplitMix64_Rng:
[legend]

Public Types

using result_type = std::uint64_t
 The type of the numbers of operator()().
 

Public Member Functions

constexpr SplitMix64_Rng () noexcept
 A generator with the default seed.
 
constexpr SplitMix64_Rng (const std::uint64_t s) noexcept
 A generator with a seed.
 
constexpr void seed (const std::uint64_t s) noexcept
 Seeds again.
 
constexpr result_type operator() () noexcept
 The next number, in [min(), max()].
 

Static Public Member Functions

static constexpr result_type min () noexcept
 The least number of operator()().
 
static constexpr result_type max () noexcept
 The greatest number of operator()(): 2^64 - 1.
 
static constexpr std::uint64_t mix (std::uint64_t z) noexcept
 The number of a state: a bijection of the 64-bit integers that scrambles its bits.
 

Static Public Attributes

static constexpr std::uint64_t default_seed = 0
 The seed of a generator that is given none.
 
static constexpr std::uint64_t increment = 0x9e3779b97f4a7c15ULL
 What the state advances for each number: 2^64 divided by the golden ratio, as an odd integer.
 

Private Attributes

std::uint64_t state
 

Friends

constexpr bool operator== (const SplitMix64_Rng &a, const SplitMix64_Rng &b) noexcept
 Whether two generators give the same numbers from now on.
 

Detailed Description

SplitMix64: a random number generator whose state is a word of 64 bits.

It is the generator of Steele, Lea and Flood ("Fast splittable pseudorandom number generators", OOPSLA 2014) with a fixed increment, as the splitmix64.c of Vigna and the SplittableRandom of Java built with a seed: the state advances by an odd constant, so that it goes through its 2^64 values before it repeats, and each number is the state scrambled by a bijection. For each seed, the numbers are those of these implementations, on every platform.

It is the generator of a Random_Source that is not asked for the Mersenne Twister: it takes a word, where a Gsl_Compatible_Rng takes about 2500 bytes, and seeding it is storing that word.

It satisfies std::uniform_random_bit_generator, and every member is constexpr.

Note
It is not a generator for cryptography: a number gives away the state.

Definition at line 641 of file ah-random.H.

Member Typedef Documentation

◆ result_type

using Aleph::SplitMix64_Rng::result_type = std::uint64_t

The type of the numbers of operator()().

Definition at line 647 of file ah-random.H.

Constructor & Destructor Documentation

◆ SplitMix64_Rng() [1/2]

constexpr Aleph::SplitMix64_Rng::SplitMix64_Rng ( )
inlineconstexprnoexcept

A generator with the default seed.

Definition at line 676 of file ah-random.H.

◆ SplitMix64_Rng() [2/2]

constexpr Aleph::SplitMix64_Rng::SplitMix64_Rng ( const std::uint64_t  s)
inlineexplicitconstexprnoexcept

A generator with a seed.

Parameters
[in]sThe seed: the state before the first number.

Definition at line 682 of file ah-random.H.

Member Function Documentation

◆ max()

static constexpr result_type Aleph::SplitMix64_Rng::max ( )
inlinestaticconstexprnoexcept

The greatest number of operator()(): 2^64 - 1.

Definition at line 660 of file ah-random.H.

Referenced by TEST().

◆ min()

static constexpr result_type Aleph::SplitMix64_Rng::min ( )
inlinestaticconstexprnoexcept

The least number of operator()().

Definition at line 657 of file ah-random.H.

Referenced by TEST().

◆ mix()

static constexpr std::uint64_t Aleph::SplitMix64_Rng::mix ( std::uint64_t  z)
inlinestaticconstexprnoexcept

The number of a state: a bijection of the 64-bit integers that scrambles its bits.

Parameters
[in]zThe state.
Returns
The number.

Definition at line 668 of file ah-random.H.

Referenced by Aleph::random_detail::entropy_of_the_run(), operator()(), Aleph::random_detail::seed_of_its_own(), and TEST().

◆ operator()()

constexpr result_type Aleph::SplitMix64_Rng::operator() ( )
inlineconstexprnoexcept

The next number, in [min(), max()].

Returns
The state, advanced by increment and scrambled by mix().

Definition at line 694 of file ah-random.H.

References increment, mix(), and state.

◆ seed()

constexpr void Aleph::SplitMix64_Rng::seed ( const std::uint64_t  s)
inlineconstexprnoexcept

Seeds again.

Parameters
[in]sThe seed: the state before the next number.

Definition at line 688 of file ah-random.H.

References state.

Referenced by Aleph::Random_Source::seed(), TEST(), and TEST().

Friends And Related Symbol Documentation

◆ operator==

constexpr bool operator== ( const SplitMix64_Rng &  a,
const SplitMix64_Rng &  b 
)
friend

Whether two generators give the same numbers from now on.

Parameters
[in]aA generator.
[in]bAnother one.
Returns
Whether their states are equal.

Definition at line 702 of file ah-random.H.

Member Data Documentation

◆ default_seed

constexpr std::uint64_t Aleph::SplitMix64_Rng::default_seed = 0
staticconstexpr

The seed of a generator that is given none.

Definition at line 650 of file ah-random.H.

Referenced by TEST().

◆ increment

constexpr std::uint64_t Aleph::SplitMix64_Rng::increment = 0x9e3779b97f4a7c15ULL
staticconstexpr

What the state advances for each number: 2^64 divided by the golden ratio, as an odd integer.

Definition at line 654 of file ah-random.H.

Referenced by Aleph::random_detail::entropy_of_the_run(), operator()(), Aleph::random_detail::seed_of_its_own(), TEST(), TEST(), TEST(), and TEST().

◆ state

std::uint64_t Aleph::SplitMix64_Rng::state
private

Definition at line 643 of file ah-random.H.

Referenced by operator()(), and seed().


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