NEST
2.6.0,not_revisioned_source_dir@0
|
Built-in implementation of Knuth's Lagged Fibonacci generator. More...
#include <knuthlfg.h>
Public Member Functions | |
KnuthLFG (unsigned long) | |
Create generator with given seed. More... | |
~KnuthLFG () | |
RngPtr | clone (unsigned long s) |
clone a random number generator of same type initialized with given seed More... | |
Public Member Functions inherited from librandom::RandomGen | |
RandomGen () | |
virtual | ~RandomGen () |
double | drand (void) |
The following functions implement the user interface of the RandomGen class, including buffer management. More... | |
double | operator() (void) |
draw from [0, 1) More... | |
double | drandpos (void) |
draw from (0, 1) More... | |
unsigned long | ulrand (const unsigned long) |
draw from [0, n-1] More... | |
void | seed (const unsigned long) |
set random seed to a new value More... | |
size_t | get_buffsize (void) const |
returns buffer size More... | |
void | set_buffsize (const size_t) |
set buffer size More... | |
Private Member Functions | |
void | seed_ (unsigned long) |
implements seeding for RandomGen More... | |
double | drand_ () |
implements drawing a single [0,1) number for RandomGen More... | |
void | ran_array_ (std::vector< long > &rbuff) |
Generates numbers, refilling buffer. More... | |
void | ran_start_ (long seed) |
initializes buffer More... | |
long | ran_draw_ () |
deliver integer random number from ran_buffer_ More... | |
void | self_test_ () |
Perform minimal self-test given by Knuth. More... | |
Static Private Member Functions | |
static long | mod_diff_ (long, long) |
subtraction module MM More... | |
static bool | is_odd_ (long) |
Private Attributes | |
std::vector< long > | ran_x_ |
the generator state More... | |
std::vector< long > | ran_buffer_ |
generated numbers, 0..KK-1 are shipped More... | |
const std::vector< long > ::const_iterator | end_ |
marker past last to deliver More... | |
std::vector< long >::const_iterator | next_ |
next number to deliver More... | |
Static Private Attributes | |
static const long | KK_ = 100 |
the long lag More... | |
static const long | LL_ = 37 |
the short lag More... | |
static const long | MM_ = 1L << 30 |
the modulus More... | |
static const long | TT_ = 70 |
guaranteed separation between streams More... | |
static const long | QUALITY_ = 1009 |
number of RNGs to fill for each cycle More... | |
static const double | I2DFactor_ = 1.0 / librandom::KnuthLFG::MM_ |
int to double factor More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from librandom::RandomGen | |
static RngPtr | create_knuthlfg_rng (unsigned long) |
Create built-in Knuth Lagged Fibonacci random generator. More... | |
Static Public Attributes inherited from librandom::RandomGen | |
static const unsigned long | DefaultSeed = 0xd37ca59fUL |
Default value for seeding generators in places where no seed is supplied. More... | |
Built-in implementation of Knuth's Lagged Fibonacci generator.
This implementation is directly derived from Knuth's C code and generates the same random number sequence as the GSL implementation.
|
explicit |
|
inline |
|
inlinevirtual |
clone a random number generator of same type initialized with given seed
Implements librandom::RandomGen.
References KnuthLFG().
|
inlineprivatevirtual |
implements drawing a single [0,1) number for RandomGen
Implements librandom::RandomGen.
References I2DFactor_, and ran_draw_().
|
inlinestaticprivate |
|
inlinestaticprivate |
subtraction module MM
References MM_.
|
private |
Generates numbers, refilling buffer.
References nest::names::n.
Referenced by ran_draw_().
|
inlineprivate |
deliver integer random number from ran_buffer_
References end_, next_, ran_array_(), and ran_buffer_.
Referenced by drand_().
|
private |
|
inlineprivatevirtual |
|
private |
Perform minimal self-test given by Knuth.
The test will break an assertion if it fails. This is acceptable, since failure indicates either lack of two's complement arithmetic or problems with the size of data types.
References assert().
Referenced by KnuthLFG().
|
private |
marker past last to deliver
Referenced by ran_draw_().
|
staticprivate |
int to double factor
Referenced by drand_().
|
staticprivate |
the long lag
|
staticprivate |
the short lag
|
staticprivate |
the modulus
Referenced by mod_diff_().
|
private |
next number to deliver
Referenced by ran_draw_().
|
staticprivate |
number of RNGs to fill for each cycle
|
private |
generated numbers, 0..KK-1 are shipped
Referenced by ran_draw_().
|
private |
the generator state
|
staticprivate |
guaranteed separation between streams