template<class CBRNG>
Random123 class
Random123based random number generator used polymorphically with tk::
Contents
Constructors, destructors, conversion operators
 Random123(uint64_t n = 1, uint64_t seed = 0) explicit
Public functions

void uniform(int tid,
ncomp_
t num, double* r) const 
void gaussian(int tid,
ncomp_
t num, double* r) const 
void gaussianmv(] int tid,
] ncomp_
t num, ] ncomp_t d, ] const double*const mean, ] const double*const cov, ] double* r) const  Multivariate Gaussian RNG: Generate multivariate Gaussian random numbers.

void beta(int tid,
ncomp_
t num, double p, double q, double a, double b, double* r) const 
void gamma(int tid,
ncomp_
t num, double a, double b, double* r) const  auto nthreads() const > uint64_t noexcept
 Accessor to the number of threads we operate on.
Function documentation
template<class CBRNG>
void tk::Random123<CBRNG>:: gaussian(int tid,
ncomp_t num,
double* r) const
Parameters  

tid in  Thread (or more precisely stream) ID 
num in  Number of RNGs to generate 
r in/out  Pointer to memory to write the random numbers to 
Gaussian RNG: Generate Gaussian random numbers Generating Gaussian random numbers is implemented via an adaptor, modeling std::UniformRandomNumberGenerator, outsourcing the transformation of uniform random numbers to Gaussian ones, to the standard library. The adaptor is instantiated here because a standard distribution, such as e.g., std::normal_distribution, generates numbers using operator() with no arguments, thus the RNG state and the thread ID (this latter only known here) must be stored in the adaptor functor's state. Even though creating the adaptor seems like a potentially costly operation for every call, using the standard library implementation is still faster than a handcoded implementation of the BoxMuller algorithm. Note that libc++ uses a cache, as BoxMuller, implemented using the polar algorithm generates 2 Gaussian numbers for each pair of uniform ones, caching every 2nd.
template<class CBRNG>
void tk::Random123<CBRNG>:: gaussianmv(] int tid,
] ncomp_t num,
] ncomp_t d,
] const double*const mean,
] const double*const cov,
] double* r) const
Multivariate Gaussian RNG: Generate multivariate Gaussian random numbers.
Parameters  

tid in  Thread (or more precisely stream) ID 
num in  Number of RNGs to generate 
d in  Dimension d ( d ≥ 1) of output random vectors 
mean in  Mean vector of dimension d 
cov in  Lower triangle of covariance matrix, stored as a vector of length d(d+1)/2 
r in/out  Pointer to memory to write the random numbers to 
template<class CBRNG>
void tk::Random123<CBRNG>:: beta(int tid,
ncomp_t num,
double p,
double q,
double a,
double b,
double* r) const
Parameters  

tid in  Thread (or more precisely stream) ID 
num in  Number of RNGs to generate 
p in  First beta shape parameter 
q in  Second beta shape parameter 
a in  Beta displacement parameter 
b in  Beta scale factor 
r in/out  Pointer to memory to write the random numbers to 
Beta RNG: Generate beta random numbers Generating betadistributed random numbers is implemented via an adaptor, modeling boost::UniformRandomNumberGenerator, outsourcing the transformation of uniform random numbers to betadistributed ones, to boost::random. The adaptor is instantiated here because a boost random number distribution, such as e.g., boost::random::beta_distribution, generates numbers using operator() with no arguments, thus the RNG state and the thread ID (this latter only known here) must be stored in the adaptor functor's state.
template<class CBRNG>
void tk::Random123<CBRNG>:: gamma(int tid,
ncomp_t num,
double a,
double b,
double* r) const
Parameters  

tid in  Thread (or more precisely stream) ID 
num in  Number of RNGs to generate 
a in  Gamma shape parameter 
b in  Gamma scale factor 
r in/out  Pointer to memory to write the random numbers to 
Gamma RNG: Generate gamma random numbers Generating gammadistributed random numbers is implemented via an adaptor, modeling boost::UniformRandomNumberGenerator, outsourcing the transformation of uniform random numbers to gammadistributed ones, to boost::random. The adaptor is instantiated here because a boost random number distribution, such as e.g., boost::random::gamma_distribution, generates numbers using operator() with no arguments, thus the RNG state and the thread ID (this latter only known here) must be stored in the adaptor functor's state.