From Jason Turner

[rand.eng.mers]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_uxl4jma/{from.md → to.md} +19 -5
tmp/tmp_uxl4jma/{from.md → to.md} RENAMED
@@ -1,12 +1,13 @@
1
  #### Class template `mersenne_twister_engine` <a id="rand.eng.mers">[[rand.eng.mers]]</a>
2
 
3
- A `mersenne_twister_engine` random number engine[^2] produces unsigned
4
- integer random numbers in the closed interval [0,2ʷ-1]. The state xᵢ of
5
- a `mersenne_twister_engine` object `x` is of size n and consists of a
6
- sequence X of n values of the type delivered by `x`; all subscripts
7
- applied to X are to be taken modulo n.
 
8
 
9
  The transition algorithm employs a twisted generalized feedback shift
10
  register defined by shift values n and m, a twist value r, and a
11
  conditional xor-mask a. To improve the uniformity of the result, the
12
  bits of the raw shift register are additionally *tempered* (i.e.,
@@ -30,10 +31,11 @@ z₁, z₂, z₃, z₄ as follows, then delivers z₄ as its result:
30
  - Let $z_2 = z_1 \xor \bigl( (z_1 \leftshift{w} s) \bitand b \bigr)$.
31
  - Let $z_3 = z_2 \xor \bigl( (z_2 \leftshift{w} t) \bitand c \bigr)$.
32
  - Let $z_4 = z_3 \xor ( z_3 \rightshift \ell )$.
33
 
34
  ``` cpp
 
35
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
36
  UIntType a, size_t u, UIntType d, size_t s,
37
  UIntType b, size_t t,
38
  UIntType c, size_t l, UIntType f>
39
  class mersenne_twister_engine {
@@ -64,14 +66,26 @@ template<class UIntType, size_t w, size_t n, size_t m, size_t r,
64
  explicit mersenne_twister_engine(result_type value);
65
  template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
66
  void seed(result_type value = default_seed);
67
  template<class Sseq> void seed(Sseq& q);
68
 
 
 
 
69
  // generating functions
70
  result_type operator()();
71
  void discard(unsigned long long z);
 
 
 
 
 
 
 
 
72
  };
 
73
  ```
74
 
75
  The following relations shall hold: `0 < m`, `m <= n`, `2u < w`,
76
  `r <= w`, `u <= w`, `s <= w`, `t <= w`, `l <= w`,
77
  `w <= numeric_limits<UIntType>::digits`, `a <= (1u<<w) - 1u`,
 
1
  #### Class template `mersenne_twister_engine` <a id="rand.eng.mers">[[rand.eng.mers]]</a>
2
 
3
+ A `mersenne_twister_engine` random number engine[^3]
4
+
5
+ produces unsigned integer random numbers in the closed interval
6
+ [0,2ʷ-1]. The state xᵢ of a `mersenne_twister_engine` object `x` is of
7
+ size n and consists of a sequence X of n values of the type delivered by
8
+ `x`; all subscripts applied to X are to be taken modulo n.
9
 
10
  The transition algorithm employs a twisted generalized feedback shift
11
  register defined by shift values n and m, a twist value r, and a
12
  conditional xor-mask a. To improve the uniformity of the result, the
13
  bits of the raw shift register are additionally *tempered* (i.e.,
 
31
  - Let $z_2 = z_1 \xor \bigl( (z_1 \leftshift{w} s) \bitand b \bigr)$.
32
  - Let $z_3 = z_2 \xor \bigl( (z_2 \leftshift{w} t) \bitand c \bigr)$.
33
  - Let $z_4 = z_3 \xor ( z_3 \rightshift \ell )$.
34
 
35
  ``` cpp
36
+ namespace std {
37
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
38
  UIntType a, size_t u, UIntType d, size_t s,
39
  UIntType b, size_t t,
40
  UIntType c, size_t l, UIntType f>
41
  class mersenne_twister_engine {
 
66
  explicit mersenne_twister_engine(result_type value);
67
  template<class Sseq> explicit mersenne_twister_engine(Sseq& q);
68
  void seed(result_type value = default_seed);
69
  template<class Sseq> void seed(Sseq& q);
70
 
71
+ // equality operators
72
+ friend bool operator==(const mersenne_twister_engine& x, const mersenne_twister_engine& y);
73
+
74
  // generating functions
75
  result_type operator()();
76
  void discard(unsigned long long z);
77
+
78
+ // inserters and extractors
79
+ template<class charT, class traits>
80
+ friend basic_ostream<charT, traits>&
81
+ operator<<(basic_ostream<charT, traits>& os, const mersenne_twister_engine& x);
82
+ template<class charT, class traits>
83
+ friend basic_istream<charT, traits>&
84
+ operator>>(basic_istream<charT, traits>& is, mersenne_twister_engine& x);
85
  };
86
+ }
87
  ```
88
 
89
  The following relations shall hold: `0 < m`, `m <= n`, `2u < w`,
90
  `r <= w`, `u <= w`, `s <= w`, `t <= w`, `l <= w`,
91
  `w <= numeric_limits<UIntType>::digits`, `a <= (1u<<w) - 1u`,