Random123-1.09: Random123/gsl_microrng.h File Reference

- Random123-1.09 Documentation

Defines

# Random123/gsl_microrng.h File Reference

`#include <gsl/gsl_rng.h>`
`#include <string.h>`

Go to the source code of this file.

## Defines
#define | GSL_MICRORNG(NAME, CBRNGNAME)

## Define Documentation

#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/threefry.h>
       #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);
            threefry4x64_ctr_t c = {{}};
            threefry4x64_key_t k = {{}};

            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);
                }
            }
       }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines