Skip to content

Commit 73a61fe

Browse files
committed
2 parents c05f886 + 037467d commit 73a61fe

31 files changed

+324
-216
lines changed

README.md

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Notice: a comparison of the computation times for all implemented PRNGs in **Cpp
116116
<td>Cwg64</td>
117117
<td>*CWG64*</td>
118118
<td>8 x 4-bytes</td>
119-
<td>&gt;= 2^70</td>
119+
<td>&gt;= 2^64</td>
120120
<td>0</td>
121121
<td>0</td>
122122
<td>0</td>
@@ -127,7 +127,7 @@ Notice: a comparison of the computation times for all implemented PRNGs in **Cpp
127127
<td>Cwg128_64</td>
128128
<td>*CWG128-64*</td>
129129
<td>10 x 4-bytes</td>
130-
<td>&gt;= 2^71</td>
130+
<td>&gt;= 2^64</td>
131131
<td>0</td>
132132
<td>0</td>
133133
<td>0</td>
@@ -138,7 +138,7 @@ Notice: a comparison of the computation times for all implemented PRNGs in **Cpp
138138
<td>Cwg128</td>
139139
<td>*CWG128*</td>
140140
<td>16 x 4-bytes</td>
141-
<td>&gt;= 2^135</td>
141+
<td>&gt;= 2^128</td>
142142
<td>0</td>
143143
<td>0</td>
144144
<td>0</td>
@@ -845,9 +845,9 @@ Since version **2.0** of **CppRandLib** also, the newly implemented method `getr
845845

846846

847847
---
848-
### Cwg64 -- minimum 2^70 period
848+
### Cwg64 -- minimum 2^64 period
849849

850-
**Cwg64** implements the full 64 bits version of the Collatz-Weyl Generator algorithm: computations are done on 64-bits, the output generated value is coded on 64-bits also. It provides a medium period which is at minimum 2^70 (i.e. about 1.18e+21), short computation time and a four 64-bits integers internal state (x, a, weyl, s).
850+
**Cwg64** implements the full 64 bits version of the Collatz-Weyl Generator algorithm: computations are done on 64-bits, the output generated value is coded on 64-bits also. It provides a medium period which is at minimum 2^64 (i.e. about 1.84e+19), short computation time and a four 64-bits integers internal state (x, a, weyl, s).
851851

852852
This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as the combination of the next instructions applied to *state(i-1)*:
853853

@@ -858,21 +858,9 @@ This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as
858858

859859

860860

861-
### Cwg64 -- minimum 2^70 period
861+
### Cwg128_64 -- minimum 2^64 period
862862

863-
**Cwg64** implements the full 64 bits version of the Collatz-Weyl Generator algorithm: computations are done on 64-bits. The output generated value is coded on 64-bits also. It provides a medium period which is at minimum 2^70 (i.e. about 1.18e+21), short computation time and a four 64-bits integers internal state (x, a, weyl, s).
864-
865-
This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as the combination of the next instructions applied to *state(i-1)*:
866-
867-
a(i) = a(i-1) + x(i-1)
868-
weyl(i) = weyl(i-1) + s // s is constant over time and must be odd, this is the value to modify to get multi-streams
869-
x(i) = ((x(i-1) >> 1) * ((a(i)) | 1)) ^ (weyl(i)))
870-
output(i) = (a(i) >> 48) ^ x(i)
871-
872-
873-
### Cwg128_64 -- minimum 2^71 period
874-
875-
**Cwg128_64** implements the mixed 128/64 bits version of the Collatz-Weyl Generator algorithm: computations are done on 128- and 64- bits. The output generated value is coded on 64-bits also. It provides a medium period which is at minimum 2^71 (i.e. about 2.36e+21), short computation time and a three 64-bits (a, weyl, s) plus one 128-bits integer internal state (x).
863+
**Cwg128_64** implements the mixed 128/64 bits version of the Collatz-Weyl Generator algorithm: computations are done on 128- and 64- bits. The output generated value is coded on 64-bits also. It provides a medium period which is at minimum 2^64 (i.e. about 1.84e+19), short computation time and a three 64-bits (a, weyl, s) plus one 128-bits integer internal state (x).
876864

877865
This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as the combination of the next instructions applied to *state(i-1)*:
878866

@@ -883,9 +871,9 @@ This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as
883871

884872

885873

886-
### Cwg128 -- minimum 2^135 period
874+
### Cwg128 -- minimum 2^128 period
887875

888-
**Cwg128** implements the full 128 bits version of the Collatz-Weyl Generator algorithm: computations are done on 128-bits. The output generated value is coded on 128-bits also. It provides a medium period which is at minimum 2^135 (i.e. about 4.36e+40), short computation time and a four 128-bits integers internal state (x, a, weyl, s).
876+
**Cwg128** implements the full 128 bits version of the Collatz-Weyl Generator algorithm: computations are done on 128-bits. The output generated value is coded on 128-bits also. It provides a medium period which is at minimum 2^128 (i.e. about 6.81e+38), short computation time and a four 128-bits integers internal state (x, a, weyl, s).
889877

890878
This version of the CGW algorithm evaluates pseudo-random suites *output(i)* as the combination of the next instructions applied to *state(i-1)*:
891879

c++11/baseclasses/basecwg.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ SOFTWARE.
7373
* implemented version. See implementation classes to get their formal
7474
* description.
7575
*
76-
* See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period CW-Generator
76+
* See Cwg64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
7777
* with low computation time, medium period, 64- bits output values and very
7878
* good randomness characteristics.
7979
*
80-
* See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period CW-Generator
80+
* See Cwg128_64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
8181
* with very low computation time, medium period, 64-bits output values and
8282
* very good randomness characteristics.
8383
*
84-
* See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period CW-generator
84+
* See Cwg128 for a minimum 2^128 (i.e. about 6.81e+38) period CW-generator
8585
* with very low computation time, medium period, 128-bits output values and
8686
* very good randomness characteristics.
8787
*
@@ -107,9 +107,9 @@ SOFTWARE.
107107
* +------------------------------------------------------------------------------------------------------------------------------------------------+
108108
* | CppRandLib class | [8] generator name | Memory Usage | Period | time-32bits | time-64 bits | SmallCrush fails | Crush fails | BigCrush fails |
109109
* | ---------------- | ------------------ | ------------ | -------- | ----------- | ------------ | ---------------- | ----------- | -------------- |
110-
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^70 | n.a. | n.a. | 0 | 0 | 0 |
111-
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^71 | n.a. | n.a. | 0 | 0 | 0 |
112-
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^135 | n.a. | n.a. | 0 | 0 | 0 |
110+
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
111+
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
112+
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^128 | n.a. | n.a. | 0 | 0 | 0 |
113113
* +------------------------------------------------------------------------------------------------------------------------------------------------+
114114
*
115115
* * _small crush_ is a small set of simple tests that quickly tests some of

c++11/baseclasses/baserandom.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ SOFTWARE.
5252
//===========================================================================
5353
/** @brief This is the base class for all pseudo-random numbers generators.
5454
*
55-
* See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period Collatz-Weyl Generator
55+
* See Cwg64 for a minimum 2^64 (i.e. about 1.84e+19) period Collatz-Weyl Generator
5656
* with low computation time, medium period, 64- bits output values and very good
5757
* randomness characteristics.
58-
* See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period C-W Generator with
58+
* See Cwg128_64 for a minimum 2^64 (i.e. about 1.84e+19) period C-W Generator with
5959
* with very low computation time, medium period, 64-bits output values and very
6060
* good randomness characteristics.
61-
* See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period C-W generator with
61+
* See Cwg128 for a minimum 2^128 (i.e. about 6.81e+38) period C-W generator with
6262
* very low computation time, medium period, 64- bits output values and very good
6363
* randomness characteristics.
6464
*

c++11/cwg128.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ SOFTWARE.
4040

4141

4242
//===========================================================================
43-
/** @brief A 128-bits Collatz-Weyl pseudorandom Generator with a short period (4.36e+40).
43+
/** @brief A 128-bits Collatz-Weyl pseudorandom Generator with a short period (6.81e+38).
4444
*
4545
* Pseudo-random numbers generator - Collatz-Weyl pseudorandom Generators
4646
* dedicated to 128-bits calculations and 128-bits output values with large
47-
* period (min 2^135, i.e. 4.36e+40) but short computation time. All CWG
47+
* period (min 2^128, i.e. 6.81e+38) but short computation time. All CWG
4848
* algorithms offer multi streams features, by simply using different initial
4949
* settings for control value 's' - see below.
5050
*
@@ -59,11 +59,11 @@ SOFTWARE.
5959
* PRNG. 's' must be initally odd. 'a', 'weyl' and initial state 'x' may be
6060
* initialized each with any 64-bits value.
6161
*
62-
* See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period CW-Generator
62+
* See Cwg64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
6363
* with very low computation time, medium period, 64- bits output values and
6464
* very good randomness characteristics.
6565
*
66-
* See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period CW-Generator
66+
* See Cwg128_64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
6767
* with very low computation time, medium period, 64-bits output values and
6868
* very good randomness characteristics.
6969
*
@@ -89,9 +89,9 @@ SOFTWARE.
8989
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9090
* | CppRandLib class | [8] generator name | Memory Usage | Period | time-32bits | time-64 bits | SmallCrush fails | Crush fails | BigCrush fails |
9191
* | ---------------- | ------------------ | ------------ | -------- | ----------- | ------------ | ---------------- | ----------- | -------------- |
92-
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^70 | n.a. | n.a. | 0 | 0 | 0 |
93-
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^71 | n.a. | n.a. | 0 | 0 | 0 |
94-
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^135 | n.a. | n.a. | 0 | 0 | 0 |
92+
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
93+
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
94+
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^128 | n.a. | n.a. | 0 | 0 | 0 |
9595
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9696
*
9797
* * _small crush_ is a small set of simple tests that quickly tests some of

c++11/cwg128_64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const Cwg128_64::output_type Cwg128_64::next() noexcept
9999
_internal_state.state.state = ((_internal_state.state.state | 1) * (_internal_state.state.a >> 1)) ^ _internal_state.state.weyl;
100100

101101
// returns the xored - shifted output value
102-
return (_internal_state.state.state ^ (_internal_state.state.a >> 48)).lo;
102+
return _internal_state.state.state ^ (_internal_state.state.a >> 48);
103103
}
104104

105105
//---------------------------------------------------------------------------

c++11/cwg128_64.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ SOFTWARE.
4040

4141

4242
//===========================================================================
43-
/** @brief A 128-/64- bits Collatz-Weyl pseudorandom Generator with a short period (1.18e+21).
43+
/** @brief A 128-/64- bits Collatz-Weyl pseudorandom Generator with a short period (1.84e+19).
4444
*
4545
* Pseudo-random numbers generator - Collatz-Weyl pseudorandom Generator
4646
* dedicated to 128-bits calculations and 64-bits output values with small
47-
* period (min 2^71, i.e. 2.36e+21) but short computation time. All CWG
47+
* period (min 2^64, i.e. 1.84e+19) but short computation time. All CWG
4848
* algorithms offer multi streams features, by simply using different initial
4949
* settings for control value 's' - see below.
5050
*
@@ -59,11 +59,11 @@ SOFTWARE.
5959
* PRNG. 's' must be initally odd. 'a', 'weyl' and initial state 'x' may be
6060
* initialized each with any 64-bits value.
6161
*
62-
* See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period CW-Generator
62+
* See Cwg64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
6363
* with very low computation time, medium period, 64- bits output values and
6464
* very good randomness characteristics.
6565
*
66-
* See Cwg128_64 for a minimum 2^135 (i.e. about 4.36e+40) period CW-generator
66+
* See Cwg128_64 for a minimum 2^128 (i.e. about 6.81e+38) period CW-generator
6767
* with very low computation time, medium period, 128-bits output values and
6868
* very good randomness characteristics.
6969
*
@@ -89,9 +89,9 @@ SOFTWARE.
8989
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9090
* | CppRandLib class | [8] generator name | Memory Usage | Period | time-32bits | time-64 bits | SmallCrush fails | Crush fails | BigCrush fails |
9191
* | ---------------- | ------------------ | ------------ | -------- | ----------- | ------------ | ---------------- | ----------- | -------------- |
92-
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^70 | n.a. | n.a. | 0 | 0 | 0 |
93-
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^71 | n.a. | n.a. | 0 | 0 | 0 |
94-
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^135 | n.a. | n.a. | 0 | 0 | 0 |
92+
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
93+
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
94+
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^128 | n.a. | n.a. | 0 | 0 | 0 |
9595
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9696
*
9797
* * _small crush_ is a small set of simple tests that quickly tests some of
@@ -103,11 +103,11 @@ SOFTWARE.
103103
* * _big crush_ is the ultimate set of difficult tests that any GOOD PRNG
104104
* should definitively pass.
105105
*/
106-
class Cwg128_64 : public BaseCWG<std::uint64_t, utils::UInt128, std::uint64_t, 64>
106+
class Cwg128_64 : public BaseCWG<std::uint64_t, utils::UInt128, utils::UInt128, 128>
107107
{
108108
public:
109109
//--- Wrappers ------------------------------------------------------
110-
using MyBaseClass = BaseCWG<std::uint64_t, utils::UInt128, std::uint64_t, 64>;
110+
using MyBaseClass = BaseCWG<std::uint64_t, utils::UInt128, utils::UInt128, 128>;
111111

112112
using output_type = typename MyBaseClass::output_type;
113113
using state_type = typename MyBaseClass::state_type;

c++11/cwg64.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ SOFTWARE.
4040

4141

4242
//===========================================================================
43-
/** @brief A 64-bits Collatz-Weyl pseudorandom Generator with a long period (1.18e+21).
43+
/** @brief A 64-bits Collatz-Weyl pseudorandom Generator with a long period (1.84e+19).
4444
*
4545
* Pseudo-random numbers generator - Collatz-Weyl pseudorandom Generator
4646
* dedicated to 64-bits calculations and 64-bits output values with small
47-
* period (min 2^70, i.e. 1.18e+21) but short computation time. All CWG
47+
* period (min 2^64, i.e. 1.84e+19) but short computation time. All CWG
4848
* algorithms offer multi streams features, by simply using different initial
4949
* settings for control value 's' - see below.
5050
*
@@ -59,11 +59,11 @@ SOFTWARE.
5959
* PRNG. 's' must be initally odd. 'a', 'weyl' and initial state 'x' may be
6060
* initialized each with any 64-bits value.
6161
*
62-
* See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period CW-Generator
62+
* See Cwg128_64 for a minimum 2^64 (i.e. about 1.84e+19) period CW-Generator
6363
* with very low computation time, medium period, 64-bits output values and
6464
* very good randomness characteristics.
6565
*
66-
* See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period CW-generator
66+
* See Cwg128 for a minimum 2^128 (i.e. about 6.81e+38) period CW-generator
6767
* with very low computation time, medium period, 128-bits output values and
6868
* very good randomness characteristics.
6969
*
@@ -89,9 +89,9 @@ SOFTWARE.
8989
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9090
* | CppRandLib class | [8] generator name | Memory Usage | Period | time-32bits | time-64 bits | SmallCrush fails | Crush fails | BigCrush fails |
9191
* | ---------------- | ------------------ | ------------ | -------- | ----------- | ------------ | ---------------- | ----------- | -------------- |
92-
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^70 | n.a. | n.a. | 0 | 0 | 0 |
93-
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^71 | n.a. | n.a. | 0 | 0 | 0 |
94-
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^135 | n.a. | n.a. | 0 | 0 | 0 |
92+
* | Cwg64 | CWG64 | 8 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
93+
* | Cwg128_64 | CWG128_64 | 10 x 4-bytes | >= 2^64 | n.a. | n.a. | 0 | 0 | 0 |
94+
* | Cwg128 | CWG128 | 16 x 4-bytes | >= 2^128 | n.a. | n.a. | 0 | 0 | 0 |
9595
* +------------------------------------------------------------------------------------------------------------------------------------------------+
9696
*
9797
* * _small crush_ is a small set of simple tests that quickly tests some of

0 commit comments

Comments
 (0)