NEST  2.6.0,not_revisioned_source_dir@0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
librandom::RandomGen Class Referenceabstract

Abstract base class for all random generator objects. More...

#include <randomgen.h>

Inheritance diagram for librandom::RandomGen:
librandom::GslRandomGen librandom::GslRandomGen librandom::KnuthLFG librandom::MT19937

Public Member Functions

 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...
 
virtual RngPtr clone (const unsigned long)=0
 clone a random number generator of same type initialized with given seed More...
 

Static Public Member Functions

static RngPtr create_knuthlfg_rng (unsigned long)
 Create built-in Knuth Lagged Fibonacci random generator. More...
 

Static Public Attributes

static const unsigned long DefaultSeed = 0xd37ca59fUL
 Default value for seeding generators in places where no seed is supplied. More...
 

Protected Member Functions

virtual void seed_ (unsigned long)=0
 The following functions provide the interface to the actual random generator. More...
 
virtual double drand_ ()=0
 drawing interface More...
 

Private Member Functions

void refill_ ()
 refill buffer More...
 
 RandomGen (const RandomGen &)
 

Private Attributes

std::vector< double > buffer_
 random number buffer More...
 
std::vector< double >
::const_iterator 
next_
 next number to return More...
 
std::vector< double >
::const_iterator 
end_
 == buffer_.end() More...
 

Static Private Attributes

static const size_t DEFAULT_BUFFSIZE = 128 * 1024
 

Detailed Description

Abstract base class for all random generator objects.

Class RandomGen is the top of the random generator object hierarchy. It defines the interface to random generators:

Note
Random number generators buffer the numbers they generate to increase efficieny in number generation. Buffer size can be adjusted at runtime.
See also
class RandomDev

Constructor & Destructor Documentation

librandom::RandomGen::RandomGen ( )
Note
All classes derived from RandomGen should have only a single constructor, taking an unsigned long as seed value. Use RandomGen::DefaultSeed if you want to create a generator with a default seed value.

References DEFAULT_BUFFSIZE, and set_buffsize().

virtual librandom::RandomGen::~RandomGen ( )
inlinevirtual
librandom::RandomGen::RandomGen ( const RandomGen )
private

Member Function Documentation

virtual RngPtr librandom::RandomGen::clone ( const unsigned  long)
pure virtual

clone a random number generator of same type initialized with given seed

Implemented in librandom::MT19937, librandom::KnuthLFG, and librandom::GslRandomGen.

librandom::RngPtr librandom::RandomGen::create_knuthlfg_rng ( unsigned long  seed)
static

Create built-in Knuth Lagged Fibonacci random generator.

This function is provided so that RNGs can be created in places where the SLI rngdict is not accessible.

See also
KnuthLFG

Referenced by nest::mip_generator::Parameters_::Parameters_(), and nest::Scheduler::prepare_nodes().

double librandom::RandomGen::drand ( void  )
inline

The following functions implement the user interface of the RandomGen class, including buffer management.

The actual interface to the underlying random generator is provided by protected member functions below.draw from [0, 1)

References end_, next_, and refill_().

Referenced by drandpos(), librandom::LognormalRandomDev::operator()(), librandom::NormalRandomDev::operator()(), operator()(), ulrand(), and librandom::GammaRandomDev::unscaled_gamma().

virtual double librandom::RandomGen::drand_ ( )
protectedpure virtual

drawing interface

Implemented in librandom::MT19937, librandom::KnuthLFG, and librandom::GslRandomGen.

double librandom::RandomGen::drandpos ( void  )
inline

draw from (0, 1)

References drand().

Referenced by librandom::GammaRandomDev::unscaled_gamma().

size_t librandom::RandomGen::get_buffsize ( void  ) const
inline

returns buffer size

References buffer_.

double librandom::RandomGen::operator() ( void  )
inline

draw from [0, 1)

References drand().

void librandom::RandomGen::refill_ ( void  )
private

refill buffer

Referenced by drand().

void librandom::RandomGen::seed ( const unsigned long  n)

set random seed to a new value

virtual void librandom::RandomGen::seed_ ( unsigned  long)
protectedpure virtual

The following functions provide the interface to the actual random generator.

They must be implemented by each derived generator class.seeding interface

Implemented in librandom::MT19937, librandom::KnuthLFG, and librandom::GslRandomGen.

void librandom::RandomGen::set_buffsize ( const size_t  buffsize)

set buffer size

References assert().

Referenced by RandomGen().

unsigned long librandom::RandomGen::ulrand ( const unsigned long  n)
inline

draw from [0, n-1]

References drand().

Member Data Documentation

std::vector<double> librandom::RandomGen::buffer_
private

random number buffer

Referenced by get_buffsize().

const size_t librandom::RandomGen::DEFAULT_BUFFSIZE = 128 * 1024
staticprivate

Referenced by RandomGen().

const unsigned long librandom::RandomGen::DefaultSeed = 0xd37ca59fUL
static

Default value for seeding generators in places where no seed is supplied.

Referenced by main(), and nest::Scheduler::prepare_nodes().

std::vector<double>::const_iterator librandom::RandomGen::end_
private

== buffer_.end()

Referenced by drand().

std::vector<double>::const_iterator librandom::RandomGen::next_
private

next number to return

Referenced by drand().


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