16 isInitialized_(false),
78 gettimeofday(&time, NULL);
79 temp = time.tv_sec + 1123*time.tv_usec;
81 if (MPI::Is_initialized()) {
82 SeedType rank = MPI::COMM_WORLD.Get_rank();
83 temp += rank*(31 + time.tv_usec);
90 isInitialized_ =
true;
102 if (hasGaussian_ ==
false) {
112 double fac = sqrt(-2.0*log(rsq)/rsq);
118 hasGaussian_ =
false;
128 double ran1=0, ran2=0, ranh;
132 while (ransq >= 1.0) {
133 ran1 = 1.0-2.0*
uniform(0.0, 1.0);
134 ran2 = 1.0-2.0*
uniform(0.0, 1.0);
135 ransq = ran1*ran1 + ran2*ran2;
137 ranh= 2.0*sqrt(1.0-ransq);
140 v[2] = 1.0 - 2.0*ransq;
ScalarParam< Type > & read(std::istream &in, const char *label, Type &value)
Add and read a new required ScalarParam < Type > object.
void setClassName(const char *className)
Set class name string.
ScalarParam< Type > & loadParameter(Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
Add and load a new ScalarParam < Type > object.
void setSeed(SeedType seed)
Sets of random seed, and initializes random number generator.
virtual void readParameters(std::istream &in)
Read seed from file, initialize RNG.
virtual void loadParameters(Serializable::IArchive &ar)
Load internal state from file.
virtual ~Random()
Destructor.
void unitVector(Vector &v)
Generate unit vector with uniform probability over the unit sphere.
double uniform()
Return a random floating point number x, uniformly distributed in the range 0 <= x < 1.
double gaussian(void)
Return a Gaussian random number with zero average and unit variance.
long seed()
Returns value of random seed (private member variable seed_).
virtual void save(Serializable::OArchive &ar)
Save internal state to file.
BinaryFileIArchive IArchive
Type of input archive used by load method.
BinaryFileOArchive OArchive
Type of output archive used by save method.
A Vector is a Cartesian vector.
Utility classes for scientific computation.