75 static vector<unsigned long int> seeds;
77 #pragma omp critical (Rng_seed) 79 unsigned long int n_orig = n;
81 while (find(seeds.begin(), seeds.end(), n) != seeds.end())
83 if (n >= ULONG_MAX - 1)
93 out0 <<
"Rng Warning: Couldn't find an unused seed. Clearing seed pool.\n";
191 static inline unsigned long int mt_get (
void *vstate);
192 static double mt_get_double (
void *vstate);
193 static void mt_set (
void *state,
unsigned long int s);
199 static const unsigned long UPPER_MASK = 0x80000000UL;
202 static const unsigned long LOWER_MASK = 0x7fffffffUL;
211 static inline unsigned long 212 mt_get (
void *vstate)
217 unsigned long int *
const mt = state->
mt;
219 #define MAGIC(y) (((y)&0x1) ? 0x9908b0dfUL : 0) 225 for (kk = 0; kk <
N -
M; kk++)
227 unsigned long y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK);
228 mt[kk] = mt[kk +
M] ^ (y >> 1) ^
MAGIC(y);
230 for (; kk <
N - 1; kk++)
232 unsigned long y = (mt[kk] & UPPER_MASK) | (mt[kk + 1] & LOWER_MASK);
233 mt[kk] = mt[kk + (M -
N)] ^ (y >> 1) ^
MAGIC(y);
237 unsigned long y = (mt[N - 1] & UPPER_MASK) | (mt[0] & LOWER_MASK);
238 mt[N - 1] = mt[M - 1] ^ (y >> 1) ^
MAGIC(y);
248 k ^= (k << 7) & 0x9d2c5680UL;
249 k ^= (k << 15) & 0xefc60000UL;
258 mt_get_double (
void * vstate)
260 return (
double)mt_get (vstate) / 4294967296.0 ;
264 mt_set (
void *vstate,
unsigned long int s)
272 state->
mt[0]= s & 0xffffffffUL;
274 for (i = 1; i <
N; i++)
280 (1812433253UL * (state->
mt[i-1] ^ (state->
mt[i-1] >> 30)) + i);
282 state->
mt[i] &= 0xffffffffUL;
325 #define ADD(t) {if (i==N1) abort(); gsl_rng_generator_types[i] = (t); i++; }; 344 ADD(gsl_rng_mt19937);
430 (*gsl_stream_handler) (label, file, line, reason);
433 fprintf (
gsl_stream,
"gsl: %s:%d: %s: %s\n", file, line, label, reason);
442 return previous_handler;
448 FILE * previous_stream;
454 return previous_stream;
479 static void no_error_handler (
const char *reason,
const char *file,
int line,
int gsl_errno);
482 gsl_error (
const char * reason,
const char * file,
int line,
int gsl_errno)
486 (*gsl_error_handler) (reason, file, line, gsl_errno);
492 fprintf (stderr,
"Default GSL error handler invoked.\n");
501 return previous_handler;
510 return previous_handler;
514 no_error_handler (
const char *reason
_U_,
const char *file
_U_,
int line
_U_,
int gsl_errno
_U_)
616 #ifndef HIDE_INLINE_STATIC 645 unsigned long int offset = r->
type->
min;
646 unsigned long int range = r->
type->
max - offset;
647 unsigned long int scale = range / n;
700 unsigned char *p = (
unsigned char *) (r->
state);
703 for (i = 0; i < n; i++)
706 printf (
"%.2x", *(p + i));
void gsl_stream_printf(const char *label, const char *file, int line, const char *reason)
const gsl_rng_type * type
Declarations having to do with the four output streams.
gsl_rng * gsl_rng_clone(const gsl_rng *q)
unsigned long int gsl_rng_max(const gsl_rng *r)
void force_seed(unsigned long int n)
FILE * gsl_set_stream(FILE *new_stream)
void gsl_rng_print_state(const gsl_rng *r)
gsl_rng * gsl_rng_alloc(const gsl_rng_type *T)
void gsl_error_handler_t(const char *reason, const char *file, int line, int gsl_errno)
void gsl_rng_set(const gsl_rng *r, unsigned long int seed)
const gsl_rng_type * gsl_rng_mt19937
#define GSL_ERROR_VAL(reason, gsl_errno, value)
unsigned long int gsl_rng_uniform_int(const gsl_rng *r, unsigned long int n)
The global header file for ARTS.
void gsl_stream_handler_t(const char *label, const char *file, int line, const char *reason)
void(* set)(void *state, unsigned long int seed)
unsigned long int(* get)(void *state)
gsl_error_handler_t * gsl_error_handler
Defines the Rng random number generator class.
void gsl_error(const char *reason, const char *file, int line, int gsl_errno)
gsl_stream_handler_t * gsl_stream_handler
void * gsl_rng_state(const gsl_rng *r)
unsigned long int showseed() const
unsigned long int gsl_rng_get(const gsl_rng *r)
unsigned long int gsl_rng_default_seed
int gsl_rng_memcpy(gsl_rng *dest, const gsl_rng *src)
#define GSL_ERROR(reason, gsl_errno)
gsl_stream_handler_t * gsl_set_stream_handler(gsl_stream_handler_t *new_handler)
double(* get_double)(void *state)
size_t gsl_rng_size(const gsl_rng *r)
const gsl_rng_type ** gsl_rng_types_setup(void)
const char * gsl_rng_name(const gsl_rng *r)
unsigned long int gsl_rng_min(const gsl_rng *r)
double gsl_rng_uniform(const gsl_rng *r)
void seed(unsigned long int n, const Verbosity &verbosity)
gsl_error_handler_t * gsl_set_error_handler(gsl_error_handler_t *new_handler)
void gsl_rng_free(gsl_rng *r)
unsigned long int seed_no
const gsl_rng_type * gsl_rng_generator_types[N1]
double gsl_rng_uniform_pos(const gsl_rng *r)
gsl_error_handler_t * gsl_set_error_handler_off(void)