From Jason Turner

[rand.eng.sub]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcalwo24u/{from.md → to.md} +11 -9
tmp/tmpcalwo24u/{from.md → to.md} RENAMED
@@ -9,10 +9,13 @@ all subscripts applied to X are to be taken modulo r. The state xᵢ
9
  additionally consists of an integer c (known as the *carry*) whose value
10
  is either 0 or 1.
11
 
12
  The state transition is performed as follows:
13
 
 
 
 
14
  [*Note 1*: This algorithm corresponds to a modular linear function of
15
  the form TA(xᵢ) = (a ⋅ xᵢ) mod b, where b is of the form mʳ - mˢ + 1
16
  and a = b - (b - 1) / m. — *end note*]
17
 
18
  The generation algorithm is given by GA(xᵢ) = y, where y is the value
@@ -32,11 +35,12 @@ template<class UIntType, size_t w, size_t s, size_t r>
32
  static constexpr result_type min() { return 0; }
33
  static constexpr result_type max() { return m - 1; }
34
  static constexpr result_type default_seed = 19780503u;
35
 
36
  // constructors and seeding functions
37
- explicit subtract_with_carry_engine(result_type value = default_seed);
 
38
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
39
  void seed(result_type value = default_seed);
40
  template<class Sseq> void seed(Sseq& q);
41
 
42
  // generating functions
@@ -50,16 +54,15 @@ The following relations shall hold: `0u < s`, `s < r`, `0 < w`, and
50
 
51
  The textual representation consists of the values of Xᵢ₋ᵣ, …, Xᵢ₋₁, in
52
  that order, followed by c.
53
 
54
  ``` cpp
55
- explicit subtract_with_carry_engine(result_type value = default_seed);
56
  ```
57
 
58
- *Effects:* Constructs a `subtract_with_carry_engine` object. Sets the
59
- values of X₋ᵣ, …, X₋, in that order, as specified below. If X₋₁ is then
60
- 0, sets c to 1; otherwise sets c to 0.
61
 
62
  To set the values Xₖ, first construct `e`, a
63
  `linear_congruential_engine` object, as if by the following definition:
64
 
65
  ``` cpp
@@ -75,12 +78,11 @@ $\left( \sum_{j=0}^{n-1} z_j \cdot 2^{32j}\right) \bmod m$.
75
 
76
  ``` cpp
77
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
78
  ```
79
 
80
- *Effects:* Constructs a `subtract_with_carry_engine` object. With
81
- k = w / 32 and a an array (or equivalent) of length r ⋅ k, invokes
82
- `q.generate(`a+0`, `a+r ⋅ k`)` and then, iteratively for i = -r, …, -1,
83
- sets Xᵢ to
84
  $\left(\sum_{j=0}^{k-1}a_{k(i+r)+j} \cdot 2^{32j} \right) \bmod m$. If
85
  X₋₁ is then 0, sets c to 1; otherwise sets c to 0.
86
 
 
9
  additionally consists of an integer c (known as the *carry*) whose value
10
  is either 0 or 1.
11
 
12
  The state transition is performed as follows:
13
 
14
+ - Let Y = Xᵢ₋ₛ - Xᵢ₋ᵣ - c.
15
+ - Set Xᵢ to y = Y mod m. Set c to 1 if Y < 0, otherwise set c to 0.
16
+
17
  [*Note 1*: This algorithm corresponds to a modular linear function of
18
  the form TA(xᵢ) = (a ⋅ xᵢ) mod b, where b is of the form mʳ - mˢ + 1
19
  and a = b - (b - 1) / m. — *end note*]
20
 
21
  The generation algorithm is given by GA(xᵢ) = y, where y is the value
 
35
  static constexpr result_type min() { return 0; }
36
  static constexpr result_type max() { return m - 1; }
37
  static constexpr result_type default_seed = 19780503u;
38
 
39
  // constructors and seeding functions
40
+ subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {}
41
+ explicit subtract_with_carry_engine(result_type value);
42
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
43
  void seed(result_type value = default_seed);
44
  template<class Sseq> void seed(Sseq& q);
45
 
46
  // generating functions
 
54
 
55
  The textual representation consists of the values of Xᵢ₋ᵣ, …, Xᵢ₋₁, in
56
  that order, followed by c.
57
 
58
  ``` cpp
59
+ explicit subtract_with_carry_engine(result_type value);
60
  ```
61
 
62
+ *Effects:* Sets the values of X₋ᵣ, …, X₋₁, in that order, as specified
63
+ below. If X₋₁ is then 0, sets c to 1; otherwise sets c to 0.
 
64
 
65
  To set the values Xₖ, first construct `e`, a
66
  `linear_congruential_engine` object, as if by the following definition:
67
 
68
  ``` cpp
 
78
 
79
  ``` cpp
80
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
81
  ```
82
 
83
+ *Effects:* With k = ⌈ w / 32 ⌉ and a an array (or equivalent) of length
84
+ r k, invokes `q.generate(`a + 0`, `a + r ⋅ k`)` and then, iteratively
85
+ for i = -r, …, -1, sets Xᵢ to
 
86
  $\left(\sum_{j=0}^{k-1}a_{k(i+r)+j} \cdot 2^{32j} \right) \bmod m$. If
87
  X₋₁ is then 0, sets c to 1; otherwise sets c to 0.
88