cps::RandomGenerator Class Reference

A random number generator generating uniform random numbers in (0,1). More...

#include <random.h>

Inherited by cps::GaussianRandomGenerator [virtual], and cps::UniformRandomGenerator [virtual].

List of all members.

Public Member Functions

 RandomGenerator ()
IFloat Rand ()
 Gets a random number.
void Reset (int seed)
 Seeds the RNG.
void StoreSeeds (unsigned int *to) const
 Stores the RNG state.
void RestoreSeeds (const unsigned int *from)
 Loads the RNG state.
int StateSize () const
 Size of the RNG state.
virtual int RNGints () const
 Number of Integers in RNG, that should be stored to record status.
void store (int *buf)
 to store this object
void load (int *buf)
 to load from file


Detailed Description

A random number generator generating uniform random numbers in (0,1).

This uses the Fibonacci RNG routine (ran3) from Numerical Recipes in C

Definition at line 42 of file random.h.


Constructor & Destructor Documentation

cps::RandomGenerator::RandomGenerator  )  [inline]
 

Definition at line 57 of file random.h.


Member Function Documentation

void cps::RandomGenerator::load int *  buf  )  [inline]
 

to load from file

Reimplemented in cps::GaussianRandomGenerator.

Definition at line 86 of file random.h.

IFloat cps::RandomGenerator::Rand void   ) 
 

Gets a random number.

Precondition:
Reset must have already been called.
Returns:
A random number from a uniform distribution over (0,1)

Reimplemented in cps::UniformRandomGenerator.

Definition at line 42 of file random_asm.C.

References cps::MPISCU::printf().

Referenced by cps::UniformRandomGenerator::Rand(), and cps::GaussianRandomGenerator::Rand().

void cps::RandomGenerator::Reset int  idum  ) 
 

Seeds the RNG.

This method must be called before the RNG is used

Parameters:
idum The seed.

Definition at line 47 of file random.C.

References cps::k.

Referenced by cps::QPropWRand::QPropWRand().

void cps::RandomGenerator::RestoreSeeds const unsigned int *  from  ) 
 

Loads the RNG state.

Parameters:
from Pointer to a buffer of size at least 57*sizeof(int).

Definition at line 120 of file random.C.

Referenced by cps::LatRanGen::SetState().

virtual int cps::RandomGenerator::RNGints  )  const [inline, virtual]
 

Number of Integers in RNG, that should be stored to record status.

Reimplemented in cps::GaussianRandomGenerator, and cps::UGrandomGenerator.

Definition at line 76 of file random.h.

int cps::RandomGenerator::StateSize  )  const
 

Size of the RNG state.

Returns:
The number of unsigned ints that comprise the RNG state vector.

Definition at line 131 of file random.C.

Referenced by cps::LatRanGen::StateSize().

void cps::RandomGenerator::store int *  buf  )  [inline]
 

to store this object

Reimplemented in cps::GaussianRandomGenerator.

Definition at line 79 of file random.h.

void cps::RandomGenerator::StoreSeeds unsigned int *  to  )  const
 

Stores the RNG state.

Parameters:
to Pointer to a buffer of size at least 57*sizeof(int).

Reimplemented in cps::UGrandomGenerator.

Definition at line 104 of file random.C.

Referenced by cps::UGrandomGenerator::StoreSeeds().


The documentation for this class was generated from the following files:
Generated on Tue Mar 6 10:58:19 2007 for Columbia Physics System by  doxygen 1.4.6