Next: Random number environment variables, Previous: Sampling from a random number generator, Up: Random Number Generation [Index]
The following functions provide information about an existing generator. You should use them in preference to hard-coding the generator parameters into your own code.
This function returns a pointer to the name of the generator. For example,
printf ("r is a '%s' generator\n", gsl_rng_name (r));
would print something like r is a 'taus' generator
.
gsl_rng_max
returns the largest value that gsl_rng_get
can return.
gsl_rng_min
returns the smallest value that gsl_rng_get
can return. Usually this value is zero. There are some generators with
algorithms that cannot return zero, and for these generators the minimum
value is 1.
These functions return a pointer to the state of generator r and its size. You can use this information to access the state directly. For example, the following code will write the state of a generator to a stream,
void * state = gsl_rng_state (r); size_t n = gsl_rng_size (r); fwrite (state, n, 1, stream);
This function returns a pointer to an array of all the available generator types, terminated by a null pointer. The function should be called once at the start of the program, if needed. The following code fragment shows how to iterate over the array of generator types to print the names of the available algorithms,
const gsl_rng_type **t, **t0; t0 = gsl_rng_types_setup (); printf ("Available generators:\n"); for (t = t0; *t != 0; t++) { printf ("%s\n", (*t)->name); }
Next: Random number environment variables, Previous: Sampling from a random number generator, Up: Random Number Generation [Index]