class RED::Random
Class providing a Mersenne Twister-based pseudo-random numbers generator. More...
#include <REDRandom.h>
Inherits: RNG.
Public functions:
Random ( unsigned int iSeed = 24091975 ) | |
virtual void * | As ( const RED::CID & iCID ) |
virtual const void * | As ( const RED::CID & iCID ) const |
template< class T_As > const T_As * | As ( ) const |
template< class T_As > T_As * | As ( ) |
virtual void | Init ( unsigned int iSeed ) |
virtual unsigned int | Rand32 ( ) |
Public static functions:
static RED::CID | GetClassID ( ) |
Private functions:
void | GenState ( ) |
Private variables:
unsigned int * | _curstate |
unsigned int * | _endstate |
unsigned int | _state [624] |
Detailed description:
Class providing a Mersenne Twister-based pseudo-random numbers generator.
As the built-in C/C++ pseudo-random numbers generator, this one has two methods: one for algorithm initialization (RED::Random::Init) and another one for getting 32bit numbers (RED::Random::Rand32). RED::Random::Max32 is the biggest number Rand32() can return.
This implementation is cross-platform and ensures users that the same numbers will be returned for a given seed on every machine run under any OS.
This generator is surely not the fastest one, but can be used as a reliable pseudo-random numbers generator for tasks which are not critic.
Functions documentation
public RED::Random::Random | ( | unsigned int | iSeed = 24091975 | ) |
Constructs a random numbers generator.
Parameters:
iSeed: | seed used for initialization. |
public static RED::CID RED::Random::GetClassID | ( | ) |
Reimplements: RED::RNG::GetClassID.
public virtual void * RED::Random::As | ( | const RED::CID & | iCID | ) |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::RNG::As.
public virtual const void * RED::Random::As | ( | const RED::CID & | iCID | ) const |
Converts the object to an instance of the given type.
Parameters:
iCID: | Requested class. |
Returns:
Reimplements: RED::RNG::As.
template< class T_As > public const T_As * RED::Random::As | ( | ) const |
Template version of the as const method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::RNG::As.
template< class T_As > public T_As * RED::Random::As | ( | ) |
Template version of the as method.
Simply set T to be the class you want to retrieve an interface to.
Returns:
Reimplements: RED::RNG::As.
public virtual void RED::Random::Init | ( | unsigned int | iSeed | ) |
Initializes a 32bit pseudo-random numbers generator.
Parameters:
iSeed: | seed used for initialization. |
Implements: RED::RNG::Init.
public virtual unsigned int RED::Random::Rand32 | ( | ) |
Returns:
Implements: RED::RNG::Rand32.
private void RED::Random::GenState | ( | ) |
RNG utility method.
Variables documentation
Pointer to the current state.
Pointer to the end state.
State values.