SST  14.0.0
StructuralSimulationToolkit
SST::RNG::MarsagliaRNG Class Reference

Implements a random number generator using the Marsaglia method. More...

#include "sst/core/rng/marsaglia.h"

Inheritance diagram for SST::RNG::MarsagliaRNG:
SST::RNG::Random SST::Core::Serialization::serializable

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
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()
 
- Protected Types inherited from SST::Core::Serialization::serializable
enum  cxn_flag_t { ConstructorFlag }
 
- Static Protected Member Functions inherited from SST::Core::Serialization::serializable
static void serializable_abort (uint32_t line, const char *file, const char *func, const char *obj)
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ MarsagliaRNG() [1/2]

MarsagliaRNG::MarsagliaRNG ( unsigned int  initial_z,
unsigned int  initial_w 
)

Creates a new Marsaglia RNG using the initial seeds.

Parameters
[in]initial_zOne of the random seed pairs
[in]initial_wOne of the random seed pairs.

References m_w, and m_z.

◆ MarsagliaRNG() [2/2]

MarsagliaRNG::MarsagliaRNG ( )

Creates a new Marsaglia RNG using random initial seeds (which are read from the system clock).

Note that these will create variation between runs and between platforms.

References m_w, and m_z.

Member Function Documentation

◆ restart()

void MarsagliaRNG::restart ( unsigned int  new_z,
unsigned int  new_w 
)

Restart the random number generator with new seeds.

Parameters
[in]new_zA new Z-seed
[in]new_wA new W-seed

References m_w, and m_z.

Field Documentation

◆ m_z

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().


The documentation for this class was generated from the following files: