std::linear_congruential_engine< _UIntType, __a, __c, __m > - A model of a linear congruential random
Contents
Constructor & Destructor Documentation
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>std::linear_congruential_engine<_UIntType,__a,__c,__m>::linear_congruential_engine()[inline]
Constructs a linear_congruential_engine random number generator engine with seed 1.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>std::linear_congruential_engine<_UIntType,__a,__c,__m>::linear_congruential_engine(result_type__s)[inline],[explicit]
Constructs a linear_congruential_engine random number generator engine with seed __s. The default seed
value is 1.
Parameters__s The initial seed value.
References std::linear_congruential_engine<_UIntType,__a,__c,__m>::seed().
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>template<typename_Sseq,typename=_If_seed_seq<_Sseq>>std::linear_congruential_engine<_UIntType,__a,__c,__m>::linear_congruential_engine(_Sseq&__q)[inline],[explicit]
Constructs a linear_congruential_engine random number generator engine seeded from the seed sequence __q.
Parameters__q the seed sequence.
References std::linear_congruential_engine<_UIntType,__a,__c,__m>::seed().
Detailed Description
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>
class std::linear_congruential_engine< _UIntType, __a, __c, __m >"A model of a linear congruential random
number generator.
A random number generator thatoproduces pseudorandom numbers via linear function:
x_{i+1}tarrow(ax_{i} + c) d ]
The template parameter _UIntType must be an unsigned integral type large enough to store values up to
(__m-1). If the template parameter __m is 0, the modulus __m used is
std::numeric_limits<_UIntType>::max() plus 1. Otherwise, the template parameters __a and __c must be less
than __m.
The size of the state is $1$.
Since
C++11
Member Data Documentation
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>constexprresult_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::increment[static],[constexpr]
An increment.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>constexprresult_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::modulus[static],[constexpr]
The modulus.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>constexprresult_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::multiplier[static],[constexpr]
The multiplier.
Member Function Documentation
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>voidstd::linear_congruential_engine<_UIntType,__a,__c,__m>::discard(unsignedlonglong__z)[inline]
Discard a sequence of random numbers.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>staticconstexprresult_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::max()[inline],[static],[constexpr]
Gets the largest possible value in the output range.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>staticconstexprresult_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::min()[inline],[static],[constexpr]
Gets the smallest possible value in the output range. The minimum depends on the __c parameter: if it is
zero, the minimum generated must be > 0, otherwise 0 is allowed.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>result_typestd::linear_congruential_engine<_UIntType,__a,__c,__m>::operator()()[inline]
Gets the next random number in the sequence.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>template<typename_Sseq>_If_seed_seq<_Sseq>std::linear_congruential_engine<_UIntType,__a,__c,__m>::seed(_Sseq&__q)
Reseeds the linear_congruential_engine random number generator engine sequence using values from the seed
sequence __q.
Parameters__q the seed sequence.
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>template<typename_Sseq>autostd::linear_congruential_engine<_UIntType,__a,__c,__m>::seed(_Sseq&__q)->_If_seed_seq<_Sseq>
" Seeds the LCR engine with a value generated by __q.
References std::__lg().
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>voidstd::linear_congruential_engine<_UIntType,__a,__c,__m>::seed(result_type__s=default_seed)
Reseeds the linear_congruential_engine random number generator engine sequence to the seed __s.
Parameters__s The new seed.
Seeds the LCR with integral value __s, adjusted so that the ring identity is never a member of the
convergence set.
Referenced by std::linear_congruential_engine<_UIntType,__a,__c,__m>::linear_congruential_engine(),
and std::linear_congruential_engine<_UIntType,__a,__c,__m>::linear_congruential_engine().
Member Typedef Documentation
template<typename_UIntType,_UIntType__a,_UIntType__c,_UIntType__m>typedef_UIntTypestd::linear_congruential_engine<_UIntType,__a,__c,__m>::result_type
The type of the generated random value.
Name
std::linear_congruential_engine< _UIntType, __a, __c, __m > - A model of a linear congruential random
number generator.
Synopsis
#include <random>
PublicTypestypedef _UIntType result_typePublicMemberFunctionslinear_congruential_engine ()
Constructs a linear_congruential_engine random number generator engine with seed 1.
template<typename_Sseq , typename = _If_seed_seq<_Sseq>> linear_congruential_engine (_Sseq &__q)
Constructs a linear_congruential_engine random number generator engine seeded from the seed sequence
__q.
linear_congruential_engine (result_type__s)
Constructs a linear_congruential_engine random number generator engine with seed __s. The default
seed value is 1.
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)
Reseeds the linear_congruential_engine random number generator engine sequence using values from the
seed sequence __q.
template<typename_Sseq > autoseed (_Sseq &__q) -> _If_seed_seq< _Sseq >
voidseed (result_type__s=default_seed)
Reseeds the linear_congruential_engine random number generator engine sequence to the seed __s.
StaticPublicMemberFunctionsstatic constexpr result_typemax ()
Gets the largest possible value in the output range.
static constexpr result_typemin ()
Gets the smallest possible value in the output range.
StaticPublicAttributesstatic constexpr result_typedefault_seedstatic constexpr result_typeincrementstatic constexpr result_typemodulusstatic constexpr result_typemultiplierFriends
template<typename_UIntType1 , _UIntType1 __a1, _UIntType1 __c1, _UIntType1 __m1, typename _CharT ,
typename _Traits > std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT,
_Traits > &__os, const std::linear_congruential_engine< _UIntType1, __a1, __c1, __m1 > &__lcr)
Writes the textual representation of the state x(i) of x to __os.
bool operator== (const linear_congruential_engine &__lhs, const linear_congruential_engine &__rhs)
Compares two linear congruential random number generator objects of the same type for equality.
template<typename_UIntType1 , _UIntType1 __a1, _UIntType1 __c1, _UIntType1 __m1, typename _CharT ,
typename _Traits > std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT,
_Traits > &__is, std::linear_congruential_engine< _UIntType1, __a1, __c1, __m1 > &__lcr)
Sets the state of the engine by reading its textual representation from __is.
