Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
|
|
Member functions | ||||
Generation | ||||
Characteristics | ||||
Non-member functions | ||||
(C++11)(C++11)(until C++20) | ||||
(C++11)(C++11) |
Defined in header <random> | ||
template< class UIntType,std::size_t w,std::size_t n,std::size_t m,std::size_t r, | (since C++11) | |
mersenne_twister_engine
is a random number engine based onMersenne Twister algorithm. It produces high quality, but not cryptographically secure, unsigned integer random numbers of typeUIntType
on the interval\(\scriptsize {[0,2^w)}\)[0, 2w
).
Contents |
UIntType | - | The result type generated by the generator. The effect is undefined if this is not one ofunsignedshort,unsignedint,unsignedlong, orunsignedlonglong. |
w | - | the power of two that determines the range of values generated by the engine |
n | - | the degree of recurrence |
m | - | the middle word, an offset used in the recurrence relation defining the state |
r | - | the number of bits of the lower bit-mask, also known as the twist value |
a | - | the conditional xor-mask, i.e. the coefficients of the rational normal form twist matrix |
u, d, s, b, t, c, l | - | the 1st to 7th components of the bit-scrambling (tempering) matrix |
f | - | the initialization multiplier |
If any of the following restrictions is violated, the program is ill-formed:
[
1,
n]
.Thesize of the states ofmersenne_twister_engine
isn, each of them consists of a sequenceX ofn values of typeresult_type
.\(\scriptsize X_j\)Xj stands for the\(\scriptsize j\mod n\)j mod nth value (starting from 0) ofX.
Given the following bitwise operation notations:
Thetransition algorithm ofmersenne_twister_engine
(\(\scriptsize TA(x_i)\)TA(xi)) is defined as follows:
Thegeneration algorithm ofmersenne_twister_engine
(\(\scriptsize GA(x_i)\)GA(xi)) is defined as follows:
The following specializations define the random number engine with two commonly used parameter sets:
Defined in header <random> | |
Type | Definition |
mt19937 (C++11) | std::mersenne_twister_engine<std::uint_fast32_t, |
mt19937_64 (C++11) | std::mersenne_twister_engine<std::uint_fast64_t, |
Type | Definition |
result_type | UIntType |
constexpr size_t word_size [static] | w (public static member constant) |
constexpr size_t state_size [static] | n (public static member constant) |
constexpr size_t shift_size [static] | m (public static member constant) |
constexpr size_t mask_bits [static] | r (public static member constant) |
constexpr UIntType xor_mask [static] | a (public static member constant) |
constexpr size_t tempering_u [static] | u (public static member constant) |
constexpr UIntType tempering_d [static] | d (public static member constant) |
constexpr size_t tempering_s [static] | s (public static member constant) |
constexpr UIntType tempering_b [static] | b (public static member constant) |
constexpr size_t tempering_t [static] | t (public static member constant) |
constexpr UIntType tempering_c [static] | c (public static member constant) |
constexpr size_t tempering_l [static] | l (public static member constant) |
constexpr UIntType initialization_multiplier [static] | f (public static member constant) |
constexpr UIntType default_seed [static] | 5489u (public static member constant) |
Construction and Seeding | |
constructs the engine (public member function)[edit] | |
sets the current state of the engine (public member function)[edit] | |
Generation | |
advances the engine's state and returns the generated value (public member function)[edit] | |
advances the engine's state by a specified amount (public member function)[edit] | |
Characteristics | |
[static] | gets the smallest possible value in the output range (public static member function)[edit] |
[static] | gets the largest possible value in the output range (public static member function)[edit] |
(C++11)(C++11)(removed in C++20) | compares the internal states of two pseudo-random number engines (function)[edit] |
(C++11) | performs stream input and output on pseudo-random number engine (function template)[edit] |
This section is incomplete Reason: no example |