From Jason Turner

[rand.eng.sub]

Diff to HTML by rtfpessoa

tmp/tmph6rlvzdm/{from.md → to.md} RENAMED
@@ -33,17 +33,17 @@ namespace std {
33
  static constexpr size_t word_size = w;
34
  static constexpr size_t short_lag = s;
35
  static constexpr size_t long_lag = r;
36
  static constexpr result_type min() { return 0; }
37
  static constexpr result_type max() { return m - 1; }
38
- static constexpr result_type default_seed = 19780503u;
39
 
40
  // constructors and seeding functions
41
- subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {}
42
  explicit subtract_with_carry_engine(result_type value);
43
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
44
- void seed(result_type value = default_seed);
45
  template<class Sseq> void seed(Sseq& q);
46
 
47
  // equality operators
48
  friend bool operator==(const subtract_with_carry_engine& x,
49
  const subtract_with_carry_engine& y);
@@ -53,14 +53,16 @@ namespace std {
53
  void discard(unsigned long long z);
54
 
55
  // inserters and extractors
56
  template<class charT, class traits>
57
  friend basic_ostream<charT, traits>&
58
- operator<<(basic_ostream<charT, traits>& os, const subtract_with_carry_engine& x);
 
59
  template<class charT, class traits>
60
  friend basic_istream<charT, traits>&
61
- operator>>(basic_istream<charT, traits>& is, subtract_with_carry_engine& x);
 
62
  };
63
  }
64
  ```
65
 
66
  The following relations shall hold: `0u < s`, `s < r`, `0 < w`, and
@@ -78,12 +80,12 @@ below. If X₋₁ is then 0, sets c to 1; otherwise sets c to 0.
78
 
79
  To set the values Xₖ, first construct `e`, a
80
  `linear_congruential_engine` object, as if by the following definition:
81
 
82
  ``` cpp
83
- linear_congruential_engine<result_type,
84
- 40014u,0u,2147483563u> e(value == 0u ? default_seed : value);
85
  ```
86
 
87
  Then, to set each Xₖ, obtain new values z₀, …, zₙ₋₁ from n = ⌈ w/32 ⌉
88
  successive invocations of `e`. Set Xₖ to
89
  $\left( \sum_{j=0}^{n-1} z_j \cdot 2^{32j}\right) \bmod m$.
 
33
  static constexpr size_t word_size = w;
34
  static constexpr size_t short_lag = s;
35
  static constexpr size_t long_lag = r;
36
  static constexpr result_type min() { return 0; }
37
  static constexpr result_type max() { return m - 1; }
38
+ static constexpr uint_least32_t default_seed = 19780503u;
39
 
40
  // constructors and seeding functions
41
+ subtract_with_carry_engine() : subtract_with_carry_engine(0u) {}
42
  explicit subtract_with_carry_engine(result_type value);
43
  template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
44
+ void seed(result_type value = 0u);
45
  template<class Sseq> void seed(Sseq& q);
46
 
47
  // equality operators
48
  friend bool operator==(const subtract_with_carry_engine& x,
49
  const subtract_with_carry_engine& y);
 
53
  void discard(unsigned long long z);
54
 
55
  // inserters and extractors
56
  template<class charT, class traits>
57
  friend basic_ostream<charT, traits>&
58
+ operator<<(basic_ostream<charT, traits>& os, // hosted
59
+ const subtract_with_carry_engine& x);
60
  template<class charT, class traits>
61
  friend basic_istream<charT, traits>&
62
+ operator>>(basic_istream<charT, traits>& is, // hosted
63
+ subtract_with_carry_engine& x);
64
  };
65
  }
66
  ```
67
 
68
  The following relations shall hold: `0u < s`, `s < r`, `0 < w`, and
 
80
 
81
  To set the values Xₖ, first construct `e`, a
82
  `linear_congruential_engine` object, as if by the following definition:
83
 
84
  ``` cpp
85
+ linear_congruential_engine<uint_least32_t, 40014u, 0u, 2147483563u> e(
86
+ value == 0u ? default_seed : static_cast<uint_least32_t>(value % 2147483563u));
87
  ```
88
 
89
  Then, to set each Xₖ, obtain new values z₀, …, zₙ₋₁ from n = ⌈ w/32 ⌉
90
  successive invocations of `e`. Set Xₖ to
91
  $\left( \sum_{j=0}^{n-1} z_j \cdot 2^{32j}\right) \bmod m$.