OpenMPCD
|
A linear congruential generator (LCG). More...
#include <LinearCongruent.hpp>
Public Member Functions | |
OPENMPCD_CUDA_HOST_AND_DEVICE | LinearCongruent (const T seed) |
The constructor. More... | |
OPENMPCD_CUDA_HOST_AND_DEVICE T | operator() () |
Generates the next number. More... | |
A linear congruential generator (LCG).
Given a starting value \( X_0 \), which is the seed, the generator produces a sequence of numbers defined by
\[ X_{n+1} = \left( a X_N + c \right) \bmod m \]
where \( a \) is the multiplier
, \( c \) is the increment
, and \( m \) is the modulus
. The first value to be generated is \( X_1 \).
T | The underlying data type, which must be integral. |
multiplier | The multiplier \( 0 < a < m \). |
increment | The increment \( 0 \le c < m \). |
modulus | The modulus \( 0 < m \). |
Definition at line 54 of file LinearCongruent.hpp.
|
inline |
The constructor.
OpenMPCD::InvalidArgumentError | If OPENMPCD_DEBUG is defined, throws if seed >= modulus or if seed < 0 . |
[in] | seed | The starting value \( 0 \le X_0 < m \). |
Definition at line 67 of file LinearCongruent.hpp.
|
inline |
Generates the next number.
Definition at line 87 of file LinearCongruent.hpp.