tmp/tmpspo8yau4/{from.md → to.md}
RENAMED
|
@@ -8,25 +8,30 @@ Except where specified otherwise, the complexity of each function
|
|
| 8 |
specified in this section [[rand.eng]] is constant.
|
| 9 |
|
| 10 |
Except where specified otherwise, no function described in this section
|
| 11 |
[[rand.eng]] throws an exception.
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
Descriptions are provided in this section [[rand.eng]] only for engine
|
| 14 |
-
operations that are not described in [[rand.req.eng]] or for
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
|
| 20 |
Each template specified in this section [[rand.eng]] requires one or
|
| 21 |
more relationships, involving the value(s) of its non-type template
|
| 22 |
parameter(s), to hold. A program instantiating any of these templates is
|
| 23 |
ill-formed if any such required relationship fails to hold.
|
| 24 |
|
| 25 |
For every random number engine and for every random number engine
|
| 26 |
-
adaptor `X` defined in this
|
| 27 |
-
|
| 28 |
|
| 29 |
- if the constructor
|
| 30 |
``` cpp
|
| 31 |
template <class Sseq> explicit X(Sseq& q);
|
| 32 |
```
|
|
@@ -55,15 +60,14 @@ algorithm is a modular linear function of the form
|
|
| 55 |
TA(xᵢ) = (a ⋅ xᵢ + c) mod m; the generation algorithm is
|
| 56 |
GA(xᵢ) = xᵢ₊₁.
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
template<class UIntType, UIntType a, UIntType c, UIntType m>
|
| 60 |
-
|
| 61 |
-
{
|
| 62 |
public:
|
| 63 |
// types
|
| 64 |
-
|
| 65 |
|
| 66 |
// engine characteristics
|
| 67 |
static constexpr result_type multiplier = a;
|
| 68 |
static constexpr result_type increment = c;
|
| 69 |
static constexpr result_type modulus = m;
|
|
@@ -83,11 +87,14 @@ public:
|
|
| 83 |
};
|
| 84 |
```
|
| 85 |
|
| 86 |
If the template parameter `m` is 0, the modulus m used throughout this
|
| 87 |
section [[rand.eng.lcong]] is `numeric_limits<result_type>::max()` plus
|
| 88 |
-
1.
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
If the template parameter `m` is not 0, the following relations shall
|
| 91 |
hold: `a < m` and `c < m`.
|
| 92 |
|
| 93 |
The textual representation consists of the value of xᵢ.
|
|
@@ -122,11 +129,11 @@ sequence X of n values of the type delivered by `x`; all subscripts
|
|
| 122 |
applied to X are to be taken modulo n.
|
| 123 |
|
| 124 |
The transition algorithm employs a twisted generalized feedback shift
|
| 125 |
register defined by shift values n and m, a twist value r, and a
|
| 126 |
conditional xor-mask a. To improve the uniformity of the result, the
|
| 127 |
-
bits of the raw shift register are additionally *tempered* (
|
| 128 |
scrambled) according to a bit-scrambling matrix defined by values
|
| 129 |
u, d, s, b, t, c, and ℓ.
|
| 130 |
|
| 131 |
The state transition is performed as follows:
|
| 132 |
|
|
@@ -139,15 +146,14 @@ z₁, z₂, z₃, z₄ as follows, then delivers z₄ as its result:
|
|
| 139 |
``` cpp
|
| 140 |
template<class UIntType, size_t w, size_t n, size_t m, size_t r,
|
| 141 |
UIntType a, size_t u, UIntType d, size_t s,
|
| 142 |
UIntType b, size_t t,
|
| 143 |
UIntType c, size_t l, UIntType f>
|
| 144 |
-
|
| 145 |
-
{
|
| 146 |
public:
|
| 147 |
// types
|
| 148 |
-
|
| 149 |
|
| 150 |
// engine characteristics
|
| 151 |
static constexpr size_t word_size = w;
|
| 152 |
static constexpr size_t state_size = n;
|
| 153 |
static constexpr size_t shift_size = m;
|
|
@@ -224,24 +230,23 @@ all subscripts applied to X are to be taken modulo r. The state xᵢ
|
|
| 224 |
additionally consists of an integer c (known as the *carry*) whose value
|
| 225 |
is either 0 or 1.
|
| 226 |
|
| 227 |
The state transition is performed as follows:
|
| 228 |
|
| 229 |
-
This algorithm corresponds to a modular linear function of
|
| 230 |
-
TA(xᵢ) = (a ⋅ xᵢ) mod b, where b is of the form mʳ - mˢ + 1
|
| 231 |
-
a = b - (b-1) / m.
|
| 232 |
|
| 233 |
The generation algorithm is given by GA(xᵢ) = y, where y is the value
|
| 234 |
produced as a result of advancing the engine’s state as described above.
|
| 235 |
|
| 236 |
``` cpp
|
| 237 |
template<class UIntType, size_t w, size_t s, size_t r>
|
| 238 |
-
|
| 239 |
-
{
|
| 240 |
public:
|
| 241 |
// types
|
| 242 |
-
|
| 243 |
|
| 244 |
// engine characteristics
|
| 245 |
static constexpr size_t word_size = w;
|
| 246 |
static constexpr size_t short_lag = s;
|
| 247 |
static constexpr size_t long_lag = r;
|
|
|
|
| 8 |
specified in this section [[rand.eng]] is constant.
|
| 9 |
|
| 10 |
Except where specified otherwise, no function described in this section
|
| 11 |
[[rand.eng]] throws an exception.
|
| 12 |
|
| 13 |
+
Every function described in this section [[rand.eng]] that has a
|
| 14 |
+
function parameter `q` of type `Sseq&` for a template type parameter
|
| 15 |
+
named `Sseq` that is different from type `seed_seq` throws what and when
|
| 16 |
+
the invocation of `q.generate` throws.
|
| 17 |
+
|
| 18 |
Descriptions are provided in this section [[rand.eng]] only for engine
|
| 19 |
+
operations that are not described in [[rand.req.eng]] or for operations
|
| 20 |
+
where there is additional semantic information. In particular,
|
| 21 |
+
declarations for copy constructors, for copy assignment operators, for
|
| 22 |
+
streaming operators, and for equality and inequality operators are not
|
| 23 |
+
shown in the synopses.
|
| 24 |
|
| 25 |
Each template specified in this section [[rand.eng]] requires one or
|
| 26 |
more relationships, involving the value(s) of its non-type template
|
| 27 |
parameter(s), to hold. A program instantiating any of these templates is
|
| 28 |
ill-formed if any such required relationship fails to hold.
|
| 29 |
|
| 30 |
For every random number engine and for every random number engine
|
| 31 |
+
adaptor `X` defined in this subclause ([[rand.eng]]) and in subclause
|
| 32 |
+
[[rand.adapt]]:
|
| 33 |
|
| 34 |
- if the constructor
|
| 35 |
``` cpp
|
| 36 |
template <class Sseq> explicit X(Sseq& q);
|
| 37 |
```
|
|
|
|
| 60 |
TA(xᵢ) = (a ⋅ xᵢ + c) mod m; the generation algorithm is
|
| 61 |
GA(xᵢ) = xᵢ₊₁.
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
template<class UIntType, UIntType a, UIntType c, UIntType m>
|
| 65 |
+
class linear_congruential_engine {
|
|
|
|
| 66 |
public:
|
| 67 |
// types
|
| 68 |
+
using result_type = UIntType;
|
| 69 |
|
| 70 |
// engine characteristics
|
| 71 |
static constexpr result_type multiplier = a;
|
| 72 |
static constexpr result_type increment = c;
|
| 73 |
static constexpr result_type modulus = m;
|
|
|
|
| 87 |
};
|
| 88 |
```
|
| 89 |
|
| 90 |
If the template parameter `m` is 0, the modulus m used throughout this
|
| 91 |
section [[rand.eng.lcong]] is `numeric_limits<result_type>::max()` plus
|
| 92 |
+
1.
|
| 93 |
+
|
| 94 |
+
[*Note 1*: m need not be representable as a value of type
|
| 95 |
+
`result_type`. — *end note*]
|
| 96 |
|
| 97 |
If the template parameter `m` is not 0, the following relations shall
|
| 98 |
hold: `a < m` and `c < m`.
|
| 99 |
|
| 100 |
The textual representation consists of the value of xᵢ.
|
|
|
|
| 129 |
applied to X are to be taken modulo n.
|
| 130 |
|
| 131 |
The transition algorithm employs a twisted generalized feedback shift
|
| 132 |
register defined by shift values n and m, a twist value r, and a
|
| 133 |
conditional xor-mask a. To improve the uniformity of the result, the
|
| 134 |
+
bits of the raw shift register are additionally *tempered* (i.e.,
|
| 135 |
scrambled) according to a bit-scrambling matrix defined by values
|
| 136 |
u, d, s, b, t, c, and ℓ.
|
| 137 |
|
| 138 |
The state transition is performed as follows:
|
| 139 |
|
|
|
|
| 146 |
``` cpp
|
| 147 |
template<class UIntType, size_t w, size_t n, size_t m, size_t r,
|
| 148 |
UIntType a, size_t u, UIntType d, size_t s,
|
| 149 |
UIntType b, size_t t,
|
| 150 |
UIntType c, size_t l, UIntType f>
|
| 151 |
+
class mersenne_twister_engine {
|
|
|
|
| 152 |
public:
|
| 153 |
// types
|
| 154 |
+
using result_type = UIntType;
|
| 155 |
|
| 156 |
// engine characteristics
|
| 157 |
static constexpr size_t word_size = w;
|
| 158 |
static constexpr size_t state_size = n;
|
| 159 |
static constexpr size_t shift_size = m;
|
|
|
|
| 230 |
additionally consists of an integer c (known as the *carry*) whose value
|
| 231 |
is either 0 or 1.
|
| 232 |
|
| 233 |
The state transition is performed as follows:
|
| 234 |
|
| 235 |
+
[*Note 1*: This algorithm corresponds to a modular linear function of
|
| 236 |
+
the form TA(xᵢ) = (a ⋅ xᵢ) mod b, where b is of the form mʳ - mˢ + 1
|
| 237 |
+
and a = b - (b-1) / m. — *end note*]
|
| 238 |
|
| 239 |
The generation algorithm is given by GA(xᵢ) = y, where y is the value
|
| 240 |
produced as a result of advancing the engine’s state as described above.
|
| 241 |
|
| 242 |
``` cpp
|
| 243 |
template<class UIntType, size_t w, size_t s, size_t r>
|
| 244 |
+
class subtract_with_carry_engine {
|
|
|
|
| 245 |
public:
|
| 246 |
// types
|
| 247 |
+
using result_type = UIntType;
|
| 248 |
|
| 249 |
// engine characteristics
|
| 250 |
static constexpr size_t word_size = w;
|
| 251 |
static constexpr size_t short_lag = s;
|
| 252 |
static constexpr size_t long_lag = r;
|