STD::LINEAR_CONGRUENTIAL_ENGINE(3)
π std::linear_congruential_engine< _UIntType, __a, __c, __m >(3) π
okay so bestie, this is the Library Functions Manual page for std::linear_congruential_engine< _UIntType, __a, __c, __m >. The header/footer shorthand is std::linea... __c, __m >(3), and the full manual-name energy is right here. It's giving C++ random-number-engine main character. π
πΈ NAME πΈ
std::linear_congruential_engine< _UIntType, __a, __c, __m > β A model of a linear congruential random number generator. No cap, that's the whole name section. π
β¨ SYNOPSIS β¨
#include <random>
π¦ Public Types π¦
typedef _UIntType result_typeβ the type of the generated random value. (Wait, the detailed typedef section says that too. Foreshadowing, bestie. β¨)
π 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.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 >
"A model of a linear congruential random number generator.
A random number generator that produces poeudorandom 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 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. π
π Constructor & Destructor Documentation π
linear_congruential_engine ()
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.
linear_congruential_engine (result_type __s)
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.
linear_congruential_engine (_Sseq & __q)
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.
π Member Function Documentation π
discard (unsigned long long __z)
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.
max ()
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
constexpr result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::max () [inline], [static], [constexpr]
Gets the largest possible value in the output range.
min ()
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
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.
operator() ()
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.
seed (_Sseq & __q)
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 >
Reseeds the linear_congruential_engine random number generator engine sequence using values from the seed sequence __q.
Parameters
__qβ the seed sequence.
Seeds the LCR engine with a value generated by __q.
References: std::__lg(), std::__numeric_limits_base::digits, and seed().
seed (result_type __s = default_seed)
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< uint_fast32_t, 16807UL, 0UL, 2147483647UL >::linear_congruential_engine(), std::linear_congruential_engine< uint_fast32_t, 16807UL, 0UL, 2147483647UL >::linear_congruential_engine(), and seed().
π Friends And Related Symbol Documentation π
operator<<
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.
operator==
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.
operator>>
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 π
increment
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::increment [static], [constexpr]
An increment.
modulus
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
result_type std::linear_congruential_engine< _UIntType, __a, __c, __m >::modulus [static], [constexpr]
The modulus.
multiplier
template<typename _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
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.
Cute sign-off, bestie: this whole vibe came from libstdc++, and the footer shorthand is std::linea... __c, __m >(3). The footer didn't hand me a date to spill, so that's the source/version tea. Stay slay, and may your LCR sequences be iconic. π
β¨
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms