@@ -43,28 +43,70 @@ SOFTWARE.
4343// ===========================================================================
4444/* * @brief This is the base class for all pseudo-random numbers generators.
4545*
46- * See FastRand32 for a 2^32 (i.e. 4.3e+9) period LC-Generator and FastRand63 for a
47- * 2^63 (i.e. about 9.2e+18) period LC-Generator with low computation time.
46+ * See Cwg64 for a minimum 2^70 (i.e. about 1.18e+21) period Collatz-Weyl Generator
47+ * with low computation time, medium period, 64- bits output values and very good
48+ * randomness characteristics.
49+ * See Cwg128_64 for a minimum 2^71 (i.e. about 2.36e+21) period C-W Generator with
50+ * with very low computation time, medium period, 64-bits output values and very
51+ * good randomness characteristics.
52+ * See Cwg128 for a minimum 2^135 (i.e. about 4.36e+40) period C-W generator with
53+ * very low computation time, medium period, 64- bits output values and very good
54+ * randomness characteristics.
4855*
49- * See FastRand63 for a 2^63 (i.e. about 9.2e+18) period LC- Generator with low
50- * computation time also, longer period and quite better randomness characteristics
51- * than for FastRand32 .
56+ * See FastRand32 for a 2^32 (i.e. 4.29e+9) period Linear Congruential Generator and
57+ * FastRand63 for a 2^63 (i.e. about 9.2e+18) period LC-Generator with very low
58+ * computation time and very low memory consumption (resp. 1 and 2 32-bits integers) .
5259*
53- * See MRGRand287, MRGRand1457 and MRGRand49507 for long periods MR-Generators (resp.
54- * 2^287, 2^1,457 and 2^49,507, i.e. 2.49e+86, 4.0e+438 and 1.2e+14,903) with low
55- * computation time but resp. 256, 47 and 1,597 integers memory consumption. Output
56- * values are coded on resp. 32-, 31- and 31- bits.
60+ * See LFibRand78, LFibRand116, LFibRand668 and LFibRand1340 for large period Lagged
61+ * Fibonacci Generators (resp. 2^78, 2^116, 2^668 and 2^1340 periods, i.e. resp.
62+ * 3.0e+23, 8.3e+34, 1.2e+201 and 2.4e+403 periods) while same computation time and
63+ * far higher precision (64-bits calculations) but memory consumption (resp. 17, 55,
64+ * 607 and 1279 32-bits integers).
5765*
58- * See LFibRand78, LFibRand116, LFibRand668 and LFibRand1340 for long period LFib
59- * generators (resp. 2^78, 2^116, 2^668 and 2^1340 periods, i.e. resp. 3.0e+23,
60- * 8.3e+34, 1.2e+201 and 2.4e+403 periods) while same computation time and far higher
61- * precision (64-bits calculations) but memory consumption (resp. 17, 55, 607 and
62- * 1279 integers).
63- *
64- * See Xoroshiro256, Xoroshiro512, Xoroshiro1024 for long period generators (resp.
65- * 2^256, 2^512 and 2^1024 periods, i.e. resp. 1.16e+77, 1.34e+154 and 1.80e+308
66- * periods), 64-bits precision calculations and short memory consumption (resp. 4,
67- * 8 and 16 integers coded on 64 bits).
66+ * See Melg607 for a large period Maximally Equidistributed F2-Linear Generator
67+ * (2^607, i.e. 5.31e+182) with medium computation time and the equivalent of 21 32-
68+ * bits integers memory little consumption.
69+ * See Melg19937 for alarger period MELG-Generator (2^19,937, i.e. 4.32e+6001), same
70+ * computation time and equivalent of 625 integers memory consumption.
71+ * See Melg44497 for a very large period (2^44,497, i.e. 8.55e+13,395) with similar
72+ * computation time but use of even more memory space (equivalent of 1,393 32-bits
73+ * integers). This is the longest period version proposed in paper [11].
74+ *
75+ * See Mrg287 for a short period Multiple Recursive Generator (2^287, i.e. 2.49e+86)
76+ * with low computation time but 256 32-bits integers memory consumption.
77+ * See Mrg1457 for a longer period MR-Generator (2^1457, i.e. 4.0e+438) and longer
78+ * computation time (2^31-1 modulus calculations) but less memory space consumption
79+ * (32-bits 47 integers).
80+ * See Mrg49507 for a far larger period MR-Generator (2^49507, i.e. 1.2e+14903) with
81+ * low computation time too (31-bits modulus) but use of more memory space (1597
82+ * 32-bits integers).
83+ *
84+ * See Pcg64_32, Pcg128_64 and Pcg1024_32 for Permuted Congruential Generators with
85+ * medium to very large periods, very low computation time, and for very low memory
86+ * consumption for the two first (resp. 4, 8 and 1,026 times 32-bits). Associated
87+ * periods are resp. 2^64, 2^128 and 2^32830, i.e. 1.84e+19, 3.40e+38 and 6.53e+9882.
88+ * These PRNGs provide multi-streams and jump ahead features. Since they all are
89+ * exposing only a part of their internal state, they are difficult to reverse and
90+ * to predict.
91+ *
92+ * See Squares32 for a counter-based middle-square random number generator with 2^64
93+ * (i.e. about 1.84e+19) period, low computation time, 32-bits output values and very
94+ * good randomness characteristics.
95+ * See Squares64 for a 2^64 (i.e. about 1.84e+19) period PRNG with low computation
96+ * time, medium period, 64-bits output values and very good randomness
97+ * characteristics. Caution: this 64-bits version should not pass the birthday test,
98+ * which is a randomness issue, while this is not mentionned in the original paper.
99+ *
100+ * See Well512a, Well1024a, Well19937c and Well44479b for large to very large period
101+ * generators (resp. 2^512, 2^1024, 2^19937 and 2^44479 periods, i.e. resp. 1.34e+154,
102+ * 2.68e+308, 4.32e+6001 and 1.51e+13466 periods), a little bit longer computation
103+ * times but very quick escaping from zeroland. Memory consumption is resp. 32, 64,
104+ * 624 and 1391 32-bits integers.
105+ *
106+ * See Xoroshiro256, Xoroshiro512, Xoroshiro1024 for long period generators (resp.
107+ * 2^256, 2^512 and 2^1024 periods, i.e. resp. 1.16e+77, 1.34e+154 and 1.80e+308
108+ * periods), 64-bits precision calculations and short memory consumption (resp. 4,
109+ * 8 and 16 integers each coded on 64 bits.
68110*
69111* Furthermore this class and all its inheriting sub-classes are callable. Example:
70112* @code
@@ -80,7 +122,7 @@ SOFTWARE.
80122* std::cout << diceRoll.randint(1, 6) << std::endl; // prints also a uniform roll within range {1, ..., 6}
81123* @endcode
82124*
83- * Conforming to the former Python version of this library (CppRandLib ), next methods
125+ * Conforming to the former Python version of this library (i.e. PyRandLib ), next methods
84126* are available - built-in function in Python module 'random':
85127* |
86128* | betavariate(alpha, beta)
@@ -668,7 +710,6 @@ class BaseRandom
668710 inline void setstate (const StateT& new_internal_state, const double gauss_next) noexcept ;
669711
670712
671-
672713 /* * @brief Returns the current internal state value. */
673714 inline const state_type state () const noexcept ;
674715
@@ -1661,10 +1702,10 @@ inline void BaseRandom<StateT, OutputT, OUTPUT_BITS>::seed(const utils::UInt128&
16611702template <typename StateT, typename OutputT, const std::uint8_t OUTPUT_BITS>
16621703inline void BaseRandom<StateT, OutputT, OUTPUT_BITS>::seed(const double seed_)
16631704{
1664- if (seed_ < 0.0 || 1.0 <= seed_)
1705+ if (0.0 <= seed_ && seed_ <= 1.0 )
1706+ seed (std::uint64_t (seed_ * double (0xffff'ffff'ffff'ffffULL )));
1707+ else
16651708 throw FloatValueRange01Exception ();
1666-
1667- seed (std::uint64_t (seed_ * double (0xffff'ffff'ffff'ffffULL )));
16681709}
16691710
16701711// ---------------------------------------------------------------------------
@@ -1743,7 +1784,7 @@ const double BaseRandom<StateT, OutputT, OUTPUT_BITS>::expovariate(const double
17431784 throw ExponentialZeroLambdaException ();
17441785
17451786 const double u{ uniform () };
1746- if (u < 1.0 ) // should always happen, let's check for it nevertheless
1787+ if (u < 1.0 ) // should always happen, let's check it nevertheless
17471788 return -std::log (1.0 - u) / lambda;
17481789 else
17491790 return 0.0 ;
0 commit comments