I'm trying to use the random number generator from the GSL. In my code I have something like
...
gsl_rng * r; /* global generator for Random Numbers*/
void init_rand_generator( int seed ){
/* Random numbers initialization */
const gsl_rng_type * T;
gsl_rng_env_setup();
gsl_rng_default_seed = seed;
T = gsl_rng_default;
r = gsl_rng_alloc( T );
}
...
The problem is that, when I call the init_rand_generator( seed )
function from another function, in order to use gsl_rng_uniform( r )
, the memory blows up and my system hangs.
However, when I initialize the random number variables in the function where I use the gsl_rng_uniform( r )
function, everything works fine.
I don't know what's the problem.