FreeBSD Manual Pages
std::mersen...ister_engine(3) C++ Standard Libarystd::mersen...ister_engine(3) NAME std::mersenne_twister_engine::mersenne_twister_engine - std::mersenne_twister_engine::mersenne_twister_engine Synopsis mersenne_twister_engine() : (1) (since C++11) mersenne_twister_engine(default_seed) {} explicit mersenne_twister_engine( result_type value ); (2) (since C++11) template< class SeedSeq > (3) (since C++11) explicit mersenne_twister_engine( SeedSeq& seq ); mersenne_twister_engine( const mersenne_twister_engine& (4) (since C++11) other ); (im- plicitly declared) Constructs the pseudo-random number engine. 1) The default constructor. 2) Constructs the engine with a seed value value. Given \(2^w\)2w as p, the engine's initial state is determined as follows: 1. Sets \(X_{-n}\)X -n to value % p. 2. For each integer i in [i - n, -1], sets \(X_i\)X i to \([f \cdot (X_{i-1}\ \mathsf{xor}\ (X_{i-1}\ \mathsf{rshift}\ (w-2)))+i\mod n]\mod p\)[f(X i-1 xor (X i-1 rshift (w-2)))+i mod n] mod p, where \(\mathsf{xor}\)xor and \(\mathsf{rshift}\)rshift stand for built-in bitwise XOR and bitwise right-shift respectively. 3) Constructs the engine with a seed sequence seq. Given std::size_t(w / 32) + 1 as k, the engine's initial state is determined as follows: 1. Creates an invented array object a of length n * k. 2. Calls seq.generate(a + 0, a + n * k). 3. For each integer i in [-n, -1], sets \(X_{i}\)X i to \((\sum^{k-1}_{j=0} a_{k(i+n)+j} \cdot 2^{32j}) \mod 2^w\)(k-1 j=0 a k(i+n)+j232j ) mod 2w . 4. If the most significant w r bits of \(X_{-n}\)X -n are zero, and if each of the other resulting \(X_{i}\)X i is 0, changes \(X_{-n}\)X -n to \(2^{w-1}\)2w-1 . This overload participates in overload resolution only if SeedSeq meets the requirements of SeedSequence. 4) The copy constructor. Upon construction, *this == other is true. Parameters value - seed value to use in the initialization of the internal state seq - seed sequence to use in the initialization of the internal state Complexity 1,2) \(\small{O(n)}\)O(n). 3) Same as the complexity of the seq.generate call. 4) \(\small{O(n)}\)O(n). Defect reports The following behavior-changing defect reports were applied retroac- tively to previously published C++ standards. DR Applied to Behavior as published Correct be- havior P0935R0 C++11 the default constructor was explicit made im- plicit See also seed sets the current state of the engine (C++11) (public member function) http://cppreference.com 2024.06.10 std::mersen...ister_engine(3)
NAME | Synopsis | Parameters | Complexity | See also
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=std::mersenne_twister_engine::mersenne_twister_engine&sektion=3&manpath=FreeBSD+Ports+15.1.quarterly>
