Loading...
Searching...
No Matches
Go to the documentation of this file.
32#ifndef __r123_gslmicrorng_dot_h__
33#define __r123_gslmicrorng_dot_h__
35#include <gsl/gsl_rng.h>
78#define GSL_MICRORNG(NAME, CBRNGNAME) \
79 gsl_rng_type const* gsl_rng_##NAME; \
82 CBRNGNAME##_ctr_t ctr; \
83 CBRNGNAME##_ctr_t r; \
84 CBRNGNAME##_key_t key; \
89 static unsigned long int NAME##_get(void* vstate) { \
90 NAME##_state* st = (NAME##_state*)vstate; \
91 int const N = sizeof(st->ctr.v) / sizeof(st->ctr.v[0]); \
93 CBRNGNAME##_ctr_t c = st->ctr; \
94 c.v[N - 1] |= st->n << (R123_W(CBRNGNAME##_ctr_t) - 32); \
96 st->r = CBRNGNAME(c, st->key); \
99 return 0xffffffff & st->r.v[--st->elem]; \
102 static double NAME##_get_double(void* vstate) { return NAME##_get(vstate) / 4294967296.; } \
104 static void NAME##_set(void* vstate, unsigned long int s) { \
105 NAME##_state* st = (NAME##_state*)vstate; \
111 static const gsl_rng_type NAME##_type = {#NAME, 0xffffffffUL, 0, sizeof(NAME##_state), &NAME##_set, &NAME##_get, &NAME##_get_double}; \
113 R123_STATIC_INLINE void NAME##_reset(gsl_rng const* gr, CBRNGNAME##_ctr_t c, CBRNGNAME##_key_t k) { \
114 NAME##_state* state = (NAME##_state*)gr->state; \
121 gsl_rng_type const* gsl_rng_##NAME = &NAME##_type