\(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\W}[1]{ \; #1 \; }\)
manage_gsl_rng¶
View page sourceSet, Get, And Free A GSL Random Number Generator¶
Syntax¶
include <cppad/mixed/manage_gsl_rng.hpp>CppAD::mixed::new_gsl_rng ( s_in )CppAD::mixed::get_gsl_rng ()CppAD::mixed::free_gsl_rng ()Purpose¶
Create and use a GSL random number generator.
new_gsl_rng¶
This routine creates a new GSL random number generator.
If a previous random number generator was created, it must
be freed using free_gsl_rng before new_gsl_rng
can be called again.
s_in¶
This argument has prototype
size_ts_in
If s_in != 0 ,
it is used as a seed for the random number generator.
Otherwise the actual seed is the number of seconds returned by
std::time plus the number of previous calls to set_gsl_rng .
(Adding the number of calls prevents the same
seed from being used by calls that are close together in time.)
s_out¶
This return value prototype
size_ts_out
and is the actual seed that was used to initialize the random number generator.
get_gsl_rng¶
If we are between a call to
new_gsl_rng and free_gsl_rng ,
this routine retrieves a pointer to the current
GSL random number generator.
Otherwise it returns the null pointer.
rng¶
The return value rng has prototype
gsl_rng* rng
free_gsl_rng¶
Once you are done with a generator created by new_gsl_rng ,
you should free the corresponding memory using
gsl_rng_free()
.
Example¶
The file manage_gsl_rng.cpp contains an example and test of
manage_gsl_rng . It returns true , if the test passes,
and false otherwise.