SST 12.1.0
Structural Simulation Toolkit
SST::RNG::XORShiftRNG Class Reference

Implements a lightweight RNG based on XOR-shift operations. More...

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

Inheritance diagram for SST::RNG::XORShiftRNG:
SST::RNG::Random

Public Member Functions

 XORShiftRNG (unsigned int seed)
 Create a new Mersenne RNG with a specified seed. More...
 
 XORShiftRNG ()
 Creates a new Mersenne using a random seed which is obtained from the system clock. More...
 
double nextUniform () override
 Generates the next random number as a double value between 0 and 1. More...
 
uint32_t generateNextUInt32 () override
 Generates the next random number as an unsigned 32-bit integer. More...
 
uint64_t generateNextUInt64 () override
 Generates the next random number as an unsigned 64-bit integer. More...
 
int64_t generateNextInt64 () override
 Generates the next random number as a signed 64-bit integer. More...
 
int32_t generateNextInt32 () override
 Generates the next random number as a signed 32-bit integer. More...
 
void seed (uint64_t newSeed)
 Seed the XOR RNG.
 
 ~XORShiftRNG ()
 Destructor for Mersenne.
 
- Public Member Functions inherited from SST::RNG::Random
virtual double nextUniform ()=0
 Generates the next random number in the range [0,1). More...
 
virtual uint32_t generateNextUInt32 ()=0
 Generates the next random number as an unsigned 32-bit integer. More...
 
virtual uint64_t generateNextUInt64 ()=0
 Generates the next random number as an unsigned 64-bit integer. More...
 
virtual int64_t generateNextInt64 ()=0
 Generates the next random number as a signed 64-bit integer. More...
 
virtual int32_t generateNextInt32 ()=0
 Generates the next random number as a signed 32-bit integer. More...
 
virtual ~Random ()
 Destroys the random number generator.
 

Protected Attributes

uint32_t x
 
uint32_t y
 
uint32_t z
 
uint32_t w
 

Detailed Description

Implements a lightweight RNG based on XOR-shift operations.

We utilize the XORSHIFT algorithm from: http://en.wikipedia.org/wiki/Xorshift. This is a very lightweight and inexpensive RNG.

Constructor & Destructor Documentation

◆ XORShiftRNG() [1/2]

XORShiftRNG::XORShiftRNG ( unsigned int  seed)

Create a new Mersenne RNG with a specified seed.

Parameters
[in]seedThe seed for this RNG

References seed().

◆ XORShiftRNG() [2/2]

XORShiftRNG::XORShiftRNG ( )

Creates a new Mersenne using a random seed which is obtained from the system clock.

Note this will give different results on different platforms and between runs.

Member Function Documentation

◆ generateNextInt32()

int32_t XORShiftRNG::generateNextInt32 ( )
overridevirtual

Generates the next random number as a signed 32-bit integer.

Implements SST::RNG::Random.

References generateNextUInt32().

◆ generateNextInt64()

int64_t XORShiftRNG::generateNextInt64 ( )
overridevirtual

Generates the next random number as a signed 64-bit integer.

Implements SST::RNG::Random.

References generateNextUInt32().

Referenced by generateNextUInt64().

◆ generateNextUInt32()

uint32_t XORShiftRNG::generateNextUInt32 ( )
overridevirtual

Generates the next random number as an unsigned 32-bit integer.

Implements SST::RNG::Random.

Referenced by generateNextInt32(), generateNextInt64(), and nextUniform().

◆ generateNextUInt64()

uint64_t XORShiftRNG::generateNextUInt64 ( )
overridevirtual

Generates the next random number as an unsigned 64-bit integer.

Implements SST::RNG::Random.

References generateNextInt64().

◆ nextUniform()

double XORShiftRNG::nextUniform ( )
overridevirtual

Generates the next random number as a double value between 0 and 1.

Implements SST::RNG::Random.

References generateNextUInt32().


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