STD::LINEAR_CONGRUENTIAL_ENGINE(3cxx)
β¨ NAME β¨
okay bestie, this is the 3cxx manual page for std::linear_congruential_engine< _UIntType, __a, __c, __m > β and it is literally a model of a linear congruential random number generator. no cap. π
π SYNOPSIS π
#include <random>
π Public Types π
typedef _UIntType result_typeβ the type it spits out, periodt.
π Public Member Functions π
linear_congruential_engine ()β Constructs alinear_congruential_enginerandom number generator engine with seed1.template<typename _Sseq , typename = _If_seed_seq<_Sseq>> linear_congruential_engine (_Sseq &__q)β Constructs alinear_congruential_enginerandom number generator engine seeded from the seed sequence__q.linear_congruential_engine (result_type __s)β Constructs alinear_congruential_enginerandom number generator engine with seed__s. The default seed value is1.void discard (unsigned long long __z)β Discard a sequence of random numbers.result_type operator() ()β Gets the next random number in the sequence.template<typename _Sseq > _If_seed_seq< _Sseq > seed (_Sseq &__q)β Reseeds thelinear_congruential_enginerandom number generator engine sequence using values from the seed sequence__q.template<typename _Sseq > auto seed (_Sseq &__q) -> _If_seed_seq< _Sseq >β another seed-sequence overload, slay.void seed (result_type __s=default_seed)β Reseeds thelinear_congruential_enginerandom number generator engine sequence to the seed__s.
β¨ Static Public Member Functions β¨
static constexpr result_type max ()β Gets the largest possible value in the output range.static constexpr result_type min ()β Gets the smallest possible value in the output range.
π¦ Static Public Attributes π¦
static constexpr result_type default_seedstatic constexpr result_type incrementstatic constexpr result_type modulusstatic constexpr result_type multiplier
π«Ά Friends π«Ά
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 statex(i)ofxto__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.
πΈ Detailed Description πΈ
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
class std::linear_congruential_engine< _UIntType, __a, __c, __m >
The self-description starts like this, quote mark and all: "A model of a linear congruential random number generator.
It's a random number generator that produces pseudorandom numbers via linear function. The manpage renders the formula like this, weird artifacts and all β I'm keeping it exactly as written, bestie:
o
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$ β yes, the dollar signs are literally in the text, iykyk. π
Since: C++11
π Member Typedef Documentation π
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
typedef _UIntType std::linear_congruential_engine< _UIntType, __a, __c, __m >::result_type
The type of the generated random value. iconic. β¨
π 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().
π₯ Member Function Documentation π₯
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
void std::linear_congruential_engine< _UIntType, __a, __c, __m >::discard (unsigned long long __z) [inline]
Discard a sequence of random numbers. bye-bye, numbers. π
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
static constexpr result_type std::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>
static constexpr result_type std::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. important little detail, don't skip it. π«Ά
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
result_type std::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 > auto std::linear_congruential_engine< _UIntType, __a, __c, __m >::seed (_Sseq & __q) -> _If_seed_seq<_Sseq>
The text says: " Seeds the LCR engine with a value generated by __q.
- References:
std::__lg().
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
void std::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(), andstd::linear_congruential_engine< _UIntType, __a, __c, __m >::linear_congruential_engine(). yes, it lists that twice, and I'm not erasing the manpage's little quirks. π
π Friends And Related Symbol Documentation π
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
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) [friend]
Writes the textual representation of the state x(i) of x to __os.
- Parameters:
__osβ The output stream.__lcrβ A% linear_congruential_enginerandom number generator.
- Returns:
__os.
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
bool operator== (const linear_congruential_engine< _UIntType, __a, __c, __m > & __lhs, const linear_congruential_engine< _UIntType, __a, __c, __m > & __rhs) [friend]
Compares two linear congruential random number generator objects of the same type for equality.
- Parameters:
__lhsβ A linear congruential random number generator object.__rhsβ Another linear congruential random number generator object.
- Returns:
trueif the infinite sequences of generated values would be equal,falseotherwise.
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
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) [friend]
Sets the state of the engine by reading its textual representation from __is. The textual representation must have been previously written using an output stream whose imbued locale and whose type's template specialization arguments _CharT and _Traits were the same as those of __is.
- Parameters:
__isβ The input stream.__lcrβ A% linear_congruential_enginerandom number generator.
- Returns:
__is.
π Member Data Documentation π
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
constexpr result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::increment [static], [constexpr]
An increment.
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
constexpr result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::modulus [static], [constexpr]
The modulus.
template<typename _UIntType , _UIntType __a, _UIntType __c, _UIntType __m>
constexpr result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::multiplier [static], [constexpr]
The multiplier.
π Author π
Generated automatically by Doxygen for libstdc++ from the source code.
okay that's the whole page, bestie! cute sign-off time: source/version is libstdc++ + 3cxx, and the date field in that footer line isn't actually shown in the text I got β so I'm not inventing one, periodt. mwah πβ¨π
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms