Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
vl::MersenneTwister Class Reference

#include <MersenneTwister.hpp>

+ Inheritance diagram for vl::MersenneTwister:

Public Types

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

Public Member Functions

 MersenneTwister (const uint32 oneSeed)
 
 MersenneTwister (uint32 *const bigSeed, uint32 const seedLength=N)
 
 MersenneTwister ()
 
 MersenneTwister (const MersenneTwister &o)
 
uint32 randInt ()
 
uint32 randInt (const uint32 n)
 
double rand ()
 
double rand (const double n)
 
double randExc ()
 
double randExc (const double n)
 
double randDblExc ()
 
double randDblExc (const double n)
 
double operator() ()
 
double rand53 ()
 
double randNorm (const double mean=0.0, const double stddev=1.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)
 
MersenneTwisteroperator= (const MersenneTwister &o)
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

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 magic (const uint32 u) const
 
uint32 twist (const uint32 m, const uint32 s0, const uint32 s1) const
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Static Protected Member Functions

static uint32 hash (time_t t, clock_t c)
 

Protected Attributes

uint32 state [N]
 
uint32pNext
 
int left
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Friends

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

Detailed Description

Definition at line 86 of file MersenneTwister.hpp.

Member Typedef Documentation

◆ uint32

typedef unsigned long vl::MersenneTwister::uint32

Definition at line 90 of file MersenneTwister.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator

Definition at line 92 of file MersenneTwister.hpp.

◆ anonymous enum

anonymous enum
Enumerator
SAVE 

Definition at line 93 of file MersenneTwister.hpp.

◆ anonymous enum

anonymous enum
protected
Enumerator

Definition at line 96 of file MersenneTwister.hpp.

Constructor & Destructor Documentation

◆ MersenneTwister() [1/4]

vl::MersenneTwister::MersenneTwister ( const uint32  oneSeed)
inline

Definition at line 282 of file MersenneTwister.hpp.

References seed().

◆ MersenneTwister() [2/4]

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

Definition at line 285 of file MersenneTwister.hpp.

References seed().

◆ MersenneTwister() [3/4]

vl::MersenneTwister::MersenneTwister ( )
inline

Definition at line 288 of file MersenneTwister.hpp.

References seed().

◆ MersenneTwister() [4/4]

vl::MersenneTwister::MersenneTwister ( const MersenneTwister o)
inline

Definition at line 291 of file MersenneTwister.hpp.

References left, N, pNext, and state.

Member Function Documentation

◆ hash()

MersenneTwister::uint32 vl::MersenneTwister::hash ( time_t  t,
clock_t  c 
)
inlinestaticprotected

Definition at line 159 of file MersenneTwister.hpp.

Referenced by seed(), and twist().

◆ hiBit()

uint32 vl::MersenneTwister::hiBit ( const uint32  u) const
inlineprotected

Definition at line 145 of file MersenneTwister.hpp.

Referenced by mixBits().

◆ initialize()

void vl::MersenneTwister::initialize ( const uint32  oneSeed)
inlineprotected

Definition at line 184 of file MersenneTwister.hpp.

References N, and state.

Referenced by seed().

◆ load()

void vl::MersenneTwister::load ( uint32 *const  loadArray)
inline

Definition at line 390 of file MersenneTwister.hpp.

References left, N, pNext, and state.

◆ loBit()

uint32 vl::MersenneTwister::loBit ( const uint32  u) const
inlineprotected

Definition at line 146 of file MersenneTwister.hpp.

Referenced by magic().

◆ loBits()

uint32 vl::MersenneTwister::loBits ( const uint32  u) const
inlineprotected

Definition at line 147 of file MersenneTwister.hpp.

Referenced by mixBits().

◆ magic()

uint32 vl::MersenneTwister::magic ( const uint32  u) const
inlineprotected

Definition at line 150 of file MersenneTwister.hpp.

References loBit().

Referenced by twist().

◆ mixBits()

uint32 vl::MersenneTwister::mixBits ( const uint32  u,
const uint32  v 
) const
inlineprotected

Definition at line 148 of file MersenneTwister.hpp.

References hiBit(), and loBits().

Referenced by twist().

◆ operator()()

double vl::MersenneTwister::operator() ( )
inline

Definition at line 376 of file MersenneTwister.hpp.

References rand().

◆ operator=()

MersenneTwister & vl::MersenneTwister::operator= ( const MersenneTwister o)
inline

Definition at line 418 of file MersenneTwister.hpp.

References left, N, pNext, and state.

◆ rand() [1/2]

double vl::MersenneTwister::rand ( )
inline

Definition at line 336 of file MersenneTwister.hpp.

References randInt().

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

◆ rand() [2/2]

double vl::MersenneTwister::rand ( const double  n)
inline

Definition at line 339 of file MersenneTwister.hpp.

References rand().

◆ rand53()

double vl::MersenneTwister::rand53 ( )
inline

Definition at line 354 of file MersenneTwister.hpp.

References randInt().

Referenced by vl::random().

◆ randDblExc() [1/2]

double vl::MersenneTwister::randDblExc ( )
inline

Definition at line 348 of file MersenneTwister.hpp.

References randInt().

Referenced by randDblExc().

◆ randDblExc() [2/2]

double vl::MersenneTwister::randDblExc ( const double  n)
inline

Definition at line 351 of file MersenneTwister.hpp.

References randDblExc().

◆ randExc() [1/2]

double vl::MersenneTwister::randExc ( )
inline

Definition at line 342 of file MersenneTwister.hpp.

References randInt().

Referenced by randExc().

◆ randExc() [2/2]

double vl::MersenneTwister::randExc ( const double  n)
inline

Definition at line 345 of file MersenneTwister.hpp.

References randExc().

◆ randInt() [1/2]

MersenneTwister::uint32 vl::MersenneTwister::randInt ( )
inline

◆ randInt() [2/2]

MersenneTwister::uint32 vl::MersenneTwister::randInt ( const uint32  n)
inline

Definition at line 317 of file MersenneTwister.hpp.

References randInt().

◆ randNorm()

double vl::MersenneTwister::randNorm ( const double  mean = 0.0,
const double  stddev = 1.0 
)
inline

Definition at line 360 of file MersenneTwister.hpp.

References vl::log(), rand(), and vl::sqrt().

◆ reload()

void vl::MersenneTwister::reload ( )
inlineprotected

Definition at line 201 of file MersenneTwister.hpp.

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

Referenced by randInt(), and seed().

◆ save()

void vl::MersenneTwister::save ( uint32 saveArray) const
inline

Definition at line 381 of file MersenneTwister.hpp.

References left, N, and state.

◆ seed() [1/3]

void vl::MersenneTwister::seed ( const uint32  oneSeed)
inline

Definition at line 217 of file MersenneTwister.hpp.

References initialize(), and reload().

◆ seed() [2/3]

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

Definition at line 224 of file MersenneTwister.hpp.

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

◆ seed() [3/3]

void vl::MersenneTwister::seed ( )
inline

Definition at line 259 of file MersenneTwister.hpp.

References hash(), N, and NULL.

Referenced by MersenneTwister().

◆ twist()

uint32 vl::MersenneTwister::twist ( const uint32  m,
const uint32  s0,
const uint32  s1 
) const
inlineprotected

Definition at line 152 of file MersenneTwister.hpp.

References hash(), magic(), and mixBits().

Referenced by reload().

Friends And Related Function Documentation

◆ operator<<

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

Definition at line 400 of file MersenneTwister.hpp.

◆ operator>>

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

Definition at line 408 of file MersenneTwister.hpp.

Member Data Documentation

◆ left

int vl::MersenneTwister::left
protected

◆ pNext

uint32* vl::MersenneTwister::pNext
protected

Definition at line 99 of file MersenneTwister.hpp.

Referenced by load(), MersenneTwister(), operator=(), vl::operator>>(), randInt(), and reload().

◆ state

uint32 vl::MersenneTwister::state[N]
protected

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