Essentia  2.1-beta6-dev
MTRand Class Reference

#include <MersenneTwister.h>

Public Types

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

Public Member Functions

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

Protected Types

enum  { M = 397 }
 

Protected Member Functions

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

Static Protected Member Functions

static uint32 hash (time_t t, clock_t c)
 

Protected Attributes

uint32 state [N]
 
uint32pNext
 
int left
 

Friends

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

Member Typedef Documentation

◆ uint32

typedef unsigned long uint32

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator

◆ anonymous enum

anonymous enum
Enumerator
SAVE 

◆ anonymous enum

anonymous enum
protected
Enumerator

Constructor & Destructor Documentation

◆ MTRand() [1/3]

MTRand ( const uint32 oneSeed)
inline

References seed().

◆ MTRand() [2/3]

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

References seed().

◆ MTRand() [3/3]

MTRand ( )
inline

References seed().

Member Function Documentation

◆ hash()

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

Referenced by seed().

◆ hiBit()

uint32 hiBit ( const uint32 u) const
inlineprotected

Referenced by mixBits().

◆ initialize()

void initialize ( const uint32  oneSeed)
inlineprotected

References N, seed(), and state.

Referenced by seed().

◆ load()

void load ( uint32 *const  loadArray)
inline

References left, N, pNext, and state.

◆ loBit()

uint32 loBit ( const uint32 u) const
inlineprotected

Referenced by twist().

◆ loBits()

uint32 loBits ( const uint32 u) const
inlineprotected

Referenced by mixBits().

◆ mixBits()

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

References hiBit(), and loBits().

Referenced by twist().

◆ operator()()

double operator() ( )
inline

References rand().

◆ rand() [1/2]

double rand ( )
inline

References randInt().

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

◆ rand() [2/2]

double rand ( const double &  n)
inline

References rand().

◆ rand53()

double rand53 ( )
inline

References randInt().

◆ randDblExc() [1/2]

double randDblExc ( )
inline

References randInt().

Referenced by randDblExc(), and randNorm().

◆ randDblExc() [2/2]

double randDblExc ( const double &  n)
inline

References randDblExc().

◆ randExc() [1/2]

double randExc ( )
inline

References randInt().

Referenced by randExc(), and randNorm().

◆ randExc() [2/2]

double randExc ( const double &  n)
inline

References randExc().

◆ randInt() [1/2]

MTRand::uint32 randInt ( )
inline

References left, pNext, and reload().

Referenced by rand(), rand53(), randDblExc(), randExc(), and randInt().

◆ randInt() [2/2]

MTRand::uint32 randInt ( const uint32 n)
inline

References randInt().

◆ randNorm()

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

◆ reload()

void reload ( )
inlineprotected

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

Referenced by randInt(), and seed().

◆ save()

void save ( uint32 saveArray) const
inline

References left, N, and state.

◆ seed() [1/3]

void seed ( )
inline

References hash(), N, and NULL.

Referenced by initialize(), and MTRand().

◆ seed() [2/3]

void seed ( const uint32  oneSeed)
inline

References initialize(), and reload().

◆ seed() [3/3]

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

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

◆ twist()

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

References loBit(), and mixBits().

Referenced by reload().

Friends And Related Function Documentation

◆ operator<<

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

◆ operator>>

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

Member Data Documentation

◆ left

int left
protected

Referenced by load(), randInt(), reload(), and save().

◆ pNext

uint32* pNext
protected

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

◆ state

uint32 state[N]
protected

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


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