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

typedef unsigned long MTRand::uint32

Definition at line 78 of file MersenneTwister.h.

typedef unsigned long long int MTRand::uint64

Definition at line 79 of file MersenneTwister.h.

Member Enumeration Documentation

anonymous enum
Enumerator

Definition at line 81 of file MersenneTwister.h.

anonymous enum
Enumerator
SAVE 

Definition at line 82 of file MersenneTwister.h.

anonymous enum
protected
Enumerator

Definition at line 85 of file MersenneTwister.h.

Constructor & Destructor Documentation

MTRand::MTRand ( const uint32 oneSeed)
inline

Definition at line 147 of file MersenneTwister.h.

References seed().

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

Definition at line 150 of file MersenneTwister.h.

References seed().

MTRand::MTRand ( )
inline

Definition at line 153 of file MersenneTwister.h.

References seed().

Member Function Documentation

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

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

Definition at line 137 of file MersenneTwister.h.

Referenced by mixBits().

void MTRand::initialize ( const uint32  oneSeed)
inlineprotected

Definition at line 318 of file MersenneTwister.h.

References N, and state.

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

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

Definition at line 388 of file MersenneTwister.h.

References left, N, pNext, and state.

Referenced by operator()().

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

Definition at line 138 of file MersenneTwister.h.

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

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

Definition at line 159 of file MersenneTwister.h.

References rand().

double MTRand::rand53 ( )
inline

Definition at line 174 of file MersenneTwister.h.

References randInt().

Referenced by operator()().

double MTRand::randDblExc ( )
inline

Definition at line 168 of file MersenneTwister.h.

References randInt().

Referenced by randDblExc(), and randNorm().

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

Definition at line 171 of file MersenneTwister.h.

References randDblExc().

double MTRand::randExc ( )
inline

Definition at line 162 of file MersenneTwister.h.

References randInt().

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

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

Definition at line 165 of file MersenneTwister.h.

References randExc().

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

Definition at line 205 of file MersenneTwister.h.

References randInt().

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

Definition at line 225 of file MersenneTwister.h.

References randInt().

Referenced by RandHelper::rand().

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

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

void MTRand::save ( uint32 saveArray) const
inline

Definition at line 378 of file MersenneTwister.h.

References left, N, and state.

Referenced by operator()().

void MTRand::seed ( const uint32  oneSeed)
inline
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.

void MTRand::seed ( )
inline

Definition at line 294 of file MersenneTwister.h.

References hash(), and N.

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

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

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

Definition at line 399 of file MersenneTwister.h.

Referenced by operator()().

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

Definition at line 408 of file MersenneTwister.h.

Referenced by operator()().

Field Documentation

int MTRand::left
protected

Definition at line 89 of file MersenneTwister.h.

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

uint32* MTRand::pNext
protected

Definition at line 88 of file MersenneTwister.h.

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

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: