| 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++26) | ||||
(C++26)(C++26) |
Defined in header <random> | ||
template< class UIntType,std::size_t w,std::size_t n,std::size_t r, | (since C++26) | |
std::philox_engine is a counter-based random number engine.
Contents |
| UIntType | - | The result type generated by the generator. The effect is undefined if this is not one ofunsignedshort,unsignedint,unsignedlong, orunsignedlonglong. |
| w | - | the word size in bits |
| n | - | the word count |
| r | - | the round count |
| consts | - | the sequence of multipliers and round constants used for generating random numbers |
If any of the following values is nottrue, the program is ill-formed:
In the following description, let\(\scriptsize Q_i \)Qi denote theith element of sequenceQ, where the subscript starts from zero.
Thesize of the states ofphilox_engine is\(\scriptsize O(n)\)O(n), each of them consists of four parts:
[0, 2w).UIntType.UIntType.Thetransition algorithm ofphilox_engine (\(\scriptsize TA(X_i) \)TA(Xi)) is defined as follows:
Thegeneration algorithm ofphilox_engine is\(\scriptsize GA(X_i)=Y_j \)GA(Xi)=Yj.
Random values are generated from the following parameters:
The sequencesM andC are formed from the values from template parameter packconsts, which represents the\(\scriptsize M_k \)Mk and\(\scriptsize C_k \)Ck constants as[\(\scriptsize M_0 \)M0, \(\scriptsize C_0 \)C0, \(\scriptsize M_1 \)M1, \(\scriptsize C_1 \)C1,... , ..., \(\scriptsize M_{n/2-1} \)Mn/2-1, \(\scriptsize C_{n/2-1} \)Cn/2-1].
Random numbers are generated by the following process:
For each round of update, an intermediate sequenceV is initialized with the elements ofS in a specified order:
| n | \(\scriptsize V_{0} \)V0 | \(\scriptsize V_{1} \)V1 | \(\scriptsize V_{2} \)V2 | \(\scriptsize V_{3} \)V3 |
|---|---|---|---|---|
| 2 | \(\scriptsize S_0 \)S0 | \(\scriptsize S_1 \)S1 | N/A | |
| 4 | \(\scriptsize S_2 \)S2 | \(\scriptsize S_1 \)S1 | \(\scriptsize S_0 \)S0 | \(\scriptsize S_3 \)S3 |
Given the following operation notations:
Letq be the current round number (starting from zero), for each integerk in[0, n/2), the elements of the output sequenceS are updated as follows:
The following specializations define the random number engine with two commonly used parameter sets:
Defined in header <random> | |
| Type | Definition |
philox4x32(C++26) | std::philox_engine<std::uint_fast32_t,32,4,10, 0xCD9E8D57,0x9E3779B9, 0xD2511F53,0xBB67AE85>[edit] |
philox4x64(C++26) | std::philox_engine<std::uint_fast64_t,64,4,10, 0xCA5A826395121157,0x9E3779B97F4A7C15, 0xD2E7470EE14C6C93,0xBB67AE8584CAA73B>[edit] |
| Type | Definition |
result_type | UIntType |
constexprstd::size_t word_size [static] | w (public static member constant) |
constexprstd::size_t word_count [static] | n (public static member constant) |
constexprstd::size_t round_count [static] | r (public static member constant) |
constexprstd::array<result_type, word_count/2> multipliers [static] | themultiplier sequenceM (public static member constant) |
constexprstd::array<result_type, word_count/2> round_consts [static] | theround constant sequenceC (public static member constant) |
constexprstd::uint_least32_t default_seed [static] | 20111115u (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] | |
| sets the current counter 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++26) | compares the internal states of two pseudo-random number engines (function)[edit] |
(C++26) | performs stream input and output on pseudo-random number engine (function template)[edit] |
| Feature-test macro | Value | Std | Feature |
|---|---|---|---|
__cpp_lib_philox_engine | 202406L | (C++26) | std::philox_engine |
| This section is incomplete Reason: no example |