OpenMPCD
Public Member Functions | List of all members
OpenMPCD::CUDA::Random::Generators::LinearCongruent< T, multiplier, increment, modulus > Class Template Reference

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_DEVICEoperator() ()
 Generates the next number. More...
 

Detailed Description

template<typename T, T multiplier, T increment, T modulus>
class OpenMPCD::CUDA::Random::Generators::LinearCongruent< T, multiplier, increment, modulus >

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 \).

Template Parameters
TThe underlying data type, which must be integral.
multiplierThe multiplier \( 0 < a < m \).
incrementThe increment \( 0 \le c < m \).
modulusThe modulus \( 0 < m \).

Definition at line 54 of file LinearCongruent.hpp.

Constructor & Destructor Documentation

◆ LinearCongruent()

template<typename T , T multiplier, T increment, T modulus>
OPENMPCD_CUDA_HOST_AND_DEVICE OpenMPCD::CUDA::Random::Generators::LinearCongruent< T, multiplier, increment, modulus >::LinearCongruent ( const T  seed)
inline

The constructor.

Exceptions
OpenMPCD::InvalidArgumentErrorIf OPENMPCD_DEBUG is defined, throws if seed >= modulus or if seed < 0.
Parameters
[in]seedThe starting value \( 0 \le X_0 < m \).

Definition at line 67 of file LinearCongruent.hpp.

Member Function Documentation

◆ operator()()

template<typename T , T multiplier, T increment, T modulus>
OPENMPCD_CUDA_HOST_AND_DEVICE T OpenMPCD::CUDA::Random::Generators::LinearCongruent< T, multiplier, increment, modulus >::operator() ( )
inline

Generates the next number.

Definition at line 87 of file LinearCongruent.hpp.


The documentation for this class was generated from the following file: