|
PSCF v1.4.0
|
Random number generator for arrays of random numbers on CPU. More...
#include <CpuVecRandom.h>
Public Member Functions | |
| CpuVecRandom () | |
| Default constructor. | |
| CpuVecRandom (Util::Random &random) | |
| Constructor - creates association with a scalar RNG. | |
| virtual | ~CpuVecRandom () |
| Destructor. | |
| void | associate (Util::Random &random) |
| Create an association with a Util::Random scalar RNG. | |
| void | uniform (Array< double > &data) |
| Generate uniform random doubles in (0, 1]. | |
| void | uniform (Array< double > &data, double min, double max) |
| Generate uniform random distribution in range (min, max]. | |
| void | normal (Array< double > &data, double stddev, double mean=0.0) |
| Generate normal-distributed random doubles. | |
Random number generator for arrays of random numbers on CPU.
A CpuVecRandom generates arrays of random real numbers on a CPU. It uses an associated Util::Random scalar random number generator to generate these random numbers.
CpuVecRandom has an interface that is analogous to that of the CudaVecRandom class, which uses a GPU to generates arrays of random numbers in global GPU memory. This similarity is intended to allow creation of template code that can use either type of vector random number object interchangably for use in analogous programs that run on CPU or GPU-accelerated hardware.
Definition at line 37 of file CpuVecRandom.h.
| Pscf::CpuVecRandom::CpuVecRandom | ( | ) |
Default constructor.
Definition at line 13 of file CpuVecRandom.cpp.
| Pscf::CpuVecRandom::CpuVecRandom | ( | Util::Random & | random | ) |
Constructor - creates association with a scalar RNG.
| random | associated scalar random number generator (RNG) |
Definition at line 20 of file CpuVecRandom.cpp.
|
virtual |
Destructor.
Definition at line 27 of file CpuVecRandom.cpp.
| void Pscf::CpuVecRandom::associate | ( | Util::Random & | random | ) |
Create an association with a Util::Random scalar RNG.
| random | associated scalar random number generator |
Definition at line 33 of file CpuVecRandom.cpp.
| void Pscf::CpuVecRandom::uniform | ( | Array< double > & | data | ) |
Generate uniform random doubles in (0, 1].
| data | array to populate |
Definition at line 39 of file CpuVecRandom.cpp.
References Util::Array< Data >::capacity(), and UTIL_CHECK.
| void Pscf::CpuVecRandom::uniform | ( | Array< double > & | data, |
| double | min, | ||
| double | max ) |
Generate uniform random distribution in range (min, max].
| data | array to populate with random numbers |
| min | minimum of range |
| max | maximum of range |
Definition at line 52 of file CpuVecRandom.cpp.
References Util::Array< Data >::capacity(), and UTIL_CHECK.
| void Pscf::CpuVecRandom::normal | ( | Array< double > & | data, |
| double | stddev, | ||
| double | mean = 0.0 ) |
Generate normal-distributed random doubles.
| data | array to populate |
| stddev | standard deviation (input) |
| mean | mean value (input, default = 0.0) |
Definition at line 66 of file CpuVecRandom.cpp.
References Util::Array< Data >::capacity(), and UTIL_CHECK.