Loading...
Searching...
No Matches
Go to the documentation of this file.
32#ifndef __r123_compat_gslrng_dot_h__
33#define __r123_compat_gslrng_dot_h__
35#include <gsl/gsl_rng.h>
67#define GSL_CBRNG(NAME, CBRNGNAME) \
68 gsl_rng_type const* gsl_rng_##NAME; \
71 CBRNGNAME##_ctr_t ctr; \
72 CBRNGNAME##_ctr_t r; \
73 CBRNGNAME##_key_t key; \
77 static unsigned long int NAME##_get(void* vstate) { \
78 NAME##_state* st = (NAME##_state*)vstate; \
79 int const N = sizeof(st->ctr.v) / sizeof(st->ctr.v[0]); \
82 if(N > 1 && st->ctr.v[0] == 0) \
84 if(N > 2 && st->ctr.v[1] == 0) \
86 if(N > 3 && st->ctr.v[2] == 0) \
88 st->r = CBRNGNAME(st->ctr, st->key); \
91 return 0xffffffffUL & st->r.v[--st->elem]; \
94 static double NAME##_get_double(void* vstate) { return NAME##_get(vstate) / 4294967296.0; } \
96 static void NAME##_set(void* vstate, unsigned long int s) { \
97 NAME##_state* st = (NAME##_state*)vstate; \
103 memset(&st->ctr.v[0], 0, sizeof(st->ctr.v)); \
104 memset(&st->key.v[0], 0, sizeof(st->key.v)); \
114 static const gsl_rng_type NAME##_type = {#NAME, 0xffffffffUL, 0, sizeof(NAME##_state), &NAME##_set, &NAME##_get, &NAME##_get_double}; \
116 gsl_rng_type const* gsl_rng_##NAME = &NAME##_type