From Jason Turner

[rand.adapt]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2n3jsd9x/{from.md → to.md} +29 -17
tmp/tmp2n3jsd9x/{from.md → to.md} RENAMED
@@ -1,33 +1,33 @@
1
  ### Random number engine adaptor class templates <a id="rand.adapt">[[rand.adapt]]</a>
2
 
3
  #### In general <a id="rand.adapt.general">[[rand.adapt.general]]</a>
4
 
5
- Each type instantiated from a class template specified in this section 
6
- [[rand.adapt]] satisfies the requirements of a random number engine
7
- adaptor ([[rand.req.adapt]]) type.
8
 
9
  Except where specified otherwise, the complexity of each function
10
- specified in this section  [[rand.adapt]] is constant.
11
 
12
- Except where specified otherwise, no function described in this section 
13
- [[rand.adapt]] throws an exception.
14
 
15
- Every function described in this section  [[rand.adapt]] that has a
16
  function parameter `q` of type `Sseq&` for a template type parameter
17
  named `Sseq` that is different from type `seed_seq` throws what and when
18
  the invocation of `q.generate` throws.
19
 
20
- Descriptions are provided in this section  [[rand.adapt]] only for
21
- adaptor operations that are not described in section  [[rand.req.adapt]]
22
- or for operations where there is additional semantic information. In
23
- particular, declarations for copy constructors, for copy assignment
24
- operators, for streaming operators, and for equality and inequality
25
- operators are not shown in the synopses.
26
 
27
- Each template specified in this section  [[rand.adapt]] requires one or
28
- more relationships, involving the value(s) of its non-type template
29
  parameter(s), to hold. A program instantiating any of these templates is
30
  ill-formed if any such required relationship fails to hold.
31
 
32
  #### Class template `discard_block_engine` <a id="rand.adapt.disc">[[rand.adapt.disc]]</a>
33
 
@@ -85,11 +85,11 @@ template<class Engine, size_t p, size_t r>
85
  The following relations shall hold: `0 < r` and `r <= p`.
86
 
87
  The textual representation consists of the textual representation of `e`
88
  followed by the value of `n`.
89
 
90
- In addition to its behavior pursuant to section  [[rand.req.adapt]],
91
  each constructor that is not a copy constructor sets `n` to 0.
92
 
93
  #### Class template `independent_bits_engine` <a id="rand.adapt.ibits">[[rand.adapt.ibits]]</a>
94
 
95
  An `independent_bits_engine` random number engine adaptor combines
@@ -100,10 +100,17 @@ state eᵢ of its base engine `e`; the size of the state is the size of
100
  e’s state.
101
 
102
  The transition and generation algorithms are described in terms of the
103
  following integral constants:
104
 
 
 
 
 
 
 
 
105
  [*Note 1*: The relation w = n₀ w₀ + (n - n₀)(w₀ + 1) always
106
  holds. — *end note*]
107
 
108
  The transition algorithm is carried out by invoking `e()` as often as
109
  needed to obtain n₀ values less than y₀ + `e.min()` and n - n₀ values
@@ -175,10 +182,15 @@ additional sequence V of k values also of the type delivered by `e`. The
175
  size of the state is the size of e’s state plus k + 1.
176
 
177
  The transition algorithm permutes the values produced by e. The state
178
  transition is performed as follows:
179
 
 
 
 
 
 
180
  The generation algorithm yields the last value of `Y` produced while
181
  advancing `e`’s state as described above.
182
 
183
  ``` cpp
184
  template<class Engine, size_t k>
@@ -219,10 +231,10 @@ template<class Engine, size_t k>
219
  The following relation shall hold: `0 < k`.
220
 
221
  The textual representation consists of the textual representation of
222
  `e`, followed by the `k` values of V, followed by the value of Y.
223
 
224
- In addition to its behavior pursuant to section  [[rand.req.adapt]],
225
  each constructor that is not a copy constructor initializes
226
  `V[0]`, …, `V[k-1]` and Y, in that order, with values returned by
227
  successive invocations of `e()`.
228
 
 
1
  ### Random number engine adaptor class templates <a id="rand.adapt">[[rand.adapt]]</a>
2
 
3
  #### In general <a id="rand.adapt.general">[[rand.adapt.general]]</a>
4
 
5
+ Each type instantiated from a class template specified in this
6
+ subclause  [[rand.adapt]] meets the requirements of a random number
7
+ engine adaptor [[rand.req.adapt]] type.
8
 
9
  Except where specified otherwise, the complexity of each function
10
+ specified in this subclause  [[rand.adapt]] is constant.
11
 
12
+ Except where specified otherwise, no function described in this
13
+ subclause  [[rand.adapt]] throws an exception.
14
 
15
+ Every function described in this subclause  [[rand.adapt]] that has a
16
  function parameter `q` of type `Sseq&` for a template type parameter
17
  named `Sseq` that is different from type `seed_seq` throws what and when
18
  the invocation of `q.generate` throws.
19
 
20
+ Descriptions are provided in this subclause  [[rand.adapt]] only for
21
+ adaptor operations that are not described in subclause 
22
+ [[rand.req.adapt]] or for operations where there is additional semantic
23
+ information. In particular, declarations for copy constructors, for copy
24
+ assignment operators, for streaming operators, and for equality and
25
+ inequality operators are not shown in the synopses.
26
 
27
+ Each template specified in this subclause  [[rand.adapt]] requires one
28
+ or more relationships, involving the value(s) of its non-type template
29
  parameter(s), to hold. A program instantiating any of these templates is
30
  ill-formed if any such required relationship fails to hold.
31
 
32
  #### Class template `discard_block_engine` <a id="rand.adapt.disc">[[rand.adapt.disc]]</a>
33
 
 
85
  The following relations shall hold: `0 < r` and `r <= p`.
86
 
87
  The textual representation consists of the textual representation of `e`
88
  followed by the value of `n`.
89
 
90
+ In addition to its behavior pursuant to subclause  [[rand.req.adapt]],
91
  each constructor that is not a copy constructor sets `n` to 0.
92
 
93
  #### Class template `independent_bits_engine` <a id="rand.adapt.ibits">[[rand.adapt.ibits]]</a>
94
 
95
  An `independent_bits_engine` random number engine adaptor combines
 
100
  e’s state.
101
 
102
  The transition and generation algorithms are described in terms of the
103
  following integral constants:
104
 
105
+ - Let R = `e.max() - e.min() + 1` and m = ⌊ log₂ R ⌋.
106
+ - With n as determined below, let w₀ = ⌊ w / n ⌋, n₀ = n - w mod n,
107
+ $y_0 = 2^{w_0} \left\lfloor R / 2^{w_0} \right\rfloor$, and
108
+ $y_1 = 2^{w_0 + 1} \left\lfloor R / 2^{w_0 + 1} \right\rfloor$.
109
+ - Let n = ⌈ w / m ⌉ if and only if the relation R - y₀ ≤ ⌊ y₀ / n ⌋
110
+ holds as a result. Otherwise let n = 1 + ⌈ w / m ⌉.
111
+
112
  [*Note 1*: The relation w = n₀ w₀ + (n - n₀)(w₀ + 1) always
113
  holds. — *end note*]
114
 
115
  The transition algorithm is carried out by invoking `e()` as often as
116
  needed to obtain n₀ values less than y₀ + `e.min()` and n - n₀ values
 
182
  size of the state is the size of e’s state plus k + 1.
183
 
184
  The transition algorithm permutes the values produced by e. The state
185
  transition is performed as follows:
186
 
187
+ - Calculate an integer $j = \left\lfloor \frac{k \cdot (Y - e_{\min})}
188
+ {e_{\max} - e_{\min} +1}
189
+ \right\rfloor$ .
190
+ - Set Y to Vⱼ and then set Vⱼ to `e()`.
191
+
192
  The generation algorithm yields the last value of `Y` produced while
193
  advancing `e`’s state as described above.
194
 
195
  ``` cpp
196
  template<class Engine, size_t k>
 
231
  The following relation shall hold: `0 < k`.
232
 
233
  The textual representation consists of the textual representation of
234
  `e`, followed by the `k` values of V, followed by the value of Y.
235
 
236
+ In addition to its behavior pursuant to subclause  [[rand.req.adapt]],
237
  each constructor that is not a copy constructor initializes
238
  `V[0]`, …, `V[k-1]` and Y, in that order, with values returned by
239
  successive invocations of `e()`.
240