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.

- Function:
*const char ****gsl_rng_name***(const gsl_rng **`r`) 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`

.

- Function:
*unsigned long int***gsl_rng_max***(const gsl_rng **`r`) `gsl_rng_max`

returns the largest value that`gsl_rng_get`

can return.

- Function:
*unsigned long int***gsl_rng_min***(const gsl_rng **`r`) `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.

- Function:
*void ****gsl_rng_state***(const gsl_rng **`r`) - Function:
*size_t***gsl_rng_size***(const gsl_rng **`r`) 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);

- Function:
*const gsl_rng_type *****gsl_rng_types_setup***(void)* 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); }