StuBS
Random Class Reference

#include <utils/random.h>

Public Member Functions

 Random (uint32_t seed)
 Constructor.
 
uint32_t number ()
 Get the next (pseudo)random number.
 

Private Attributes

uint32_t mt [N]
 
uint16_t index
 

Static Private Attributes

static const uint32_t N = 624
 
static const uint32_t M = 397
 
static const uint32_t R = 31
 
static const uint32_t A = 0x9908B0DF
 
static const uint32_t F = 1812433253
 
static const uint32_t U = 11
 
static const uint32_t S = 7
 
static const uint32_t B = 0x9D2C5680
 
static const uint32_t T = 15
 
static const uint32_t C = 0xEFC60000
 
static const uint32_t L = 18
 
static const uint32_t MASK_LOWER = (1UL << R) - 1
 
static const uint32_t MASK_UPPER = (1UL << R)
 

Detailed Description

Mersenne Twister (32 bit pseudorandom number generator)

See also
Wikipedia

Constructor & Destructor Documentation

◆ Random()

Random::Random ( uint32_t  seed)
explicit

Constructor.

Parameters
seedinitial value (seed) for the pseudorandom number generator.

Member Function Documentation

◆ number()

uint32_t Random::number ( )

Get the next (pseudo)random number.

Returns
some number

Member Data Documentation

◆ N

const uint32_t Random::N = 624
staticprivate

◆ M

const uint32_t Random::M = 397
staticprivate

◆ R

const uint32_t Random::R = 31
staticprivate

◆ A

const uint32_t Random::A = 0x9908B0DF
staticprivate

◆ F

const uint32_t Random::F = 1812433253
staticprivate

◆ U

const uint32_t Random::U = 11
staticprivate

◆ S

const uint32_t Random::S = 7
staticprivate

◆ B

const uint32_t Random::B = 0x9D2C5680
staticprivate

◆ T

const uint32_t Random::T = 15
staticprivate

◆ C

const uint32_t Random::C = 0xEFC60000
staticprivate

◆ L

const uint32_t Random::L = 18
staticprivate

◆ MASK_LOWER

const uint32_t Random::MASK_LOWER = (1UL << R) - 1
staticprivate

◆ MASK_UPPER

const uint32_t Random::MASK_UPPER = (1UL << R)
staticprivate

◆ mt

uint32_t Random::mt[N]
private

◆ index

uint16_t Random::index
private

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