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, | (since C++11) | |
Is a random number engine that usessubtract with carry algorithm.
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, of the state sequence |
s | - | the short lag |
r | - | the long lag |
Ifw is not in[
1,
std::numeric_limits<UIntType>::digits]
, ors is not in[
1,
r)
, the program is ill-formed.
Thesize of the states ofsubtract_with_carry_engine
is\(\scriptsize O(r)\)O(r), each of them consists of two parts:
[
0,
2
w
)
.Given that\(\scriptsize X_j\)Xj stands for the\(\scriptsize j\mod r\)j mod rth value (starting from 0) ofX, thetransition algorithm ofsubtract_with_carry_engine
(\(\scriptsize TA(x_i)\)TA(xi)) is defined as follows:
Thegeneration algorithm ofsubtract_with_carry_engine
is\(\scriptsize GA(x_i) = y\)GA(xi) = y, wherey is the value produced in step 2 of the transition algorithm.
The following specializations define the random number engine with two commonly used parameter sets:
Defined in header <random> | |
Type | Definition |
ranlux24_base (C++11) | std::subtract_with_carry_engine<std::uint_fast32_t,24,10,24>[edit] |
ranlux48_base (C++11) | std::subtract_with_carry_engine<std::uint_fast64_t,48,5,12>[edit] |
Type | Definition |
result_type | UIntType |
constexprstd::size_t word_size [static] | w (public static member constant) |
constexprstd::size_t short_lag [static] | s (public static member constant) |
constexprstd::size_t long_lag [static] | r (public static member constant) |
constexprstd::uint_least32_t default_seed [static] | 19780503u (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 |
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3809 | C++11 | default_seed might not berepresentable with result_type | changed its type to std::uint_least32_t |