3
<title>Auxiliary random number generator functions - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Random-Number-Generation.html#Random-Number-Generation" title="Random Number Generation">
9
<link rel="prev" href="Sampling-from-a-random-number-generator.html#Sampling-from-a-random-number-generator" title="Sampling from a random number generator">
10
<link rel="next" href="Random-number-environment-variables.html#Random-number-environment-variables" title="Random number environment variables">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
15
Permission is granted to copy, distribute and/or modify this document
16
under the terms of the GNU Free Documentation License, Version 1.2 or
17
any later version published by the Free Software Foundation; with the
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
20
and with the Back-Cover Text being (a) (see below). A copy of the
21
license is included in the section entitled ``GNU Free Documentation
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
25
GNU Manual, like GNU software.''-->
26
<meta http-equiv="Content-Style-Type" content="text/css">
27
<style type="text/css"><!--
28
pre.display { font-family:inherit }
29
pre.format { font-family:inherit }
30
pre.smalldisplay { font-family:inherit; font-size:smaller }
31
pre.smallformat { font-family:inherit; font-size:smaller }
32
pre.smallexample { font-size:smaller }
33
pre.smalllisp { font-size:smaller }
34
span.sc { font-variant:small-caps }
35
span.roman { font-family:serif; font-weight:normal; }
36
span.sansserif { font-family:sans-serif; font-weight:normal; }
42
<a name="Auxiliary-random-number-generator-functions"></a>
43
Next: <a rel="next" accesskey="n" href="Random-number-environment-variables.html#Random-number-environment-variables">Random number environment variables</a>,
44
Previous: <a rel="previous" accesskey="p" href="Sampling-from-a-random-number-generator.html#Sampling-from-a-random-number-generator">Sampling from a random number generator</a>,
45
Up: <a rel="up" accesskey="u" href="Random-Number-Generation.html#Random-Number-Generation">Random Number Generation</a>
49
<h3 class="section">17.5 Auxiliary random number generator functions</h3>
51
<p>The following functions provide information about an existing
52
generator. You should use them in preference to hard-coding the generator
53
parameters into your own code.
56
— Function: const char * <b>gsl_rng_name</b> (<var>const gsl_rng * r</var>)<var><a name="index-gsl_005frng_005fname-1380"></a></var><br>
57
<blockquote><p>This function returns a pointer to the name of the generator.
60
<pre class="example"> printf ("r is a '%s' generator\n",
63
<p class="noindent">would print something like <code>r is a 'taus' generator</code>.
64
</p></blockquote></div>
67
— Function: unsigned long int <b>gsl_rng_max</b> (<var>const gsl_rng * r</var>)<var><a name="index-gsl_005frng_005fmax-1381"></a></var><br>
68
<blockquote><p><code>gsl_rng_max</code> returns the largest value that <code>gsl_rng_get</code>
70
</p></blockquote></div>
73
— Function: unsigned long int <b>gsl_rng_min</b> (<var>const gsl_rng * r</var>)<var><a name="index-gsl_005frng_005fmin-1382"></a></var><br>
74
<blockquote><p><code>gsl_rng_min</code> returns the smallest value that <code>gsl_rng_get</code>
75
can return. Usually this value is zero. There are some generators with
76
algorithms that cannot return zero, and for these generators the minimum
78
</p></blockquote></div>
81
— Function: void * <b>gsl_rng_state</b> (<var>const gsl_rng * r</var>)<var><a name="index-gsl_005frng_005fstate-1383"></a></var><br>
82
— Function: size_t <b>gsl_rng_size</b> (<var>const gsl_rng * r</var>)<var><a name="index-gsl_005frng_005fsize-1384"></a></var><br>
83
<blockquote><p>These functions return a pointer to the state of generator <var>r</var> and
84
its size. You can use this information to access the state directly. For
85
example, the following code will write the state of a generator to a
88
<pre class="example"> void * state = gsl_rng_state (r);
89
size_t n = gsl_rng_size (r);
90
fwrite (state, n, 1, stream);
95
— Function: const gsl_rng_type ** <b>gsl_rng_types_setup</b> (<var>void</var>)<var><a name="index-gsl_005frng_005ftypes_005fsetup-1385"></a></var><br>
96
<blockquote><p>This function returns a pointer to an array of all the available
97
generator types, terminated by a null pointer. The function should be
98
called once at the start of the program, if needed. The following code
99
fragment shows how to iterate over the array of generator types to print
100
the names of the available algorithms,
102
<pre class="example"> const gsl_rng_type **t, **t0;
104
t0 = gsl_rng_types_setup ();
106
printf ("Available generators:\n");
108
for (t = t0; *t != 0; t++)
110
printf ("%s\n", (*t)->name);