#include <NOX_Random.H>
Public Member Functions | |
Random () | |
Initialize random number generator with a random seed. | |
Random (int s) | |
Initialize random number generator with the given seed. | |
Static Public Member Functions | |
static void | setSeed (int s) |
Set the seed to s. | |
static double | number () |
Compute a random number. | |
Static Protected Member Functions | |
static int | checkSeed (const string &func, int s) |
Checks that the supplied seed value is valid and returns a valid seed. | |
Static Protected Attributes | |
static double | seed = 1.0 |
Seed value. |
The Random class computes pseudo-random (double precision) numbers uniformly distributed between -1.0 and 1.0 using a multiplicative congruential generator with modulus 2^31-1 (a Lehmer generator). For a numerical and mathematical treatment of the algorithm, see "Random number generators: good ones are hard to find" by Stephen K. Park and Keith W. Miller, Communications of the ACM, Vol. 31 No. 10 (1988).
Definition at line 61 of file NOX_Random.H.
NOX::Random::Random | ( | ) |
Initialize random number generator with a random seed.
The random seed is computed using the POSIX rand() function.
Definition at line 47 of file NOX_Random.C.
References seed.
NOX::Random::Random | ( | int | s | ) |
Initialize random number generator with the given seed.
The seed should be an integer between 1 and 2147483646 = 2^32-2 (inclusive). If the supplied seed is invalid, an error message is printed and the seed is replaced by 1.
Definition at line 56 of file NOX_Random.C.
References setSeed().
void NOX::Random::setSeed | ( | int | s | ) | [static] |
Set the seed to s.
The seed should be an integer between 1 and 2147483646 = 2^32-2 (inclusive). If the supplied seed is invalid, an error message is printed and the seed is replaced by 1.
Definition at line 61 of file NOX_Random.C.
References checkSeed(), and seed.
Referenced by Random(), NOX::LAPACK::Vector::random(), and LOCA::Extended::Vector::random().
double NOX::Random::number | ( | ) | [static] |
Compute a random number.
Definition at line 68 of file NOX_Random.C.
References seed.
Referenced by NOX::LAPACK::Vector::random().
int NOX::Random::checkSeed | ( | const string & | func, | |
int | s | |||
) | [static, protected] |
Checks that the supplied seed value is valid and returns a valid seed.
The string argument supplies the calling function name for an error message in the case that the supplied seed is invalid.
Definition at line 77 of file NOX_Random.C.
Referenced by setSeed().
double NOX::Random::seed = 1.0 [static, protected] |