STD::MERSENNE_TWISTER_ENGINE(3)
β¨ NAME β¨
std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f > β bestie, this is the Library Functions Manual page for it, okurrr π
π SYNOPSIS π
#include <random>
π Public Types π
typedef _UIntType result_type
πΈ Public Member Functions πΈ
template<typename _Sseq, typename = _If_seed_seq<_Sseq>> mersenne_twister_engine (_Sseq &__q)β Constructs a mersenne_twister_engine random number generator engine seeded from the seed sequence__q.mersenne_twister_engine (result_type __sd)void discard (unsigned long long __z)β Discard a sequence of random numbers.result_type operator() ()template<typename _Sseq> _If_seed_seq< _Sseq > seed (_Sseq &__q)void seed (result_type __sd=default_seed)
π¦ 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 initialization_multiplierstatic constexpr size_t mask_bitsstatic constexpr size_t shift_sizestatic constexpr size_t state_sizestatic constexpr result_type tempering_bstatic constexpr result_type tempering_cstatic constexpr result_type tempering_dstatic constexpr size_t tempering_lstatic constexpr size_t tempering_sstatic constexpr size_t tempering_tstatic constexpr size_t tempering_ustatic constexpr size_t word_sizestatic constexpr result_type xor_mask
π Friends π
template<typename _UIntType1, size_t __w1, size_t __n1, size_t __m1, size_t __r1, _UIntType1 __a1, size_t __u1, _UIntType1 __d1, size_t __s1, _UIntType1 __b1, size_t __t1, _UIntType1 __c1, size_t __l1, _UIntType1 __f1, typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits > & operator<< (std::basic_ostream< _CharT, _Traits > &__os, const std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > &__x)β Inserts the current state of a % mersenne_twister_engine random number generator engine__xinto the output stream__os.bool operator== (const mersenne_twister_engine &__lhs, const mersenne_twister_engine &__rhs)β Compares two % mersenne_twister_engine random number generator objects of the same type for equality.template<typename _UIntType1, size_t __w1, size_t __n1, size_t __m1, size_t __r1, _UIntType1 __a1, size_t __u1, _UIntType1 __d1, size_t __s1, _UIntType1 __b1, size_t __t1, _UIntType1 __c1, size_t __l1, _UIntType1 __f1, typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits > & operator>> (std::basic_istream< _CharT, _Traits > &__is, std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1, __u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > &__x)β Extracts the current state of a % mersenne_twister_engine random number generator engine__xfrom the input stream__is.
π Detailed Description π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f>
class std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a,
__u, __d, __s, __b, __t, __c, __l, __f >
okay so, it's literally "A generalized feedback shift register discrete random number generator." π
This algorithm avoids multiplication and division and is designed to be friendly to a pipelined architecture. If the parameters are chosen correctly, this generator will produce numbers with a very long period and fairly good apparent entropy, although still not cryptographically strong π so do NOT use it for your secrets, bestie.
The best way to use this generator is with the predefined mt19937 class. slay β¨
This algorithm was originally invented by Makoto Matsumoto and Takuji Nishimura. genuinely iconic of them π«Ά
π§ Template Parameters π§
__wβ Word size, the number of bits in each element of the state vector.__nβ The degree of recursion.__mβ The period parameter.__rβ The separation point bit index.__aβ The last row of the twist matrix.__uβ The first right-shift tempering matrix parameter.__dβ The first right-shift tempering matrix mask.__sβ The first left-shift tempering matrix parameter.__bβ The first left-shift tempering matrix mask.__tβ The second left-shift tempering matrix parameter.__cβ The second left-shift tempering matrix mask.__lβ The second right-shift tempering matrix parameter.__fβ Initialization multiplier.
π Since π
C++11
π Member Typedef Documentation π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> typedef _UIntType
std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a, __u,
__d, __s, __b, __t, __c, __l, __f >::result_type
The type of the generated random value. that's the whole vibe of it πΈ
π Constructor & Destructor Documentation π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> template<typename
_Sseq, typename = _If_seed_seq<_Sseq>> std::mersenne_twister_engine<
_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l,
__f >::mersenne_twister_engine (_Sseq & __q) [inline], [explicit]
Constructs a mersenne_twister_engine random number generator engine seeded from the seed sequence __q. π
Note the [explicit] β no sneaky implicit conversions around here, periodt π
Parameters
__qβ the seed sequence.
π₯ Member Function Documentation π₯
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> void
std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a, __u,
__d, __s, __b, __t, __c, __l, __f >::discard (unsigned long long __z)
Discard a sequence of random numbers. yeet them, basically π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> constexpr
result_type std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r,
__a, __u, __d, __s, __b, __t, __c, __l, __f >::max () [inline],
[static], [constexpr]
Gets the largest possible value in the output range. π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> constexpr
result_type std::mersenne_twister_engine< _UIntType, __w, __n, __m, __r,
__a, __u, __d, __s, __b, __t, __c, __l, __f >::min () [inline],
[static], [constexpr]
Gets the smallest possible value in the output range. π¦
π Friends And Related Symbol Documentation π
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> template<typename
_UIntType1, size_t __w1, size_t __n1, size_t __m1, size_t __r1,
_UIntType1 __a1, size_t __u1, _UIntType1 __d1, size_t __s1, _UIntType1
__b1, size_t __t1, _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
typename _CharT, typename _Traits> std::basic_ostream< _CharT, _Traits >
& operator<< (std::basic_ostream< _CharT, _Traits > & __os, const
std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1,
__u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > & __x) [friend]
Inserts the current state of a % mersenne_twister_engine random number generator engine __x into the output stream __os. β¨
Parameters
__osβ An output stream.__xβ A % mersenne_twister_engine random number generator engine.
Returns
The output stream with the state of __x inserted or in an error state.
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> bool operator==
(const mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a, __u,
__d, __s, __b, __t, __c, __l, __f > & __lhs, const
mersenne_twister_engine< _UIntType, __w, __n, __m, __r, __a, __u, __d,
__s, __b, __t, __c, __l, __f > & __rhs) [friend]
Compares two % mersenne_twister_engine random number generator objects of the same type for equality. vibe check, but make it mathematical π
Parameters
__lhsβ A % mersenne_twister_engine random number generator object.__rhsβ Another % mersenne_twister_engine random number generator object.
Returns
true if the infinite sequences of generated values would be equal, false otherwise.
template<typename _UIntType, size_t __w, size_t __n, size_t __m, size_t __r,
_UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b,
size_t __t, _UIntType __c, size_t __l, _UIntType __f> template<typename
_UIntType1, size_t __w1, size_t __n1, size_t __m1, size_t __r1,
_UIntType1 __a1, size_t __u1, _UIntType1 __d1, size_t __s1, _UIntType1
__b1, size_t __t1, _UIntType1 __c1, size_t __l1, _UIntType1 __f1,
typename _CharT, typename _Traits> std::basic_istream< _CharT, _Traits >
& operator>> (std::basic_istream< _CharT, _Traits > & __is,
std::mersenne_twister_engine< _UIntType1, __w1, __n1, __m1, __r1, __a1,
__u1, __d1, __s1, __b1, __t1, __c1, __l1, __f1 > & __x) [friend]
Extracts the current state of a % mersenne_twister_engine random number generator engine __x from the input stream __is. π«Ά
Parameters
__isβ An input stream.__xβ A % mersenne_twister_engine random 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.
not a single human hand wrote this and honestly? it ate. π
and that's the whole page, bestie β big libstdc++ energy, dated by the std::merse...__l, __f >(3) in the corner, from your friendly neighborhood Library Functions Manual ππβ¨
π¦ 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