libstdc++: std::philox_engine< _UIntType, __w, __n, __r, __consts > Class Template Reference

libstdc++

std::philox_engine< _UIntType, __w, __n, __r, __consts > Class Template Reference
Numerics » Random Number Generation » Random Number Generators

`#include <random>`

## Public Types
using | result_type

## Public Member Functions
template<typename _Sseq>
| philox_engine (_Sseq &__q)
| philox_engine (result_type __value)
void | discard (unsigned long long __z)
result_type | operator() ()
template<typename _Sseq> requires __is_seed_seq<_Sseq>
void | seed (_Sseq &__q)
void | seed (result_type __value=default_seed)
void | set_counter (const array< result_type, __n > &__counter)

## Static Public Member Functions
static constexpr result_type | max ()
static constexpr result_type | min ()

## Static Public Attributes
static constexpr result_type | default_seed
static constexpr array< result_type, __n/2 > | multipliers
static constexpr array< result_type, __n/2 > | round_consts
static constexpr size_t | round_count
static constexpr size_t | word_count
static constexpr size_t | word_size

## Friends
template<typename _CharT, typename _Traits>
basic_ostream< _CharT, _Traits > & | operator<< (basic_ostream< _CharT, _Traits > &__os, const philox_engine &__x)
bool | operator== (const philox_engine &, const philox_engine &)=default
template<typename _CharT, typename _Traits>
basic_istream< _CharT, _Traits > & | operator>> (basic_istream< _CharT, _Traits > &__is, philox_engine &__x)

## Detailed Description

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>
class std::philox_engine< _UIntType, __w, __n, __r, __consts >

A discrete pseudorandom number generator with weak cryptographic properties.

This algorithm was designed to be used for highly parallel random number generation, and is capable of immensely long periods. It provides "Crush-resistance", denoting an ability to pass the TestU01 Suite's "Big Crush" test, demonstrating significant apparent entropy.

It is not intended for cryptographic use and should not be used for such, despite being based on cryptographic primitives.

The typedefs philox4x32 and philox4x64 are provided as suitable defaults for most use cases, providing high-quality random numbers with reasonable performance.

This algorithm was created by John Salmon, Mark Moraes, Ron Dror, and David Shaw as a product of D.E. Shaw Research.

Template Parameters

  __w | Word size
  __n | Buffer size
  __r | Rounds
  __consts | Multiplication and round constant pack, ordered as M_{0}, C_{0}, M_{1}, C_{1}, ... , M_{N/2-1}, C_{N/2-1}

Since
  C++26

Definition at line 2059 of file random.h.

## Member Typedef Documentation

## ◆ result_type

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

using std::philox_engine< _UIntType, __w, __n, __r, __consts >::result_type

Definition at line 2086 of file random.h.

## Constructor & Destructor Documentation

## ◆ philox_engine() [1/3]

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

std::philox_engine< _UIntType, __w, __n, __r, __consts >::philox_engine | ( |  | ) |
| inline

Definition at line 2111 of file random.h.

## ◆ philox_engine() [2/3]

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

std::philox_engine< _UIntType, __w, __n, __r, __consts >::philox_engine | ( | result_type | __value | ) |
| inlineexplicit

Definition at line 2116 of file random.h.

## ◆ philox_engine() [3/3]

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>
template<typename _Sseq>

std::philox_engine< _UIntType, __w, __n, __r, __consts >::philox_engine | ( | _Sseq & | __q | ) |
| inlineexplicit

seed sequence constructor for philox_engine

Parameters

  __q | the seed sequence

Definition at line 2126 of file random.h.

## Member Function Documentation

## ◆ discard()

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

void std::philox_engine< _UIntType, __w, __n, __r, __consts >::discard | ( | unsigned long long | __z | ) |
| inline

discards __z numbers

Parameters

  __z | number of iterations to discard

Definition at line 2185 of file random.h.

## ◆ max()

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

constexpr result_type std::philox_engine< _UIntType, __w, __n, __r, __consts >::max | ( |  | ) |
| inlinestaticconstexpr

The maximum value that this engine can return.

Definition at line 2103 of file random.h.

Referenced by std::philox_engine< uint_fast32_t, 32, 4, 10, 0xCD9E8D57, 0x9E3779B9, 0xD2511F53, 0xBB67AE85 >::operator>>, and std::philox_engine< uint_fast32_t, 32, 4, 10, 0xCD9E8D57, 0x9E3779B9, 0xD2511F53, 0xBB67AE85 >::set_counter().

## ◆ min()

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

constexpr result_type std::philox_engine< _UIntType, __w, __n, __r, __consts >::min | ( |  | ) |
| inlinestaticconstexpr

The minimum value that this engine can return.

Definition at line 2098 of file random.h.

## ◆ operator()()

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

result_type std::philox_engine< _UIntType, __w, __n, __r, __consts >::operator() | ( |  | ) |
| inline

outputs a single w-bit number and handles state advancement

Returns
  return_type

Definition at line 2174 of file random.h.

## ◆ seed() [1/2]

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>
requires __is_seed_seq<_Sseq>
template<typename _Sseq>
requires __is_seed_seq<_Sseq>

void std::philox_engine< _UIntType, __w, __n, __r, __consts >::seed | ( | _Sseq & | __q | ) |

seeds philox_engine by seed sequence

Parameters

  __q | the seed sequence

Definition at line 1016 of file bits/random.tcc.

References std::max().

## ◆ seed() [2/2]

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

void std::philox_engine< _UIntType, __w, __n, __r, __consts >::seed | ( | result_type | __value = default_seed | ) |
| inline

Definition at line 2132 of file random.h.

## ◆ set_counter()

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

void std::philox_engine< _UIntType, __w, __n, __r, __consts >::set_counter | ( | const array< result_type, __n > & | __counter | ) |
| inline

sets the internal counter "cleartext"

Parameters

  __counter | std::array of len N

Definition at line 2154 of file random.h.

## Friends And Related Symbol Documentation

## ◆ operator<<

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>
template<typename _CharT, typename _Traits>

basic_ostream< _CharT, _Traits > & operator<< | ( | basic_ostream< _CharT, _Traits > & | __os,
|  | const philox_engine< _UIntType, __w, __n, __r, __consts > & | __x )
| friend

outputs the state of the generator

Parameters

  __os | An output stream.
  __x | A philox_engine object reference

Returns
  the state of the Philox Engine in __os

Definition at line 2199 of file random.h.

## ◆ operator==

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

bool operator== | ( | const philox_engine< _UIntType, __w, __n, __r, __consts > & | ,
|  | const philox_engine< _UIntType, __w, __n, __r, __consts > & | )
| friend

compares two philox_engine objects

Returns
  true if the objects will produce an identical stream, false otherwise

## ◆ operator>>

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>
template<typename _CharT, typename _Traits>

basic_istream< _CharT, _Traits > & operator>> | ( | basic_istream< _CharT, _Traits > & | __is,
|  | philox_engine< _UIntType, __w, __n, __r, __consts > & | __x )
| friend

takes input to set the state of the philox_engine object

Parameters

  __is | An input stream.
  __x | A philox_engine object reference

Returns
  philox_engine object is set with values from instream

Definition at line 2227 of file random.h.

## Member Data Documentation

## ◆ default_seed

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

result_type std::philox_engine< _UIntType, __w, __n, __r, __consts >::default_seed
| staticconstexpr

Definition at line 2108 of file random.h.

## ◆ multipliers

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

array<result_type, __n / 2> std::philox_engine< _UIntType, __w, __n, __r, __consts >::multipliers
| staticconstexpr

Definition at line 2091 of file random.h.

## ◆ round_consts

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

array<result_type, __n / 2> std::philox_engine< _UIntType, __w, __n, __r, __consts >::round_consts
| staticconstexpr

Definition at line 2093 of file random.h.

## ◆ round_count

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

size_t std::philox_engine< _UIntType, __w, __n, __r, __consts >::round_count
| staticconstexpr

Definition at line 2090 of file random.h.

## ◆ word_count

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

size_t std::philox_engine< _UIntType, __w, __n, __r, __consts >::word_count
| staticconstexpr

Definition at line 2089 of file random.h.

## ◆ word_size

template<typename _UIntType, size_t __w, size_t __n, size_t __r, _UIntType... __consts>

size_t std::philox_engine< _UIntType, __w, __n, __r, __consts >::word_size
| staticconstexpr

Definition at line 2088 of file random.h.

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

- random.h
- bits/random.tcc