SUMO - Simulation of Urban MObility
MTRand Class Reference

#include <MersenneTwister.h>

Collaboration diagram for MTRand:
Collaboration graph

Public Types

enum  { N = 624 }
 
enum  { SAVE = N + 1 }
 
typedef unsigned long uint32
 
typedef unsigned long long int uint64
 

Public Member Functions

void load (uint32 *const loadArray)
 
 MTRand (const uint32 &oneSeed)
 
 MTRand (uint32 *const bigSeed, uint32 const seedLength=N)
 
 MTRand ()
 
double operator() ()
 
double rand ()
 
double rand (const double &n)
 
double rand53 ()
 
double randDblExc ()
 
double randDblExc (const double &n)
 
double randExc ()
 
double randExc (const double &n)
 
uint32 randInt ()
 
uint32 randInt (const uint32 &n)
 
uint64 randInt64 (const uint64 &n)
 
double randNorm (const double &mean=0.0, const double &variance=0.0)
 
void save (uint32 *saveArray) const
 
void seed (const uint32 oneSeed)
 
void seed (uint32 *const bigSeed, const uint32 seedLength=N)
 
void seed ()
 

Static Public Member Functions

static uint32 hash (time_t t, clock_t c)
 

Protected Types

enum  { M = 397 }
 

Protected Member Functions

uint32 hiBit (const uint32 &u) const
 
void initialize (const uint32 oneSeed)
 
uint32 loBits (const uint32 &u) const
 
uint32 mixBits (const uint32 &u, const uint32 &v) const
 
void reload ()
 
uint32 twist (const uint32 &m, const uint32 &s0, const uint32 &s1) const
 

Protected Attributes

int left
 
uint32pNext
 
uint32 state [N]
 

Friends

std::ostream & operator<< (std::ostream &os, const MTRand &mtrand)
 
std::istream & operator>> (std::istream &is, MTRand &mtrand)
 

Detailed Description

Definition at line 75 of file MersenneTwister.h.

Member Typedef Documentation

◆ uint32

typedef unsigned long MTRand::uint32

Definition at line 78 of file MersenneTwister.h.

◆ uint64

typedef unsigned long long int MTRand::uint64

Definition at line 79 of file MersenneTwister.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 81 of file MersenneTwister.h.

◆ anonymous enum

anonymous enum
Enumerator
SAVE 

Definition at line 82 of file MersenneTwister.h.

◆ anonymous enum

anonymous enum
protected
Enumerator

Definition at line 85 of file MersenneTwister.h.

Constructor & Destructor Documentation

◆ MTRand() [1/3]

MTRand::MTRand ( const uint32 oneSeed)
inline

Definition at line 147 of file MersenneTwister.h.

References seed().

◆ MTRand() [2/3]

MTRand::MTRand ( uint32 *const  bigSeed,
uint32 const  seedLength = N 
)
inline

Definition at line 150 of file MersenneTwister.h.

References seed().

◆ MTRand() [3/3]

MTRand::MTRand ( )
inline

Definition at line 153 of file MersenneTwister.h.

References seed().

Member Function Documentation

◆ hash()

MTRand::uint32 MTRand::hash ( time_t  t,
clock_t  c 
)
inlinestatic

Definition at line 352 of file MersenneTwister.h.

Referenced by RandHelper::initRandGlobal(), operator()(), and seed().

◆ hiBit()

uint32 MTRand::hiBit ( const uint32 u) const
inlineprotected

Definition at line 137 of file MersenneTwister.h.

Referenced by mixBits().

◆ initialize()

void MTRand::initialize ( const uint32  oneSeed)
inlineprotected

Definition at line 318 of file MersenneTwister.h.

References N, and state.

Referenced by operator()(), and seed().

◆ load()

void MTRand::load ( uint32 *const  loadArray)
inline

Definition at line 388 of file MersenneTwister.h.

References left, N, pNext, and state.

Referenced by operator()().

◆ loBits()

uint32 MTRand::loBits ( const uint32 u) const
inlineprotected

Definition at line 138 of file MersenneTwister.h.

Referenced by mixBits().

◆ mixBits()

uint32 MTRand::mixBits ( const uint32 u,
const uint32 v 
) const
inlineprotected

Definition at line 139 of file MersenneTwister.h.

References hiBit(), and loBits().

Referenced by twist().

◆ operator()()

double MTRand::operator() ( )
inline

◆ rand() [1/2]

◆ rand() [2/2]

double MTRand::rand ( const double &  n)
inline

Definition at line 159 of file MersenneTwister.h.

References rand().

◆ rand53()

double MTRand::rand53 ( )
inline

Definition at line 174 of file MersenneTwister.h.

References randInt().

Referenced by operator()().

◆ randDblExc() [1/2]

double MTRand::randDblExc ( )
inline

Definition at line 168 of file MersenneTwister.h.

References randInt().

Referenced by randDblExc(), and randNorm().

◆ randDblExc() [2/2]

double MTRand::randDblExc ( const double &  n)
inline

Definition at line 171 of file MersenneTwister.h.

References randDblExc().

◆ randExc() [1/2]

double MTRand::randExc ( )
inline

Definition at line 162 of file MersenneTwister.h.

References randInt().

Referenced by RandHelper::rand(), randExc(), RandHelper::randNorm(), and randNorm().

◆ randExc() [2/2]

double MTRand::randExc ( const double &  n)
inline

Definition at line 165 of file MersenneTwister.h.

References randExc().

◆ randInt() [1/2]

MTRand::uint32 MTRand::randInt ( )
inline

◆ randInt() [2/2]

MTRand::uint32 MTRand::randInt ( const uint32 n)
inline

Definition at line 205 of file MersenneTwister.h.

References randInt().

◆ randInt64()

MTRand::uint64 MTRand::randInt64 ( const uint64 n)
inline

Definition at line 225 of file MersenneTwister.h.

References randInt().

Referenced by RandHelper::rand().

◆ randNorm()

double MTRand::randNorm ( const double &  mean = 0.0,
const double &  variance = 0.0 
)
inline

Definition at line 180 of file MersenneTwister.h.

References randDblExc(), and randExc().

Referenced by operator()(), and Distribution_Parameterized::sample().

◆ reload()

void MTRand::reload ( )
inlineprotected

Definition at line 336 of file MersenneTwister.h.

References left, M, N, pNext, state, and twist().

Referenced by operator()(), randInt(), and seed().

◆ save()

void MTRand::save ( uint32 saveArray) const
inline

Definition at line 378 of file MersenneTwister.h.

References left, N, and state.

Referenced by operator()().

◆ seed() [1/3]

void MTRand::seed ( const uint32  oneSeed)
inline

◆ seed() [2/3]

void MTRand::seed ( uint32 *const  bigSeed,
const uint32  seedLength = N 
)
inline

Definition at line 257 of file MersenneTwister.h.

References initialize(), N, reload(), and state.

◆ seed() [3/3]

void MTRand::seed ( )
inline

Definition at line 294 of file MersenneTwister.h.

References hash(), and N.

Referenced by MTRand(), and operator()().

◆ twist()

uint32 MTRand::twist ( const uint32 m,
const uint32 s0,
const uint32 s1 
) const
inlineprotected

Definition at line 141 of file MersenneTwister.h.

References mixBits().

Referenced by reload().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const MTRand mtrand 
)
friend

Definition at line 399 of file MersenneTwister.h.

Referenced by operator()().

◆ operator>>

std::istream& operator>> ( std::istream &  is,
MTRand mtrand 
)
friend

Definition at line 408 of file MersenneTwister.h.

Referenced by operator()().

Field Documentation

◆ left

int MTRand::left
protected

Definition at line 89 of file MersenneTwister.h.

Referenced by load(), operator<<(), operator>>(), randInt(), reload(), and save().

◆ pNext

uint32* MTRand::pNext
protected

Definition at line 88 of file MersenneTwister.h.

Referenced by load(), operator>>(), randInt(), and reload().

◆ state

uint32 MTRand::state[N]
protected

Definition at line 87 of file MersenneTwister.h.

Referenced by initialize(), load(), operator<<(), operator>>(), reload(), save(), and seed().


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