KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::Gsl_rng_basic< KIND > Class Template Reference

Basic RAII wrapper for GNU GSL random number generators. More...

#include <gsl_rng.h>

Inheritance diagram for kjb::Gsl_rng_basic< KIND >:
Gsl_rng_cmrg Gsl_rng_gfsr4 Gsl_rng_mrg Gsl_rng_mt19937 Gsl_rng_ranlxd1 Gsl_rng_ranlxd2 Gsl_rng_ranlxs0 Gsl_rng_ranlxs1 Gsl_rng_ranlxs2 Gsl_rng_taus2

Public Member Functions

 Gsl_rng_basic (const gsl_rng_type *type)
 ctor defines type – not meant to be called directly by users. More...
 
 Gsl_rng_basic (const Gsl_rng_basic< KIND > &rng)
 copy ctor of an RNG of the same kind More...
 
Gsl_rng_basic< KIND > & operator= (const Gsl_rng_basic< KIND > &that)
 assignment operator from an RNG of the same kind More...
 
void seed (unsigned long seed_val) const
 seed the generator to determine its future values More...
 
std::string serialize () const
 take a snapshot of the generator state right now More...
 
void deserialize (const std::string &state) const
 return generator to the state "snapshot" from serialize(). More...
 
unsigned long get () const
 Sample uniformly distributed integers over a large range. More...
 
const char * name () const
 return C-style string of the name of the generator algorithm. More...
 
unsigned long max () const
 maximum possible value that get() can potentially return. More...
 
unsigned long min () const
 minimum possible value that get() can potentially return. More...
 
double uniform () const
 Sample uniformly distributed float in interval [0,1) More...
 
double uniform_pos () const
 Sample uniformly distributed positive float in interval (0,1) More...
 
unsigned long uniform_int (unsigned long end_value) const
 Sample uniformly dist. non-neg. integers less than end_value. More...
 
 operator const gsl_rng * () const
 return raw pointer to generator – needed by other GSL methods More...
 

Detailed Description

template<unsigned KIND>
class kjb::Gsl_rng_basic< KIND >

Basic RAII wrapper for GNU GSL random number generators.

Warning
I recommend you not use this basic class directly; instead use the specializations below, defined via Gsl_rng_template.

Most of the gsl functions having names with prefix "gsl_rng_" are wrapped below. The methods that are NOT wrapped are the following:

The functiosn gsl_rng_fread() and gsl_rng_fwrite() are wrapped up inside the methods serialize() and deserialize(). You should use that interface since the methods also perform the type checking that fread requires.

Constructor & Destructor Documentation

template<unsigned KIND>
kjb::Gsl_rng_basic< KIND >::Gsl_rng_basic ( const gsl_rng_type type)
inline

ctor defines type – not meant to be called directly by users.

template<unsigned KIND>
kjb::Gsl_rng_basic< KIND >::Gsl_rng_basic ( const Gsl_rng_basic< KIND > &  rng)
inline

copy ctor of an RNG of the same kind

Member Function Documentation

template<unsigned KIND>
void kjb::Gsl_rng_basic< KIND >::deserialize ( const std::string &  state) const
inline

return generator to the state "snapshot" from serialize().

Parameters
stateOutput from method serialize() from a RNG of the same type as this one.
Exceptions
KJB_errorcorresponding to GSL_EFAILED if input is from an invalid string.
template<unsigned KIND>
unsigned long kjb::Gsl_rng_basic< KIND >::get ( ) const
inline

Sample uniformly distributed integers over a large range.

See Also
max() for the maximum possible value – a value that IS possible.
min() for the minimum possible value – a value that IS possible.
template<unsigned KIND>
unsigned long kjb::Gsl_rng_basic< KIND >::max ( ) const
inline

maximum possible value that get() can potentially return.

template<unsigned KIND>
unsigned long kjb::Gsl_rng_basic< KIND >::min ( ) const
inline

minimum possible value that get() can potentially return.

template<unsigned KIND>
const char* kjb::Gsl_rng_basic< KIND >::name ( ) const
inline

return C-style string of the name of the generator algorithm.

template<unsigned KIND>
kjb::Gsl_rng_basic< KIND >::operator const gsl_rng * ( ) const
inline

return raw pointer to generator – needed by other GSL methods

template<unsigned KIND>
Gsl_rng_basic< KIND >& kjb::Gsl_rng_basic< KIND >::operator= ( const Gsl_rng_basic< KIND > &  that)
inline

assignment operator from an RNG of the same kind

template<unsigned KIND>
void kjb::Gsl_rng_basic< KIND >::seed ( unsigned long  seed_val) const
inline

seed the generator to determine its future values

template<unsigned KIND>
std::string kjb::Gsl_rng_basic< KIND >::serialize ( ) const
inline

take a snapshot of the generator state right now

template<unsigned KIND>
double kjb::Gsl_rng_basic< KIND >::uniform ( ) const
inline

Sample uniformly distributed float in interval [0,1)

template<unsigned KIND>
unsigned long kjb::Gsl_rng_basic< KIND >::uniform_int ( unsigned long  end_value) const
inline

Sample uniformly dist. non-neg. integers less than end_value.

Warning
end_value must not be too big: see GSL documentation
Exceptions
KJB_errorcorresponding to GSL_EINVAL if end_value is invalid.
template<unsigned KIND>
double kjb::Gsl_rng_basic< KIND >::uniform_pos ( ) const
inline

Sample uniformly distributed positive float in interval (0,1)


The documentation for this class was generated from the following file: