tmp/tmp_rhp8ak9/{from.md → to.md}
RENAMED
|
@@ -35,35 +35,35 @@ private:
|
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
seed_seq();
|
| 38 |
```
|
| 39 |
|
| 40 |
-
*
|
| 41 |
-
its member `v`.
|
| 42 |
|
| 43 |
*Throws:* Nothing.
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
template<class T>
|
| 47 |
seed_seq(initializer_list<T> il);
|
| 48 |
```
|
| 49 |
|
| 50 |
-
*
|
| 51 |
|
| 52 |
*Effects:* Same as `seed_seq(il.begin(), il.end())`.
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
template<class InputIterator>
|
| 56 |
seed_seq(InputIterator begin, InputIterator end);
|
| 57 |
```
|
| 58 |
|
| 59 |
-
*
|
| 60 |
-
iterator (Table [[tab:iterator.input.requirements]]) type. Moreover,
|
| 61 |
-
`iterator_traits<InputIterator>::value_type` shall denote an integer
|
| 62 |
type.
|
| 63 |
|
| 64 |
-
*
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
for (InputIterator s = begin; s != end; ++s)
|
| 68 |
v.push_back((*s) mod 2³²);
|
| 69 |
```
|
|
@@ -71,21 +71,63 @@ for( InputIterator s = begin; s != end; ++s)
|
|
| 71 |
``` cpp
|
| 72 |
template<class RandomAccessIterator>
|
| 73 |
void generate(RandomAccessIterator begin, RandomAccessIterator end);
|
| 74 |
```
|
| 75 |
|
| 76 |
-
*
|
| 77 |
-
mutable random access iterator ([[random.access.iterators]]). Moreover,
|
| 78 |
-
`iterator_traits<RandomAccessIterator>::value_type` shall denote an
|
| 79 |
unsigned integer type capable of accommodating 32-bit quantities.
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
*Effects:* Does nothing if `begin == end`. Otherwise, with
|
| 82 |
s = `v.size()` and n = `end` - `begin`, fills the supplied range
|
| 83 |
[`begin`,`end`) according to the following algorithm in which each
|
| 84 |
operation is to be carried out modulo 2³², each indexing operator
|
| 85 |
applied to `begin` is to be taken modulo n, and T(x) is defined as
|
| 86 |
-
$x \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
*Throws:* What and when `RandomAccessIterator` operations of `begin` and
|
| 89 |
`end` throw.
|
| 90 |
|
| 91 |
``` cpp
|
|
@@ -100,13 +142,15 @@ to `param()`.
|
|
| 100 |
``` cpp
|
| 101 |
template<class OutputIterator>
|
| 102 |
void param(OutputIterator dest) const;
|
| 103 |
```
|
| 104 |
|
| 105 |
-
*
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
|
| 109 |
*Effects:* Copies the sequence of prepared 32-bit units to the given
|
| 110 |
destination, as if by executing the following statement:
|
| 111 |
|
| 112 |
``` cpp
|
|
@@ -115,22 +159,10 @@ copy(v.begin(), v.end(), dest);
|
|
| 115 |
|
| 116 |
*Throws:* What and when `OutputIterator` operations of `dest` throw.
|
| 117 |
|
| 118 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 119 |
|
| 120 |
-
Each function instantiated from the template described in this section
|
| 121 |
-
[[rand.util.canonical]] maps the result of one or more invocations of a
|
| 122 |
-
supplied uniform random bit generator `g` to one member of the specified
|
| 123 |
-
`RealType` such that, if the values gᵢ produced by `g` are uniformly
|
| 124 |
-
distributed, the instantiation’s results tⱼ, 0 ≤ tⱼ < 1, are distributed
|
| 125 |
-
as uniformly as possible as specified below.
|
| 126 |
-
|
| 127 |
-
[*Note 1*: Obtaining a value in this way can be a useful step in the
|
| 128 |
-
process of transforming a value generated by a uniform random bit
|
| 129 |
-
generator into a value that can be delivered by a random number
|
| 130 |
-
distribution. — *end note*]
|
| 131 |
-
|
| 132 |
``` cpp
|
| 133 |
template<class RealType, size_t bits, class URBG>
|
| 134 |
RealType generate_canonical(URBG& g);
|
| 135 |
```
|
| 136 |
|
|
@@ -143,7 +175,16 @@ respectively. Calculates a quantity
|
|
| 143 |
$$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
|
| 144 |
\cdot R^i$$ using arithmetic of type `RealType`.
|
| 145 |
|
| 146 |
*Returns:* S / Rᵏ.
|
| 147 |
|
|
|
|
|
|
|
| 148 |
*Throws:* What and when `g` throws.
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
``` cpp
|
| 37 |
seed_seq();
|
| 38 |
```
|
| 39 |
|
| 40 |
+
*Ensures:* `v.empty()` is `true`.
|
|
|
|
| 41 |
|
| 42 |
*Throws:* Nothing.
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
template<class T>
|
| 46 |
seed_seq(initializer_list<T> il);
|
| 47 |
```
|
| 48 |
|
| 49 |
+
*Mandates:* `T` is an integer type.
|
| 50 |
|
| 51 |
*Effects:* Same as `seed_seq(il.begin(), il.end())`.
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
template<class InputIterator>
|
| 55 |
seed_seq(InputIterator begin, InputIterator end);
|
| 56 |
```
|
| 57 |
|
| 58 |
+
*Mandates:* `iterator_traits<InputIterator>::value_type` is an integer
|
|
|
|
|
|
|
| 59 |
type.
|
| 60 |
|
| 61 |
+
*Preconditions:* `InputIterator` meets the *Cpp17InputIterator*
|
| 62 |
+
requirements [[input.iterators]].
|
| 63 |
+
|
| 64 |
+
*Effects:* Initializes `v` by the following algorithm:
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
for (InputIterator s = begin; s != end; ++s)
|
| 68 |
v.push_back((*s) mod 2³²);
|
| 69 |
```
|
|
|
|
| 71 |
``` cpp
|
| 72 |
template<class RandomAccessIterator>
|
| 73 |
void generate(RandomAccessIterator begin, RandomAccessIterator end);
|
| 74 |
```
|
| 75 |
|
| 76 |
+
*Mandates:* `iterator_traits<RandomAccessIterator>::value_type` is an
|
|
|
|
|
|
|
| 77 |
unsigned integer type capable of accommodating 32-bit quantities.
|
| 78 |
|
| 79 |
+
*Preconditions:* `RandomAccessIterator` meets the
|
| 80 |
+
*Cpp17RandomAccessIterator* requirements [[random.access.iterators]] and
|
| 81 |
+
the requirements of a mutable iterator.
|
| 82 |
+
|
| 83 |
*Effects:* Does nothing if `begin == end`. Otherwise, with
|
| 84 |
s = `v.size()` and n = `end` - `begin`, fills the supplied range
|
| 85 |
[`begin`,`end`) according to the following algorithm in which each
|
| 86 |
operation is to be carried out modulo 2³², each indexing operator
|
| 87 |
applied to `begin` is to be taken modulo n, and T(x) is defined as
|
| 88 |
+
$x \xor (x \rightshift 27)$:
|
| 89 |
+
|
| 90 |
+
- By way of initialization, set each element of the range to the value
|
| 91 |
+
`0x8b8b8b8b`. Additionally, for use in subsequent steps, let
|
| 92 |
+
p = (n - t) / 2 and let q = p + t, where $$%
|
| 93 |
+
t = (n \ge 623) \mbox{ ? } 11 \mbox{ : } (n \ge 68) \mbox{ ? } 7 \mbox{ : } (n \ge 39) \mbox{ ? } 5 \mbox{ : } (n \ge 7) \mbox{ ? } 3 \mbox{ : } (n - 1)/2;$$
|
| 94 |
+
- With m as the larger of s + 1 and n, transform the elements of the
|
| 95 |
+
range: iteratively for k = 0, …, m - 1, calculate values
|
| 96 |
+
$$\begin{aligned}
|
| 97 |
+
r_1 & = &
|
| 98 |
+
1664525 \cdot T( \texttt{begin[}k\texttt{]}
|
| 99 |
+
\xor \texttt{begin[}k+p\texttt{]}
|
| 100 |
+
\xor \texttt{begin[}k-1 \texttt{]}
|
| 101 |
+
)
|
| 102 |
+
\\
|
| 103 |
+
r_2 & = & r_1 + \left\{
|
| 104 |
+
\begin{array}{cl}
|
| 105 |
+
s & \mbox{, } k = 0
|
| 106 |
+
\\
|
| 107 |
+
k \bmod n + \texttt{v[}k-1\texttt{]} & \mbox{, } 0 < k \le s
|
| 108 |
+
\\
|
| 109 |
+
k \bmod n & \mbox{, } s < k
|
| 110 |
+
\end{array}
|
| 111 |
+
\right.
|
| 112 |
+
|
| 113 |
+
\end{aligned}$$ and, in order, increment `begin[`k+p`]` by r₁,
|
| 114 |
+
increment `begin[`k+q`]` by r₂, and set `begin[`k`]` to r₂.
|
| 115 |
+
- Transform the elements of the range again, beginning where the
|
| 116 |
+
previous step ended: iteratively for k = m, …, m + n - 1, calculate
|
| 117 |
+
values $$\begin{aligned}
|
| 118 |
+
r_3 & = &
|
| 119 |
+
1566083941 \cdot T( \texttt{begin[}k \texttt{]}
|
| 120 |
+
+ \texttt{begin[}k+p\texttt{]}
|
| 121 |
+
+ \texttt{begin[}k-1\texttt{]}
|
| 122 |
+
)
|
| 123 |
+
\\
|
| 124 |
+
r_4 & = & r_3 - (k \bmod n)
|
| 125 |
+
|
| 126 |
+
\end{aligned}$$ and, in order, update `begin[`k+p`]` by xoring it with
|
| 127 |
+
r₃, update `begin[`k+q`]` by xoring it with r₄, and set `begin[`k`]`
|
| 128 |
+
to r₄.
|
| 129 |
|
| 130 |
*Throws:* What and when `RandomAccessIterator` operations of `begin` and
|
| 131 |
`end` throw.
|
| 132 |
|
| 133 |
``` cpp
|
|
|
|
| 142 |
``` cpp
|
| 143 |
template<class OutputIterator>
|
| 144 |
void param(OutputIterator dest) const;
|
| 145 |
```
|
| 146 |
|
| 147 |
+
*Mandates:* Values of type `result_type` are
|
| 148 |
+
writable [[iterator.requirements.general]] to `dest`.
|
| 149 |
+
|
| 150 |
+
*Preconditions:* `OutputIterator` meets the *Cpp17OutputIterator*
|
| 151 |
+
requirements [[output.iterators]].
|
| 152 |
|
| 153 |
*Effects:* Copies the sequence of prepared 32-bit units to the given
|
| 154 |
destination, as if by executing the following statement:
|
| 155 |
|
| 156 |
``` cpp
|
|
|
|
| 159 |
|
| 160 |
*Throws:* What and when `OutputIterator` operations of `dest` throw.
|
| 161 |
|
| 162 |
#### Function template `generate_canonical` <a id="rand.util.canonical">[[rand.util.canonical]]</a>
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
``` cpp
|
| 165 |
template<class RealType, size_t bits, class URBG>
|
| 166 |
RealType generate_canonical(URBG& g);
|
| 167 |
```
|
| 168 |
|
|
|
|
| 175 |
$$S = \sum_{i=0}^{k-1} (g_i - \texttt{g.min()})
|
| 176 |
\cdot R^i$$ using arithmetic of type `RealType`.
|
| 177 |
|
| 178 |
*Returns:* S / Rᵏ.
|
| 179 |
|
| 180 |
+
[*Note 1*: 0 ≤ S / Rᵏ < 1. — *end note*]
|
| 181 |
+
|
| 182 |
*Throws:* What and when `g` throws.
|
| 183 |
|
| 184 |
+
[*Note 2*: If the values gᵢ produced by `g` are uniformly distributed,
|
| 185 |
+
the instantiation’s results are distributed as uniformly as possible.
|
| 186 |
+
Obtaining a value in this way can be a useful step in the process of
|
| 187 |
+
transforming a value generated by a uniform random bit generator into a
|
| 188 |
+
value that can be delivered by a random number
|
| 189 |
+
distribution. — *end note*]
|
| 190 |
+
|