Random123
Macros
gsl_microrng.h File Reference
#include <gsl/gsl_rng.h>
#include <string.h>
Include dependency graph for gsl_microrng.h:

Go to the source code of this file.

Macros

#define GSL_MICRORNG(NAME, CBRNGNAME)
 

Macro Definition Documentation

◆ GSL_MICRORNG

#define GSL_MICRORNG (   NAME,
  CBRNGNAME 
)

The macro: GSL_MICRORNG(NAME, CBRNGNAME) is the GSL analog analog of the C++ r123::MicroURNG template. It declares a gsl_rng type named gsl_rng_NAME which uses the underlying CBRNGNAME and can be invoked a limited number of times between calls to NAME_reset.

When the underlying CBRNG's ctr_t is an r123arrayNxW, and the gsl_rng_NAME may called up to N*2^32 times between calls to NAME_reset.

NAME_reset takes a gsl_rng_NAME type, a counter and a key as arguments. It restarts the micro-rng with a new base counter and key.

Note that you must call NAME_reset before the first use of a gsl_rng. NAME_reset is not called automatically by gsl_rng_alloc().

#include <Random123/gsl_microrng.h> // this file
GSL_MICRORNG(microcbrng, threefry4x64, 20) // creates gsl_rng_microcbrng
int main(int argc, char** argv) {
gsl_rng *r = gsl_rng_alloc(gsl_rng_microcbrng);
for (...) {
c.v[0] = ??; // some application variable
microcbrng_reset(r, c, k);
for (...) {
// gaussian calls r several times. It is safe for
// r to be used upto 2^20 times in this loop
something[i] = gsl_ran_gaussian(r, 1.5);
}
}
}
r123array4x64::v
uint64_t v[4]
Definition: array.h:322
gsl_microrng.h
GSL_MICRORNG
#define GSL_MICRORNG(NAME, CBRNGNAME)
Definition: gsl_microrng.h:79
threefry4x64
R123_CUDA_DEVICE R123_STATIC_INLINE threefry4x64_ctr_t threefry4x64(threefry4x64_ctr_t in, threefry4x64_key_t k)
Definition: threefry.h:737
threefry.h
r123array4x64
Definition: array.h:322