Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

cps::LatRanGen Class Reference

The lattice random number generator. More...

#include <random.h>

List of all members.

Public Member Functions

 LatRanGen ()
 ~LatRanGen ()
void Initialize ()
IFloat Urand (FermionFieldDimension frm_dim=FOUR_D)
 Get a uniform random number.
IFloat Urand (Float high, Float low, FermionFieldDimension frm_dim=FOUR_D)
IFloat Grand (FermionFieldDimension frm_dim=FOUR_D)
 Get a gaussian random number.
IFloat Lrand ()
 Get a uniform random number which is the same on all nodes.
void SetSigma (IFloat sigma)
 Sets the variance of the distribution.
void SetInterval (IFloat high, IFloat low)
 Sets the interval over which the uniform distribution is defined.
void AssignGenerator (int x, int y, int z, int t, int s=0)
 Specifies which hypercube RNG to use.
void AssignGenerator (const int *coor)
 Specifies which hypercube RNG to use.
void AssignGenerator (int i)
 Specifies which hypercube RNG to use.
int StateSize () const
 Size of the RNG state (per hypercube).
void SetState (const unsigned int *, FermionFieldDimension frm_dim=FIVE_D)
 Assign the state to a selected RNG.
void SetStates (unsigned int **, FermionFieldDimension frm_dim=FIVE_D)
 Assign the state of all RNGs.
int NStates (FermionFieldDimension frm_dim=FIVE_D) const
 Get the total number of states.
void GetState (unsigned int *, FermionFieldDimension frm_dim=FIVE_D) const
 Retrieve the state of a single RNG.
void GetStates (unsigned int **, FermionFieldDimension frm_dim=FIVE_D) const
 Retrieve the state of all RNGs.
bool Read (const char *filename, int concur_io_num=0)
 Save the RNGs to a file (due to multi-type class members, not only supports read/write on same platform).
bool Write (const char *filename, int concur_io_num=0)
void setParallel ()
void setSerial ()
int parIO () const
bool good () const
void Shift ()
void setLogDir (const char *LogDir)


Detailed Description

The lattice random number generator.

This class contains a uniform and a gaussian RNG for each 2^4 hypercube on the lattice. To ensure cross-platform reproducibility, these RNGs should be used, not the ones defined in the classes from which this inherits.

Definition at line 276 of file random.h.


Constructor & Destructor Documentation

cps::LatRanGen::LatRanGen  ) 
 

Definition at line 146 of file random.C.

cps::LatRanGen::~LatRanGen  ) 
 

Definition at line 154 of file random.C.


Member Function Documentation

void cps::LatRanGen::AssignGenerator int  i  ) 
 

Specifies which hypercube RNG to use.

For a given lattice site, this identifies and assigns the corresponding hypercube RNG.

Parameters:
i The canonical index of the lattice site.
Postcondition:
Subsequent calls to e.g. Urand will return results from this particular hypercubic RNG.

Definition at line 452 of file random.C.

References cps::GJP, and cps::GlobalJobParameter::SnodeSites().

void cps::LatRanGen::AssignGenerator const int *  x  ) 
 

Specifies which hypercube RNG to use.

For a given lattice site, this identifies and assigns the corresponding hypercube RNG.

Parameters:
x Array holding the lattice site coordinates in order X, Y, Z, T.
Postcondition:
Subsequent calls to e.g. Urand will return results from this particular hypercubic RNG.

Definition at line 438 of file random.C.

References AssignGenerator().

void cps::LatRanGen::AssignGenerator int  x,
int  y,
int  z,
int  t,
int  s = 0
 

Specifies which hypercube RNG to use.

For a given lattice site, this identifies and assigns the corresponding hypercube RNG.

Parameters:
x The x coordinate of the lattice site.
y The y coordinate of the lattice site.
z The z coordinate of the lattice site.
t The t coordinate of the lattice site.
s The s coordinate of the lattice site.
Postcondition:
Subsequent calls to e.g. Urand will return results from this particular hypercubic RNG.

Definition at line 409 of file random.C.

References cps::GJP, cps::GlobalJobParameter::SnodeSites(), cps::GlobalJobParameter::TnodeSites(), cps::GlobalJobParameter::XnodeSites(), cps::GlobalJobParameter::YnodeSites(), and cps::GlobalJobParameter::ZnodeSites().

Referenced by AssignGenerator(), cps::Lattice::MetropolisAccept(), cps::QPropWRand::QPropWRand(), cps::Lattice::RandGaussAntiHermMatrix(), cps::Lattice::RandGaussVector(), cps::AlgRandomGauge::run(), cps::AlgOverRelax::run(), cps::AlgNoise::run(), cps::AlgGheatBath::run(), and cps::Lattice::SetGfieldDisOrd().

void cps::LatRanGen::GetState unsigned int *  state,
FermionFieldDimension  frm_dim = FIVE_D
const
 

Retrieve the state of a single RNG.

Precondition:
A RNG must be assigned using ::AssignGenerator. state must point to an array of unsigned ints (at least) as long as the value returned by ::StateSize.
Parameters:
state The state to be copied from the RNG.
frm_dim If FIVE_D, the default, refers to the normal RNG. If FOUR_D then the special RNG four gauge fields with domain-wall fermions is used.

Definition at line 508 of file random.C.

References cps::UGrandomGenerator::StoreSeeds().

void cps::LatRanGen::GetStates unsigned int **  s,
FermionFieldDimension  frm_dim = FIVE_D
const
 

Retrieve the state of all RNGs.

Precondition:
s must point to a 2-d array with lengths given by ::NStates and ::StateSize.
Parameters:
s The state to be copied from the RNGs on the entire local lattice.
frm_dim If FIVE_D, the default, refers to the normal RNG. If FOUR_D then the special RNG four gauge fields with domain-wall fermions is used.

Definition at line 562 of file random.C.

References cps::UGrandomGenerator::StoreSeeds().

Referenced by cps::LRGState::GetStates().

bool cps::LatRanGen::good  )  const [inline]
 

Definition at line 367 of file random.h.

IFloat cps::LatRanGen::Grand FermionFieldDimension  frm_dim = FOUR_D  ) 
 

Get a gaussian random number.

Precondition:
A RNG must be assigned using ::AssignGenerator.
Returns:
A gaussian random number for this hypercube.

Definition at line 360 of file random.C.

References cps::UGrandomGenerator::Grand(), and cps::IFloat.

Referenced by cps::QPropWRand::QPropWRand(), cps::Lattice::RandGaussAntiHermMatrix(), cps::Lattice::RandGaussVector(), and cps::AlgNoise::run().

void cps::LatRanGen::Initialize  ) 
 

Seeds the RNGs according to the method defined in GJP

Definition at line 161 of file random.C.

References cps::ERR, cps::Verbose::Func(), cps::Error::General(), cps::GJP, cps::Error::Pointer(), cps::RandomGenerator::Reset(), cps::SeedS(), cps::GlobalJobParameter::SnodeCoor(), cps::GlobalJobParameter::Snodes(), cps::GlobalJobParameter::SnodeSites(), cps::START_SEED, cps::START_SEED_FILE, cps::START_SEED_INPUT, cps::START_SEED_INPUT_NODE, cps::START_SEED_INPUT_UNIFORM, cps::START_SEED_UNIFORM, cps::GlobalJobParameter::StartSeedFilename(), cps::GlobalJobParameter::StartSeedKind(), cps::GlobalJobParameter::StartSeedValue(), cps::GlobalJobParameter::TnodeCoor(), cps::GlobalJobParameter::Tnodes(), cps::GlobalJobParameter::TnodeSites(), cps::GlobalJobParameter::VolNodeSites(), cps::VRB, cps::GlobalJobParameter::XnodeCoor(), cps::GlobalJobParameter::Xnodes(), cps::GlobalJobParameter::XnodeSites(), cps::GlobalJobParameter::YnodeCoor(), cps::GlobalJobParameter::Ynodes(), cps::GlobalJobParameter::YnodeSites(), cps::GlobalJobParameter::ZnodeCoor(), cps::GlobalJobParameter::Znodes(), and cps::GlobalJobParameter::ZnodeSites().

Referenced by cps::Lattice::Lattice().

IFloat cps::LatRanGen::Lrand  ) 
 

Get a uniform random number which is the same on all nodes.

Returns:
A uniform random number; one per node, the same on each node.

Definition at line 475 of file random.C.

References cps::Float, cps::GJP, cps::glb_sum_five(), cps::IFloat, cps::GlobalJobParameter::Snodes(), cps::GlobalJobParameter::Tnodes(), cps::UGrandomGenerator::Urand(), cps::GlobalJobParameter::Xnodes(), cps::GlobalJobParameter::Ynodes(), and cps::GlobalJobParameter::Znodes().

int cps::LatRanGen::NStates FermionFieldDimension  frm_dim = FIVE_D  )  const
 

Get the total number of states.

Returns:
The total number of RNG states on the local lattice.

Definition at line 535 of file random.C.

Referenced by cps::LRGState::LRGState(), cps::AlgHmcRHMC::~AlgHmcRHMC(), and cps::LRGState::~LRGState().

int cps::LatRanGen::parIO  )  const [inline]
 

Definition at line 365 of file random.h.

Referenced by Read(), and Write().

bool cps::LatRanGen::Read const char *  filename,
int  concur_io_num = 0
 

Save the RNGs to a file (due to multi-type class members, not only supports read/write on same platform).

Definition at line 573 of file random.C.

References cps::QioControl::good(), parIO(), cps::LatRngRead::read(), cps::QioControl::setLogDir(), cps::LatRngIO::setParallel(), and cps::LatRngIO::setSerial().

void cps::LatRanGen::SetInterval IFloat  high,
IFloat  low
 

Sets the interval over which the uniform distribution is defined.

The parameters are set for the RNGs on all hypercubes.

Parameters:
high the upper bound of the distribution range
low the lower bound of the distribution range

Definition at line 378 of file random.C.

Referenced by cps::m_rand(), cps::Lattice::MetropolisAccept(), cps::AlgGheatBath::NoCheckerBoardRun(), cps::AlgGheatBath::NodeCheckerBoardRun(), cps::QPropWRand::QPropWRand(), cps::AlgRandomGauge::run(), cps::AlgOverRelax::run(), cps::AlgNoise::run(), cps::AlgGheatBath::run(), cps::Lattice::SetGfieldDisOrd(), and cps::WspectQuark::WspectQuark().

void cps::LatRanGen::setLogDir const char *  LogDir  )  [inline]
 

Definition at line 375 of file random.h.

void cps::LatRanGen::setParallel  )  [inline]
 

Definition at line 354 of file random.h.

void cps::LatRanGen::setSerial  )  [inline]
 

Definition at line 356 of file random.h.

References cps::Verbose::Flow(), and cps::VRB.

void cps::LatRanGen::SetSigma IFloat  sigma  ) 
 

Sets the variance of the distribution.

The parameters are set for the RNGs on all hypercubes. The mean is zero.

Parameters:
sigma the variance of the gaussian distribution.

Definition at line 390 of file random.C.

Referenced by cps::QPropWRand::QPropWRand(), cps::Lattice::RandGaussAntiHermMatrix(), cps::Lattice::RandGaussVector(), and cps::AlgNoise::run().

void cps::LatRanGen::SetState const unsigned int *  s,
FermionFieldDimension  frm_dim = FIVE_D
 

Assign the state to a selected RNG.

Precondition:
A RNG must be assigned using ::AssignGenerator.

s must be an array with length given by ::StateSize.

Parameters:
s The state to assigned to the RNG on an assigned site.

Definition at line 521 of file random.C.

References cps::RandomGenerator::RestoreSeeds().

void cps::LatRanGen::SetStates unsigned int **  s,
FermionFieldDimension  frm_dim = FIVE_D
 

Assign the state of all RNGs.

Precondition:
s must point to a 2-d array with lengths given by ::NStates and ::StateSize.
Parameters:
s The state to assigned to the RNGs on the entire local lattice.
frm_dim If FIVE_D, the default, refers to the normal RNG. If FOUR_D then the special RNG four gauge fields with domain-wall fermions is used.

Definition at line 547 of file random.C.

References cps::RandomGenerator::RestoreSeeds().

Referenced by cps::LRGState::SetStates().

void cps::LatRanGen::Shift  ) 
 

Definition at line 597 of file random.C.

References cps::GDS, and cps::GlobalDataShift::Shift().

Referenced by cps::AlgHmcRHMC::run().

int cps::LatRanGen::StateSize  )  const
 

Size of the RNG state (per hypercube).

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

Definition at line 493 of file random.C.

References cps::RandomGenerator::StateSize().

Referenced by cps::LRGState::LRGState().

IFloat cps::LatRanGen::Urand Float  high,
Float  low,
FermionFieldDimension  frm_dim = FOUR_D
 

Definition at line 345 of file random.C.

References cps::IFloat, and cps::UGrandomGenerator::Urand().

IFloat cps::LatRanGen::Urand FermionFieldDimension  frm_dim = FOUR_D  ) 
 

Get a uniform random number.

Precondition:
A RNG must be assigned using ::AssignGenerator.
Returns:
A uniform random number for this hypercube.

Definition at line 336 of file random.C.

References cps::IFloat, and cps::UGrandomGenerator::Urand().

Referenced by cps::cmhb_kernel(), cps::m_rand(), cps::metropolis_kernel(), cps::Lattice::MetropolisAccept(), cps::QPropWRand::QPropWRand(), cps::AlgRandomGauge::run(), cps::AlgNoise::run(), cps::Lattice::SetGfieldDisOrd(), and cps::WspectQuark::WspectQuark().

bool cps::LatRanGen::Write const char *  filename,
int  concur_io_num = 0
 

Definition at line 585 of file random.C.

References cps::QioControl::good(), parIO(), cps::Verbose::Result(), cps::QioControl::setLogDir(), cps::LatRngIO::setParallel(), cps::LatRngIO::setSerial(), cps::VRB, and cps::LatRngWrite::write().


The documentation for this class was generated from the following files:
Generated on Sat Oct 10 14:12:14 2009 for Columbia Physics System by  doxygen 1.3.9.1