| GNU Scientific Library Reference Manual - Third Edition (v1.12) by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) |
17.5 Auxiliary random number generator functions
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_maxreturns the largest value thatgsl_rng_getcan return.
- Function: unsigned long int gsl_rng_min (const gsl_rng * r)
gsl_rng_minreturns the smallest value thatgsl_rng_getcan 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); }
| ISBN 0954612078 | GNU Scientific Library Reference Manual - Third Edition (v1.12) | See the print edition |