std::subtract_with_carry_engine< _UIntType, __w, __s, __r > - The Marsaglia-Zaman generator.
Contents
Constructor & Destructor Documentation
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)[inline],[explicit]
Constructs an explicitly seeded subtract_with_carry_engine random number generator.
References std::subtract_with_carry_engine<_UIntType,__w,__s,__r>::seed().
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)[inline],[explicit]
Constructs a subtract_with_carry_engine random number engine seeded from the seed sequence __q.
Parameters__q the seed sequence.
References std::subtract_with_carry_engine<_UIntType,__w,__s,__r>::seed().
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 pseuoorandom numbers using:
x_{i}tarrow(x_{i - s} - x_{i - r} - carry_{i-1}) d ]
The size of the state is $r$ and the maximum period of the generator is $(m^r - m^s - 1)$.
Since
C++11
Member Function Documentation
template<typename_UIntType,size_t__w,size_t__s,size_t__r>voidstd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::discard(unsignedlonglong__z)[inline]
Discard a sequence of random numbers.
template<typename_UIntType,size_t__w,size_t__s,size_t__r>staticconstexprresult_typestd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::max()[inline],[static],[constexpr]
Gets the inclusive maximum value of the range of random integers returned by this generator.
template<typename_UIntType,size_t__w,size_t__s,size_t__r>staticconstexprresult_typestd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::min()[inline],[static],[constexpr]
Gets the inclusive minimum value of the range of random integers returned by this generator.
template<typename_UIntType,size_t__w,size_t__s,size_t__r>subtract_with_carry_engine<_UIntType,__w,__s,__r>::result_typestd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::operator()()
Gets the next random number in the sequence.
template<typename_UIntType,size_t__w,size_t__s,size_t__r>template<typename_Sseq>_If_seed_seq<_Sseq>std::subtract_with_carry_engine<_UIntType,__w,__s,__r>::seed(_Sseq&__q)
Seeds the initial state $x_0$ of the % subtract_with_carry_engine random number generator.
template<typename_UIntType,size_t__w,size_t__s,size_t__r>voidstd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::seed(result_type__sd=0u)
Seeds the initial state $x_0$ 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 $ m_{lcg} o 2147483563,oa_{lcg} = 40014, c_{lcg} = 0, and lcg(0) = value $, sets $ x_{-r} ots
x_{-1} $ to $ lcg(1) d ots lcg(r) d $ respectively. If $ x_{-1} = 0 $ set carry to 1, otherwise sets
carry to 0.
Referenced by std::subtract_with_carry_engine<_UIntType,__w,__s,__r>::subtract_with_carry_engine(),
and std::subtract_with_carry_engine<_UIntType,__w,__s,__r>::subtract_with_carry_engine().
Member Typedef Documentation
template<typename_UIntType,size_t__w,size_t__s,size_t__r>typedef_UIntTypestd::subtract_with_carry_engine<_UIntType,__w,__s,__r>::result_type
The type of the generated random value.
Name
std::subtract_with_carry_engine< _UIntType, __w, __s, __r > - The Marsaglia-Zaman generator.
Synopsis
#include <random>
PublicTypestypedef _UIntType result_typePublicMemberFunctions
template<typename_Sseq , typename = _If_seed_seq<_Sseq>> subtract_with_carry_engine (_Sseq &__q)
Constructs a subtract_with_carry_engine random number engine seeded from the seed sequence __q.
subtract_with_carry_engine (result_type__sd)
Constructs an explicitly seeded subtract_with_carry_engine random number generator.
voiddiscard (unsigned long long __z)
Discard a sequence of random numbers.
result_typeoperator() ()
Gets the next random number in the sequence.
template<typename_Sseq > _If_seed_seq< _Sseq > seed (_Sseq &__q)
Seeds the initial state $x_0$ of the % subtract_with_carry_engine random number generator.
template<typename_Sseq > autoseed (_Sseq &__q) -> _If_seed_seq< _Sseq >
voidseed (result_type__sd=0u)
Seeds the initial state $x_0$ of the random number generator.
StaticPublicMemberFunctionsstatic constexpr result_typemax ()
Gets the inclusive maximum value of the range of random integers returned by this generator.
static constexpr result_typemin ()
Gets the inclusive minimum value of the range of random integers returned by this generator.
StaticPublicAttributesstatic constexpr uint_least32_t default_seedstatic constexpr size_t long_lagstatic constexpr size_t short_lagstatic constexpr size_t word_sizeFriends
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)
Inserts the current state of a % subtract_with_carry_engine random number generator engine __x into
the output stream __os.
bool operator== (const subtract_with_carry_engine &__lhs, const subtract_with_carry_engine &__rhs)
Compares two % subtract_with_carry_engine random number generator objects of the same type for
equality.
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)
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from
the input stream __is.
