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 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.
  • 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 the linear_congruential_engine random number generator engine sequence using values from the seed sequence __q.
  • void seed (result_type __s=default_seed) β€” Reseeds the linear_congruential_engine random 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_seed
  • static constexpr result_type increment
  • static constexpr result_type modulus
  • static 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 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.

🧚 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().


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_engine random 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

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

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_engine random 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