STD::SUBTRACT_WITH_CARRY_ENGINE(3cxx)
π NAME π
std::subtract_with_carry_engine< _UIntType, __w, __s, __r > β the Marsaglia-Zaman generator. This is the 3cxx manual page for it, bestie, and it's giving very specific random-number-engine energy. π
π SYNOPSIS π
#include <random>
β¨ Public Types β¨
typedef _UIntType result_type
π Public Member Functions π
template<typename _Sseq , typename = _If_seed_seq<_Sseq>> subtract_with_carry_engine (_Sseq &__q)β constructs asubtract_with_carry_enginerandom number engine seeded from the seed sequence__q.subtract_with_carry_engine (result_type __sd)β constructs an explicitly seededsubtract_with_carry_enginerandom number generator.void discard (unsigned long long __z)β discards 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)β seeds the initial state$x_0$of the% subtract_with_carry_enginerandom number generator.template<typename _Sseq > auto seed (_Sseq &__q) -> _If_seed_seq< _Sseq >β the synopsis lists this overload too, with no extra blurb attached, so no invented tea here. πvoid seed (result_type __sd=0u)β seeds the initial state$x_0$of the random number generator.
π¦ Static Public Member Functions π¦
static constexpr result_type max ()β gets the inclusive maximum value of the range of random integers returned by this generator.static constexpr result_type min ()β gets the inclusive minimum value of the range of random integers returned by this generator.
π Static Public Attributes π
static constexpr uint_least32_t default_seedstatic constexpr size_t long_lagstatic constexpr size_t short_lagstatic constexpr size_t word_size
π§ Friends π§
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_enginerandom number generator engine__xinto the output stream__os.bool operator== (const subtract_with_carry_engine &__lhs, const subtract_with_carry_engine &__rhs)β compares two% subtract_with_carry_enginerandom 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_enginerandom number generator engine__xfrom the input stream__is.
π 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.
Okay so this is the Marsaglia-Zaman generator, and it's a model of a Generalized Fibonacci discrete random number generator, sometimes referred to as the SWC generator.
It's a discrete random number generator that produces pseudorandom numbers using β and yes, the source has a stray o hanging around right before the formula, keeping it real:
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 Typedef Documentation π§
template<typename _UIntType , size_t __w , size_t __s , size_t __r> typedef _UIntType std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::result_type
The type of the generated random value. Slay. β¨
π Constructor & Destructor Documentation π
Explicit seeded constructor
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().
Seed-sequence constructor
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
__qthe seed sequence.
References std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::seed().
π Member Function Documentation π
discard
template<typename _UIntType , size_t __w , size_t __s , size_t __r> void
std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::discard
(unsigned long long __z) [inline]
Discard a sequence of random numbers.
max
template<typename _UIntType , size_t __w , size_t __s , size_t __r> static
constexpr result_type std::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.
min
template<typename _UIntType , size_t __w , size_t __s , size_t __r> static
constexpr result_type std::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.
operator()
template<typename _UIntType , size_t __w , size_t __s , size_t __r>
subtract_with_carry_engine< _UIntType, __w, __s, __r >::result_type
std::subtract_with_carry_engine< _UIntType, __w, __s, __r >::operator()
()
Gets the next random number in the sequence.
seed(_Sseq & __q)
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.
seed(result_type __sd = 0u)
template<typename _UIntType , size_t __w , size_t __s , size_t __r> void
std::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} = 2147483563, a_{lcg} = 40014, c_olcg} = 0,
and lcgo0) = 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().
πΈ Friends And Related Symbol Documentation πΈ
operator<<
template<typename _UIntType , size_t __w , size_t __s , size_t __r>
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)
[friend]
Inserts the current state of a % subtract_with_carry_engine random number generator engine __x into the output stream __os.
Parameters
__osAn output stream.__xA% subtract_with_carry_enginerandom number generator engine.
Returns
The output stream with the state of __x inserted or in an error state.
operator==
template<typename _UIntType , size_t __w , size_t __s , size_t __r> bool
operator== (const subtract_with_carry_engine< _UIntType, __w, __s, __r >
& __lhs, const subtract_with_carry_engine< _UIntType, __w, __s, __r > &
__rhs) [friend]
Compares two % subtract_with_carry_engine random number generator objects of the same type for equality.
Parameters
__lhsA% subtract_with_carry_enginerandom number generator object.__rhsAnother% subtract_with_carry_enginerandom number generator object.
Returns
true if the infinite sequences of generated values would be equal, false otherwise.
operator>>
template<typename _UIntType , size_t __w , size_t __s , size_t __r>
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)
[friend]
Extracts the current state of a % subtract_with_carry_engine random number generator engine __x from the input stream __is.
Parameters
__isAn input stream.__xA% subtract_with_carry_enginerandom number generator engine.
Returns
The input stream with the state of __x extracted or in an error state.
π«Ά Author π«Ά
Generated automatically by Doxygen for libstdc++ from the source code.
And that's the whole page, bestie π«Ά. Source/version tea: this one's generated automatically by Doxygen for libstdc++ from the source code, and the footer is the usual truncated 3cxx manual-footer vibe for the std::subtract_...__w, __s, __r > page. No actual date is printed on it, so no cap β that's literally all the footer gives us. π
β¨
π¦ 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