class
<random>
std::mt19937
typedef mersenne_twister_engine<uint_fast32_t,
32,624,397,31,0x9908b0df,11,0xffffffff,7,0x9d2c5680,15,0xefc60000,18,1812433253>
mt19937;
Mersenne Twister 19937 generator
A Mersenne Twister pseudo-random generator of 32-bit numbers with a state size of 19937 bits.
It is an instantiation of the mersenne_twister_engine with the following template parameters:
parameter | name | value |
UIntType | result type | uint_fast32_t |
w | word size | 32 |
n | state size | 624 |
m | shift size | 397 |
r | mask bits | 31 |
a | XOR mask | 0x9908b0df |
u | tempering u | 11 |
d | tempering d | 0xffffffff |
s | tempering s | 7 |
b | tempering b | 0x9d2c5680 |
t | tempering t | 15 |
c | tempering c | 0xefc60000 |
l | tempering l | 18 |
f | initialization multiplier | 1812433253 |
Member types
The following alias is a member type of mt19937:
member type | definition | notes |
result_type | uint_fast32_t | The type of the numbers generated. |
Member functions
As a mersenne_twister_engine type, it has the following member functions:
- (constructor)
- Construct mersenne twister engine (public member function)
- min
- Minimum value (public static member function)
- max
- Maximum value (public static member function)
- seed
- Seed engine (public member function)
- operator()
- Generate random number (public member function)
- discard
- Advance internal state (public member function)
Non-member functions
As a mersenne_twister_engine type, the following operator overloads may be applied to it:
- operator<<
- Insert into output stream (function template
)
- operator>>
- Extract from input stream (function template
)
- relational operators
- Relational operators (function template
)
Member constexpr constants
member constant | definition | notes |
word_size | 32 | The number of bits of each word in the state sequence. |
state_size | 624 | The number of elements in the state sequence (degree of recurrence). |
shift_size | 397 | The shift size used on twists to transform the values. |
mask_bits | 31 | The number of bits that mark the separation point of words on each twist. |
xor_mask | 0x9908b0df | The XOR mask applied as the linear function on each twist. |
tempering_u | 11 | The shift size of parameter u used in the tempering process of the generation algorithm. |
tempering_d | 0xffffffff | The XOR mask used as parameter d in the tempering process of the generation algorithm. |
tempering_s | 7 | The shift size of parameter s used in the tempering process of the generation algorithm. |
tempering_b | 0x9d2c5680 | The XOR mask used as parameter b in the tempering process of the generation algorithm. |
tempering_t | 15 | The shift size of parameter t used in the tempering process of the generation algorithm. |
tempering_c | 0xefc60000 | The XOR mask used as parameter c in the tempering process of the generation algorithm. |
tempering_l | 18 | The shift size of parameter l used in the tempering process of the generation algorithm. |
initialization_multiplier | 1812433253 | The initialization multiplier used to seed the state sequence when a single value is used as seed. |
default_seed | 5489u | The default seed used on construction or seeding. |