Skip to content

Commit 2d211d4

Browse files
authored
Merge pull request #317 from schmouk/release-2-1-2
Release 2 1 2 --> Main
2 parents 2be13a7 + 84f6aff commit 2d211d4

File tree

1,722 files changed

+126153
-136282
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,722 files changed

+126153
-136282
lines changed

README.md

Lines changed: 591 additions & 75 deletions
Large diffs are not rendered by default.

c++11/baseclasses/basecwg.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,28 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup CWG-algorithms algos: CWG - Collatz-Weyl Generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the Collatz-Weyl
32+
* pseudorandom Generators (CWG) algorithm.
33+
*
34+
* CWG models are chaotic generators that are combined with Weyl sequences to
35+
* eliminate the risk of short cycles. They have a large period, a uniform
36+
* distribution, and the ability to generate multiple independent streams by
37+
* changing their internal parameters (Weyl increment). CWGs owe their
38+
* exceptional quality to the arithmetical dynamics of noninvertible,
39+
* generalized, Collatz mappings based on the wellknown Collatz conjecture.
40+
* There is no jump function, but each odd number of the Weyl increment
41+
* initiates a new unique period, which enables quick initialization of
42+
* independent streams (this text is extracted from [8], see README.md).
43+
*
44+
* The internal implementation of the CWG algorithm varies according to its
45+
* implemented version. See implementation classes to get their formal
46+
* description.
47+
*
48+
* @{
49+
*/
2850

2951
//===========================================================================
3052
#include <cstdint>
@@ -321,3 +343,5 @@ inline void BaseCWG<ValueType, StateValueType, OutputType, OUTPUT_BITS>::_setsta
321343
{
322344
MyBaseClass::_internal_state.state.seed(seed_);
323345
}
346+
347+
/** @}*/

c++11/baseclasses/baselfib64.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup LFib-algorithms algos: LFib - Lagged Fibonacci generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the Lagged
32+
* Fibonacci pseudorandom generators (LFib) algorithm.
33+
*
34+
* Lagged Fibonacci generators LFib( m, r, k, op) use the recurrence
35+
* @code
36+
* x(i) = (x(i-r) op (x(i-k)) mod m
37+
* @endcode
38+
* where op is an operation that can be:
39+
* @code
40+
* + (addition),
41+
* - (substraction),
42+
* * (multiplication),
43+
* ^ (bitwise exclusive-or).
44+
* @endcode
45+
*
46+
* With the + or - operation, such generators are in fact MRGs. They offer very large
47+
* periods with the best known results in the evaluation of their randomness, as
48+
* stated in the evaluation done by Pierre L'Ecuyer and Richard Simard (Universite de
49+
* Montreal) in "TestU01: A C Library for Empirical Testing of Random Number
50+
* Generators - ACM Transactions on Mathematical Software, vol.33 n.4, pp.22-40,
51+
* August 2007".
52+
*
53+
* @{
54+
*/
55+
2856

2957
//===========================================================================
3058
#include <cstdint>
@@ -363,3 +391,5 @@ inline void BaseLFib64<SIZE, K>::_setstate(const utils::UInt128& seed) noexcept
363391
{
364392
MyBaseClass::_setstate(seed);
365393
}
394+
395+
/** @}*/

c++11/baseclasses/basemelg.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup MELG-algorithms algos: MELG - Maximally Equidistributed Long-period Linear Generators
30+
*
31+
* This is the group for all the CppRandLib implementations of Maximally
32+
* Equidistributed Long-period Linear Generators (MELG) algorithm.
33+
*
34+
* Maximally Equidistributed Long-period Linear Generators (MELG) use
35+
* linear recurrence based on state transitions with double feedbacks
36+
* and linear output transformations with several memory references.
37+
*
38+
* MELGs offer large to very large periods with best known results in the
39+
* evaluation of their randomness. They ensure a maximally equidistributed
40+
* generation of pseudo random numbers. They pass all TestU01 tests and
41+
* newer ones but are the slowest to compute ones in the base of PRNGs
42+
* that have been implemented in CppRandLib.
43+
*
44+
* @{
45+
*/
46+
2847

2948
//===========================================================================
3049
#include <cstdint>
@@ -321,3 +340,5 @@ inline void BaseMELG<SIZE>::_setstate(const utils::UInt128& seed) noexcept
321340
{
322341
MyBaseClass::_setstate(seed);
323342
}
343+
344+
/** @}*/

c++11/baseclasses/basemrg31.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup MRG-algorithms algos: MRG - Multiple Recursive Generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the Multiple
32+
* Recursive pseudorandom Generators (MRG) algorithm.
33+
*
34+
* Multiple Recursive Generators (MRGs) use recurrence to evaluate pseudo-
35+
* random numbers suites. Recurrence is of the form:
36+
* @code
37+
* x(i) = A * SUM[ x(i-k) ] mod M
38+
* @endcode
39+
* for 2 to more k different values.
40+
*
41+
* MRGs offer very large periods with the best known results in the
42+
* evaluation of their randomness, as stated in the evaluation done by
43+
* by Pierre L'Ecuyer and Richard Simard (Universite de Montreal) in
44+
* "TestU01: A C Library for Empirical Testing of Random Number Generators
45+
* - ACM Transactions on Mathematical Software, vol.33 n.4, pp.22-40, August
46+
* 2007".
47+
*
48+
* @{
49+
*/
50+
2851

2952
//===========================================================================
3053
#include <cstdint>
@@ -35,7 +58,7 @@ SOFTWARE.
3558

3659

3760
//===========================================================================
38-
/** @brief The base support for 32-bits MRG Pseudo Random Number Generators.
61+
/** @brief The base support for 31-bits MRG Pseudo Random Number Generators.
3962
*
4063
* Multiple Recursive Generators (MRGs) use recurrence to evaluate pseudo-random
4164
* numbers suites. Recurrence is of the form:
@@ -324,3 +347,5 @@ inline void BaseMRG31<SIZE>::_setstate(const utils::UInt128& seed_) noexcept
324347
{
325348
MyBaseClass::_internal_state.state.seed(seed_.lo);
326349
}
350+
351+
/** @}*/

c++11/baseclasses/basemrg32.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @addtogroup MRG-algorithms
30+
*
31+
* @{
32+
*/
33+
2834

2935
//===========================================================================
3036
#include <cstdint>
@@ -324,3 +330,5 @@ inline void BaseMRG32<SIZE>::_setstate(const utils::UInt128& seed_) noexcept
324330
{
325331
MyBaseClass::_internal_state.state.seed(seed_.lo);
326332
}
333+
334+
/** @}*/

c++11/baseclasses/basepcg.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup PCG-algorithms algos: PCG - Permuted Congruential Generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the Permuted
32+
* Congruential Generator (PCG) counter-based pseudorandom algorithm.
33+
*
34+
* As LCGs do, PCG models evaluate pseudo-random numbers suites x(i) as a
35+
* simple mathematical function of x(i-1):
36+
* @code
37+
* x(i) = (a*x(i-1) + c) mod m
38+
* @endcode
39+
*
40+
* PCGs associate to this recurrence a permutation of a subpart of their
41+
* internal state bits. The output of PCGs is this permutated subpart of its
42+
* internal state, leading to a very large enhancement of the randomness of
43+
* these algorithms compared with the LCGs one.
44+
*
45+
* These PRNGs have been tested with TestU01 by the authors and have shown to
46+
* pass all tests (about TestU01, see Pierre L'Ecuyer and Richard Simard
47+
* (Universite de Montreal) in 'TestU01: A C Library for Empirical Testing of
48+
* Random Number Generators - ACM Transactions on Mathematical Software,
49+
* vol.33 n.4, pp.22-40, August 2007')
50+
*
51+
* PCGs are very fast generators, with low memory usage except for a very few
52+
* of them and medium to very large periods. They offer jump ahead and multi
53+
* streams features for most of them. They are difficult to very difficult to
54+
* invert and to predict.
55+
*
56+
* @{
57+
*/
58+
2859

2960
//===========================================================================
3061
#include "baserandom.h"
@@ -105,3 +136,5 @@ SOFTWARE.
105136
*/
106137
template<typename StateT, typename OutputT>
107138
using BasePCG = BaseRandom<StateT, OutputT, 8 * sizeof(OutputT)>;
139+
140+
/** @}*/

c++11/baseclasses/baserandom.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup BaseRandom algos: BaseRandom - Base class for all PRNGs (Pseudo Random Numbers Generators)
30+
*
31+
* This is the definition of the base class for all pseudo-random numbers generators
32+
* that are implemented in CppRandLib.
33+
*
34+
* @{
35+
*/
36+
2837

2938
//===========================================================================
3039
#include <algorithm>
@@ -124,6 +133,7 @@ SOFTWARE.
124133
*
125134
* Conforming to the former Python version of this library (i.e. PyRandLib), next methods
126135
* are available - built-in function in Python module 'random':
136+
* @code
127137
* |
128138
* | betavariate(alpha, beta)
129139
* | Beta distribution.
@@ -334,6 +344,7 @@ SOFTWARE.
334344
* | https://en.wikipedia.org/wiki/Weibull_distribution
335345
* |
336346
* | alpha is the scale parameter and beta is the shape parameter.
347+
* @endcode
337348
*/
338349
template<
339350
typename StateT,
@@ -2094,3 +2105,5 @@ const double BaseRandom<StateT, OutputT, OUTPUT_BITS>::weibullvariate(const doub
20942105

20952106
return alpha * std::pow(-std::log(1.0 - uniform()), 1.0 / beta);
20962107
}
2108+
2109+
/** @}*/

c++11/baseclasses/basesquares.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup Squares-algorithms algos: Squares - Squares counter-based pseudorandom generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the
32+
* Squares counter-based pseudorandom Generators (Squares) algorithm.
33+
*
34+
* Squares models are based on an incremented counter and a key. The
35+
* algorithm squares a combination of the counter and the key values,
36+
* and exchanges the upper and lower bits of the combination, the
37+
* whole repeated a number of times (4 to 5 rounds). Output values
38+
* are provided on 32-bits or on 64-bits according to the model.
39+
*
40+
* @{
41+
*/
42+
2843

2944
//===========================================================================
3045
#include <cstdint>
@@ -317,3 +332,5 @@ inline void BaseSquares<OutputT>::_setstate(const utils::UInt128& seed_) noexcep
317332
MyBaseClass::_internal_state.state.seed(seed_.lo);
318333
MyBaseClass::_internal_state.state.counter = 0;
319334
}
335+
336+
/** @}*/

c++11/baseclasses/basewell.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,39 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
SOFTWARE.
2626
*/
2727

28+
/**
29+
* @defgroup WELL-algorithms algos: WELL - Well-Equidistributed Long-period Linear generators
30+
*
31+
* This is the group for all the CppRandLib implementations of the Well-
32+
* Equidistributed Long-period Linear Generators pseudo-random generators (WELL)
33+
* algorithm.
34+
*
35+
* Well-Equidistributed Long-period Linear Generators (WELL) use linear recurrence
36+
* based on primitive characteristic polynomials associated with left- and right-
37+
* shifts and xor operations to fastly evaluate pseudo-random numbers suites.
38+
*
39+
* WELLs offer large to very large periods with best known results in the evaluation
40+
* of their randomness, as stated in the evaluation done by Pierre L'Ecuyer and
41+
* Richard Simard (Universite de Montreal) in "TestU01: A C Library for Empirical
42+
* Testing of Random Number Generators - ACM Transactions on Mathematical Software,
43+
* vol.33 n.4, pp.22-40, August 2007". It is recommended to use such pseudo-random
44+
* numbers generators rather than LCG ones for serious simulation applications.
45+
* Furthermore, WELLs have proven their great ability to very fastly escape from
46+
* zeroland.
47+
*
48+
* Notice: the algorithm in the 4 different versions implemented here has been coded
49+
* as a direct implementation of their descriptions in the initial paper "Improved
50+
* Long-Period Generators Based on Linear Recurrences Modulo 2", Francois PANNETON
51+
* and Pierre L'ECUYER (Universite de Montreal) and Makoto MATSUMOTO (Hiroshima
52+
* University), in ACM Transactions on Mathematical Software, Vol. 32, No. 1, March
53+
* 2006, Pages 1-16.
54+
* (see https://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf).
55+
* So, only minimalist optimization has been coded, with the aim at easing the
56+
* verification of its proper implementation.
57+
*
58+
* @{
59+
*/
60+
2861

2962
//===========================================================================
3063
#include <cstdint>
@@ -52,8 +85,8 @@ SOFTWARE.
5285
*
5386
* Notice: the algorithm in the 4 different versions implemented here has been coded
5487
* as a direct implementation of their descriptions in the initial paper "Improved
55-
* Long-Period Generators Based on Linear Recurrences Modulo 2", François PANNETON
56-
* and Pierre L'ECUYER (Université de Montréal) and Makoto MATSUMOTO (Hiroshima
88+
* Long-Period Generators Based on Linear Recurrences Modulo 2", Francois PANNETON
89+
* and Pierre L'ECUYER (Universite de Montreal) and Makoto MATSUMOTO (Hiroshima
5790
* University), in ACM Transactions on Mathematical Software, Vol. 32, No. 1, March
5891
* 2006, Pages 1-16.
5992
* (see https://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf).
@@ -493,3 +526,5 @@ inline typename BaseWell<SIZE>::value_type BaseWell<SIZE>::_tempering(
493526
value_type x_{ x ^ (((x << 7) & 0xffff'fffful) & b) };
494527
return x_ ^ (((x_ << 15) & 0xffff'fffful) & c);
495528
}
529+
530+
/** @}*/

0 commit comments

Comments
 (0)