Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZRandGen Class Reference

#include <ZE_ZRandGen.h>

List of all members.


Detailed Description

This class usually isn't needed by the average user, ZEngine contains an instance which should suffice unless you want objects to have their ownrandom streams. This implementation is derived from the original mt19937ar.c source from http://www.math.keio.ac.jp/matumoto/emt.html. See source of ZE_ZRandGen.cpp for license.
Since:
0.8.4


Public Member Functions

 ZRandGen ()
 Constructor which does an initial seeding using time.

 ZRandGen (unsigned long seed)
 Constructor which does an initial seeding.

void Seed (unsigned long seed)
 Seed random number generator.

unsigned int Rand (unsigned int max)
 Obtain random integer [0,max).

unsigned long Rand (unsigned long max)
 Obtain random integer [0,max).

int Rand (int min, int max)
 Obtain random integer [min,max].

long Rand (long min, long max)
 Obtain random integer [min,max].

float Rand (float min, float max)
 Obtain random integer [min,max].

double Rand (double min, double max)
 Obtain random integer [min,max].

double RandDouble ()
 Obtain random double [0,1).


Protected Member Functions

unsigned long genrand_int32 ()
 Workhorse of random generator, only used internally.


Protected Attributes

unsigned long rStateVector [N]
 Each instance of the algorithm requires a state vector.

unsigned long rStateVectorIndex
 Used internally to traversing the rStateVector.


Static Protected Attributes

const unsigned long N = 624
 Number of random numbers to generate at once.

const unsigned long M = 397
 A constant used internally by Mersenne Twister.

const unsigned long MATRIX_A = 0x9908b0dfUL
 Constant vector A, used internally by Mersenne Twister.

const unsigned long UPPER_MASK = 0x80000000UL
 Most signifigan w-r bits, used internally by Mersenne Twister.

const unsigned long LOWER_MASK = 0x7fffffffUL
 Least signifigant r bits, used internally by Mersenne Twister.


Constructor & Destructor Documentation

ZE::ZRandGen::ZRandGen  ) 
 

Creates internal vector and calls Seed(time(NULL)) to initialize the MT state.

ZE::ZRandGen::ZRandGen unsigned long  seed  ) 
 

Creates internal vector and calls seed to initialize the MT state.


Member Function Documentation

unsigned long ZE::ZRandGen::genrand_int32  )  [protected]
 

Generates N random numbers and then serves them up, all Rand functions rely on this.

Returns:
A random unsigned long.

void ZE::ZRandGen::Seed unsigned long  seed  ) 
 

Reseed Mersenne Twister random number generator. NOTE: Generator is initialized upon creation of object using time.

Parameters:
seed Seed for random sequence.

unsigned int ZE::ZRandGen::Rand unsigned int  max  ) 
 

Obtain random int l where 0 <= l < max.

Parameters:
max Limit for random number.
Returns:
Random unsigned int.

unsigned long ZE::ZRandGen::Rand unsigned long  max  ) 
 

Obtain random long l where 0 <= l < max.

Parameters:
max Limit for random number.
Returns:
Random unsigned long.

int ZE::ZRandGen::Rand int  min,
int  max
 

Obtain random int l where min <= l <= max.

Parameters:
min Lower limit for random number.
max Upper limit for random number.
Returns:
Random int.

long ZE::ZRandGen::Rand long  min,
long  max
 

Obtain random long l where min <= l <= max.

Parameters:
min Lower limit for random number.
max Upper limit for random number.
Returns:
Random long.

float ZE::ZRandGen::Rand float  min,
float  max
 

Obtain random float l where min <= l <= max.

Parameters:
min Lower limit for random number.
max Upper limit for random number.
Returns:
Random float.

double ZE::ZRandGen::Rand double  min,
double  max
 

Obtain random double l where min <= l <= max.

Parameters:
min Lower limit for random number.
max Upper limit for random number.
Returns:
Random double.

double ZE::ZRandGen::RandDouble  ) 
 

Obtain random double d where 0 <= d < 1.

Returns:
Random double [0,1).


The documentation for this class was generated from the following files:
Generated on Sun Oct 5 19:34:46 2003 for ZEngine by doxygen1.3