1 #ifndef _GLUCAT_RANDOM_H
2 #define _GLUCAT_RANDOM_H
34 #if defined(_GLUCAT_USE_GSL_RANDOM)
35 # include <gsl/gsl_rng.h>
36 # include <gsl/gsl_randist.h>
46 template<
typename Scalar_T >
47 class random_generator
59 static const unsigned long seed = 19590921UL;
60 #if defined(_GLUCAT_USE_GSL_RANDOM)
65 gen(gsl_rng_alloc(gsl_rng_mt19937))
66 { gsl_rng_set(this->gen,
seed); }
69 { gsl_rng_free(this->gen); }
73 {
return Scalar_T(gsl_ran_flat(this->gen, 0.0, 1.0)); }
75 {
return Scalar_T(gsl_ran_gaussian(this->gen, 1.0)); }
85 { this->uint_gen.seed(
seed); }
94 {
return Scalar_T(this->
normal_dist(this->uint_gen)); }
100 #endif // _GLUCAT_RANDOM_H