26 #ifndef O2SCL_RNG_GSL_H 27 #define O2SCL_RNG_GSL_H 34 #ifdef O2SCL_NEEDS_TIME_H 38 #include <gsl/gsl_rng.h> 40 #ifndef DOXYGEN_NO_O2NS 59 typedef unsigned long int result_type;
64 rng_gsl(
const gsl_rng_type *gtype=gsl_rng_mt19937);
68 const gsl_rng_type *gtype=gsl_rng_mt19937);
78 return gsl_rng_get(
this);
83 return (this->type->get_double)(this->state);
93 unsigned long int max() {
94 return gsl_rng_max(
this);
98 unsigned long int min() {
99 return gsl_rng_min(
this);
103 unsigned long int random_int(
unsigned long int n=0);
108 gsl_rng_set(
this,seed);
114 gsl_rng_set(
this,seed);
122 this->state=malloc(rg.type->size);
124 memcpy(this->state,rg.state,this->type->size);
133 this->state=malloc(rg.type->size);
135 memcpy(this->state,rg.state,this->type->size);
138 #ifndef DOXYGEN_INTERNAL 157 return (r.type->get_double)(r.state);
161 #ifndef DOXYGEN_NO_O2NS void clock_seed()
Set the seed.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
void set_seed(unsigned long int s)
Set the seed.
rng_gsl(const gsl_rng_type *gtype=gsl_rng_mt19937)
Initialize the random number generator with type gtype and the default seed.
double random()
Return a random number in .
unsigned long int seed
The seed.
double entropy()
Return the entropy (0.0 since not applicable for pseudo-random engines.
unsigned long int max()
Return the maximum integer for random_int()
result_type operator()()
Return a random number in .
rng_gsl & operator=(const rng_gsl &rg)
Copy constructor with equals operator.
Random number generator (GSL)
unsigned long int random_int(unsigned long int n=0)
Return random integer in .
unsigned long int min()
Return the minimum integer for random_int()
rng_gsl(const rng_gsl &rg)
Copy constructor.
const gsl_rng_type * get_type()
Return generator type.
const gsl_rng_type * rng
The GSL random number generator type.