10 #ifndef GSL_RNG_H_INCLUDED_LIBKJB_UOFARIZONAVISION
11 #define GSL_RNG_H_INCLUDED_LIBKJB_UOFARIZONAVISION
19 #include "gsl/gsl_rng.h"
21 #warning "Compiling GNU GSL wrapper without GNU GSL; it will not run properly"
62 std::string gsl_rng_serialize_implementation(
const gsl_rng* );
64 void gsl_rng_deserialize_implementation(
gsl_rng*,
const std::string& );
85 template<
unsigned KIND >
93 return char(
'0' + KIND );
101 : m_rng( gsl_rng_alloc( type ) )
103 ETX_2( 00 == m_rng,
"Gsl_rng_basic ctor: bad_alloc" );
114 : m_rng( gsl_rng_clone( rng.m_rng ) )
116 ETX_2( 00 == m_rng,
"Gsl_rng_basic copy ctor: bad_alloc" );
130 gsl_rng_memcpy( m_rng, that.m_rng );
137 void seed(
unsigned long seed_val )
const
140 gsl_rng_set( m_rng, seed_val );
148 return gsl_rng_serialize_implementation( m_rng ) + kind();
162 if ( state.size() < 2 || state[ state.size() - 1 ] != kind() )
167 gsl_rng_deserialize_implementation( m_rng,
168 std::string( state.begin(), state.end() - 1 ) );
177 unsigned long get()
const
180 return gsl_rng_get( m_rng );
188 return gsl_rng_name( m_rng );
196 return gsl_rng_max( m_rng );
204 return gsl_rng_min( m_rng );
212 return gsl_rng_uniform( m_rng );
220 return gsl_rng_uniform_pos( m_rng );
232 unsigned long dev = gsl_rng_uniform_int( m_rng, end_value );
234 if ( 0 == dev && end_value >
max() )
253 gsl_rng_free( m_rng );
261 #define Gsl_rng_template( Foo, foo, FOO ) \
262 struct Foo : public Gsl_rng_basic< FOO > \
264 Foo() : Gsl_rng_basic< FOO >( foo ) {} \
Matsumoto's & Nishimura's "Mersenne Twister".
Definition: gsl_rng.h:48
void gsl_rng
Definition: gsl_rng.h:22
unsigned long min() const
minimum possible value that get() can potentially return.
Definition: gsl_rng.h:201
const char * name() const
return C-style string of the name of the generator algorithm.
Definition: gsl_rng.h:185
void gsl_rng_type
Definition: gsl_rng.h:23
Random number generator using the "RANLUX" algorithm, 24 bits. This implements the "RANLUX" algor...
Random number generator using a four-tap XOR using a shift register. This uses Ziff's offsets (1998) ...
RANLUX double-precision level 2.
Definition: gsl_rng.h:53
unsigned long uniform_int(unsigned long end_value) const
Sample uniformly dist. non-neg. integers less than end_value.
Definition: gsl_rng.h:229
void seed(unsigned long seed_val) const
seed the generator to determine its future values
Definition: gsl_rng.h:137
GSL utility stuff to help those using the C++ wrapper on GSL code.
gsl_rng_type * gsl_rng_gfsr4
Definition: gsl_rng.h:24
gsl_rng_type * gsl_rng_cmrg
Definition: gsl_rng.h:24
Random number generator using the "Mersenne Twister" algorithm. This implements the "Mersenne Twister...
void deserialize(const std::string &state) const
return generator to the state "snapshot" from serialize().
Definition: gsl_rng.h:159
Random number generator using the "RANLUX" algorithm, 48 bits, lvl. 1 This implements the "RANLUX"...
unsigned long max() const
maximum possible value that get() can potentially return.
Definition: gsl_rng.h:193
Random number generator using L'Ecuyer's 1996 algorithm. This implements the Combined Multiple Recurs...
RANLUX single-precision level 0.
Definition: gsl_rng.h:49
gsl_rng_type * gsl_rng_ranlxd2
Definition: gsl_rng.h:24
Gsl_rng_template(Gsl_rng_mt19937, gsl_rng_mt19937, GSL_RNG_MT19937)
Gsl_rng_mt19937 Gsl_rng_default
An all-around good, fast, simulation-quality random number generator.
Definition: gsl_rng.h:397
gsl_rng_type * gsl_rng_ranlxs0
Definition: gsl_rng.h:24
Gsl_rng_basic(const gsl_rng_type *type)
ctor defines type – not meant to be called directly by users.
Definition: gsl_rng.h:99
double uniform_pos() const
Sample uniformly distributed positive float in interval (0,1)
Definition: gsl_rng.h:217
Random number generator using the "RANLUX" algorithm, 24 bits. This implements the "RANLUX" algor...
#define GSL_ETX(gsl_expr)
Definition: gsl_util.h:37
Four-tap-XOR shift generator.
Definition: gsl_rng.h:57
Random number generator using the "RANLUX" algorithm, 48 bits, lvl. 1 This implements the "RANLUX"...
RANLUX single-precision level 2.
Definition: gsl_rng.h:51
Random number generator using 1993 algorithm of L'Ecuyer et al. This implements the Multiple Recursiv...
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
std::string serialize() const
take a snapshot of the generator state right now
Definition: gsl_rng.h:145
double uniform() const
Sample uniformly distributed float in interval [0,1)
Definition: gsl_rng.h:209
Gsl_rng_basic< KIND > & operator=(const Gsl_rng_basic< KIND > &that)
assignment operator from an RNG of the same kind
Definition: gsl_rng.h:125
#define ETX_2(a, msg)
Definition: l_exception.h:78
RANLUX single-precision level 1.
Definition: gsl_rng.h:50
gsl_rng_type * gsl_rng_mt19937
Definition: gsl_rng.h:24
Random number generator using Tausworthe's algorithm. This is L'Ecuyer's version of Tausworthe's algo...
RANLUX double-precision level 1.
Definition: gsl_rng.h:52
Tausworthe generator version 2.
Definition: gsl_rng.h:56
Support for error handling exception classes in libKJB.
Object thrown when a program lacks required resources or libraries.
Definition: l_exception.h:539
gsl_rng_type * gsl_rng_taus2
Definition: gsl_rng.h:24
L'Ecuyer's '96 generator, period ~ 10^56.
Definition: gsl_rng.h:54
Random number generator using the "RANLUX" algorithm, 24 bits. This implements the "RANLUX" algor...
gsl_rng_type * gsl_rng_ranlxs1
Definition: gsl_rng.h:24
gsl_rng_type * gsl_rng_ranlxs2
Definition: gsl_rng.h:24
L'Ecuyer et al. '93 generator, period ~ 10^46.
Definition: gsl_rng.h:55
gsl_rng_type * gsl_rng_mrg
Definition: gsl_rng.h:24
Basic RAII wrapper for GNU GSL random number generators.
Definition: gsl_rng.h:86
gsl_rng_type * gsl_rng_ranlxd1
Definition: gsl_rng.h:24