SST
14.1.0
StructuralSimulationToolkit
|
Implements a random number generator using the Marsaglia method. More...
#include "sst/core/rng/marsaglia.h"
Public Member Functions | |
MarsagliaRNG (unsigned int initial_z, unsigned int initial_w) | |
Creates a new Marsaglia RNG using the initial seeds. More... | |
MarsagliaRNG () | |
Creates a new Marsaglia RNG using random initial seeds (which are read from the system clock). More... | |
void | restart (unsigned int new_z, unsigned int new_w) |
Restart the random number generator with new seeds. More... | |
double | nextUniform () override |
Generates the next random number as a double in the range 0 to 1. | |
uint32_t | generateNextUInt32 () override |
Generates the next random number as an unsigned 32-bit integer. | |
uint64_t | generateNextUInt64 () override |
Generates the next random number as an unsigned 64-bit integer. | |
int64_t | generateNextInt64 () override |
Generates the next number as a signed 64-bit integer. | |
int32_t | generateNextInt32 () override |
Generates the next number as a signed 32-bit integer. | |
void | seed (uint64_t newSeed) |
Seed the XOR RNG. | |
void | serialize_order (SST::Core::Serialization::serializer &ser) override |
Serialization function for checkpoint. | |
Public Member Functions inherited from SST::RNG::Random | |
virtual | ~Random () |
Destroys the random number generator. | |
virtual void | serialize_order (SST::Core::Serialization::serializer &UNUSED(ser)) override |
Public Member Functions inherited from SST::Core::Serialization::serializable_base | |
virtual const char * | cls_name () const =0 |
virtual uint32_t | cls_id () const =0 |
virtual std::string | serialization_name () const =0 |
Data Fields | |
ImplementSerializable(SST::RNG::MarsagliaRNG) private unsigned int | m_z |
Serialization macro. More... | |
unsigned int | m_w |
The W seed of the Marsaglia generator. | |
Additional Inherited Members | |
Static Public Attributes inherited from SST::Core::Serialization::serializable | |
static constexpr uint32_t | NullClsId = std::numeric_limits<uint32_t>::max() |
Static Public Attributes inherited from SST::Core::Serialization::serializable_base | |
static constexpr uint32_t | NullClsId = std::numeric_limits<uint32_t>::max() |
Protected Types inherited from SST::Core::Serialization::serializable_base | |
enum | cxn_flag_t { ConstructorFlag } |
Static Protected Member Functions inherited from SST::Core::Serialization::serializable_base | |
static void | serializable_abort (uint32_t line, const char *file, const char *func, const char *obj) |
Implements a random number generator using the Marsaglia method.
This method is computationally cheap and provides a reasonable distribution of random numbers. If you need additional strength in the random numbers you may want to consider the Mersenne RNG.
For more information see the Multiply-with-carry Random Number Generator article
at Wikipedia (http://en.wikipedia.org/wiki/Multiply-with-carry).
MarsagliaRNG::MarsagliaRNG | ( | unsigned int | initial_z, |
unsigned int | initial_w | ||
) |
MarsagliaRNG::MarsagliaRNG | ( | ) |
void MarsagliaRNG::restart | ( | unsigned int | new_z, |
unsigned int | new_w | ||
) |
ImplementSerializable (SST::RNG::MarsagliaRNG) private unsigned int SST::RNG::MarsagliaRNG::m_z |
Serialization macro.
Generates the next random number The Z seed of the Marsaglia generator
Referenced by MarsagliaRNG(), restart(), seed(), and serialize_order().