libstdc++: std::subtract_with_carry_engine< _UIntType, __w, __s, __r > Class Template Reference

libstdc++

std::subtract_with_carry_engine< _UIntType, __w, __s, __r > Class Template Reference
Numerics » Random Number Generation » Random Number Generators

`#include <random>`

## Public Types
typedef _UIntType | result_type

## Public Member Functions
template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
| subtract_with_carry_engine (_Sseq &__q)
| subtract_with_carry_engine (result_type __sd)
void | discard (unsigned long long __z)
result_type | operator() ()
template<typename _Sseq>
_If_seed_seq< _Sseq > | seed (_Sseq &__q)
void | seed (result_type __sd=0u)

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

## Static Public Attributes
static constexpr uint_least32_t | default_seed
static constexpr size_t | long_lag
static constexpr size_t | short_lag
static constexpr size_t | word_size

## Friends
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1, typename _CharT, typename _Traits>
std::basic_ostream< _CharT, _Traits > & | operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > &__x)
bool | operator== (const subtract_with_carry_engine &__lhs, const subtract_with_carry_engine &__rhs)
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1, typename _CharT, typename _Traits>
std::basic_istream< _CharT, _Traits > & | operator>> (std::basic_istream< _CharT, _Traits > &__is, std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > &__x)

## Detailed Description

template<typename _UIntType, size_t __w, size_t __s, size_t __r>
class std::subtract_with_carry_engine< _UIntType, __w, __s, __r >

The Marsaglia-Zaman generator.

This is a model of a Generalized Fibonacci discrete random number generator, sometimes referred to as the SWC generator.

A discrete random number generator that produces pseudorandom numbers using:

The size of the state is and the maximum period of the generator is .

Since
  C++11

Definition at line 1150 of file random.h.

## Member Typedef Documentation

## ◆ result_type

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

typedef _UIntType std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::result_type

The type of the generated random value.

Definition at line 1165 of file random.h.

## Constructor & Destructor Documentation

## ◆ subtract_with_carry_engine() [1/3]

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::subtract_with_carry_engine | ( |  | ) |
| inline

Definition at line 1173 of file random.h.

## ◆ subtract_with_carry_engine() [2/3]

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::subtract_with_carry_engine | ( | result_type | __sd | ) |
| inlineexplicit

Constructs an explicitly seeded subtract_with_carry_engine random number generator.

Definition at line 1181 of file random.h.

## ◆ subtract_with_carry_engine() [3/3]

template<typename _UIntType, size_t __w, size_t __s, size_t __r>
template<typename _Sseq, typename = _If_seed_seq<_Sseq>>

std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::subtract_with_carry_engine | ( | _Sseq & | __q | ) |
| inlineexplicit

Constructs a subtract_with_carry_engine random number engine seeded from the seed sequence `__q`.

Parameters

  __q | the seed sequence.

Definition at line 1192 of file random.h.

## Member Function Documentation

## ◆ discard()

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

void std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::discard | ( | unsigned long long | __z | ) |
| inline

Discard a sequence of random numbers.

Definition at line 1238 of file random.h.

## ◆ max()

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

constexpr result_type std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::max | ( |  | ) |
| inlinestaticconstexpr

Gets the inclusive maximum value of the range of random integers returned by this generator.

Definition at line 1231 of file random.h.

## ◆ min()

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

constexpr result_type std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::min | ( |  | ) |
| inlinestaticconstexpr

Gets the inclusive minimum value of the range of random integers returned by this generator.

Definition at line 1223 of file random.h.

## ◆ operator()()

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

subtract_with_carry_engine< _UIntType, __w, __s, __r >::result_type std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::operator() | ( |  | ) |

Gets the next random number in the sequence.

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

## ◆ seed() [1/2]

template<typename _UIntType, size_t __w, size_t __s, size_t __r>
template<typename _Sseq>

auto std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::seed | ( | _Sseq & | __q | ) | -> _If_seed_seq< _Sseq >

Seeds the initial state of the % subtract_with_carry_engine random number generator.

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

## ◆ seed() [2/2]

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

void std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::seed | ( | result_type | __sd = 0u | ) |

Seeds the initial state of the random number generator.

N1688[4.19] modifies this as follows. If `__value` == 0, sets value to 19780503. In any case, with a linear congruential generator lcg(i) having parameters , sets to respectively. If set carry to 1, otherwise sets carry to 0.

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

Referenced by std::subtract_with_carry_engine< uint_fast32_t, 24, 10, 24 >::subtract_with_carry_engine(), and std::subtract_with_carry_engine< uint_fast32_t, 24, 10, 24 >::subtract_with_carry_engine().

## Friends And Related Symbol Documentation

## ◆ operator<<

template<typename _UIntType, size_t __w, size_t __s, size_t __r>
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1, typename _CharT, typename _Traits>

std::basic_ostream< _CharT, _Traits > & operator<< | ( | std::basic_ostream< _CharT, _Traits > & | __os,
|  | const std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > & | __x )
| friend

Inserts the current state of a % subtract_with_carry_engine random number generator engine `__x` into the output stream `__os`.

Parameters

  __os | An output stream.
  __x | A % subtract_with_carry_engine random number generator engine.

Returns
  The output stream with the state of `__x` inserted or in an error state.

## ◆ operator==

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

bool operator== | ( | const subtract_with_carry_engine< _UIntType, __w, __s, __r > & | __lhs,
|  | const subtract_with_carry_engine< _UIntType, __w, __s, __r > & | __rhs )
| friend

Compares two % subtract_with_carry_engine random number generator objects of the same type for equality.

Parameters

  __lhs | A % subtract_with_carry_engine random number generator object.
  __rhs | Another % subtract_with_carry_engine random number generator object.

Returns
  true if the infinite sequences of generated values would be equal, false otherwise.

Definition at line 1263 of file random.h.

## ◆ operator>>

template<typename _UIntType, size_t __w, size_t __s, size_t __r>
template<typename _UIntType1, size_t __w1, size_t __s1, size_t __r1, typename _CharT, typename _Traits>

std::basic_istream< _CharT, _Traits > & operator>> | ( | std::basic_istream< _CharT, _Traits > & | __is,
|  | std::subtract_with_carry_engine< _UIntType1, __w1, __s1, __r1 > & | __x )
| friend

Extracts the current state of a % subtract_with_carry_engine random number generator engine `__x` from the input stream `__is`.

Parameters

  __is | An input stream.
  __x | A % subtract_with_carry_engine random number generator engine.

Returns
  The input stream with the state of `__x` extracted or in an error state.

## Member Data Documentation

## ◆ default_seed

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

uint_least32_t std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::default_seed
| staticconstexpr

Definition at line 1171 of file random.h.

## ◆ long_lag

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

size_t std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::long_lag
| staticconstexpr

Definition at line 1170 of file random.h.

## ◆ short_lag

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

size_t std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::short_lag
| staticconstexpr

Definition at line 1169 of file random.h.

## ◆ word_size

template<typename _UIntType, size_t __w, size_t __s, size_t __r>

size_t std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::word_size
| staticconstexpr

Definition at line 1168 of file random.h.

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

- random.h
- bits/random.tcc