"L. Spiro Engine"
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes

lsm::CRand Class Reference

Random-number generator. More...

#include <LSMRand.h>

List of all members.

Public Types

enum  { LSM_STATE_LEN = 624, LSM_STATE_LEN_ARRAY }

Public Member Functions

LSVOID LSE_FCALL Seed (LSUINT32 _ui32Seed)
LSUINT32 LSE_FCALL RandUInt32 () const
LSUINT32 LSE_FCALL RandUInt32 (LSUINT32 _ui32Max) const
LSUINT64 LSE_FCALL RandUInt64 () const
LSUINT64 LSE_FCALL RandUInt64 (LSUINT64 _ui64Max) const
LSREAL LSE_FCALL RandReal () const
LSREAL LSE_FCALL RandReal (LSREAL _fLow, LSREAL _fHigh) const

Protected Types

enum  { LSM_PERIOD = 397 }

Protected Member Functions

LSVOID LSE_FCALL Initialize (LSUINT32 _ui32Seed) const
LSVOID LSE_FCALL Reload () const

Static Protected Member Functions

static LSUINT32 LSE_FCALL HiBit (const LSUINT32 &_ui32Val)
static LSUINT32 LSE_FCALL LoBit (const LSUINT32 &_ui32Val)
static LSUINT32 LSE_FCALL LoBits (const LSUINT32 &_ui32Val)
static LSUINT32 LSE_FCALL MixBits (const LSUINT32 &_ui32L, const LSUINT32 &_ui32R)
static LSUINT32 LSE_FCALL MersenneTwist (const LSUINT32 &_ui32F, const LSUINT32 &_ui32L, const LSUINT32 &_ui32R)

Protected Attributes

LSUINT32 m_ui32State [LSM_STATE_LEN_ARRAY]
LSUINT32 * m_pui32NextInState
LSINT32 m_i32LeftInState

Detailed Description

Random-number generator.

Class CRand Description: Random-number class. Uses the Mersenne Twister approach due to Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus.


Member Enumeration Documentation

anonymous enum

Length of the state array.

anonymous enum [protected]

Period.


Member Function Documentation

LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::HiBit ( const LSUINT32 &  _ui32Val) [static, protected]

Get the highest bit.

Parameters:
_ui32ValValue whose highest bit is to be gotten.
Returns:
Returns the highest bit in the given value.
LSE_INLINE LSVOID LSE_FCALL lsm::CRand::Initialize ( LSUINT32  _ui32Seed) const [protected]

Initialize the state array with a seed.

Parameters:
_ui32SeedThe seed.
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::LoBit ( const LSUINT32 &  _ui32Val) [static, protected]

Get the lowest bit.

Parameters:
_ui32ValValue whose lowest bit is to be gotten.
Returns:
Returns the lowest bit in the given value.
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::LoBits ( const LSUINT32 &  _ui32Val) [static, protected]

Get all bits but the highest bit.

Parameters:
_ui32ValValue whose lower bots are to be obtained.
Returns:
Returns all but the highest bit.
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::MersenneTwist ( const LSUINT32 &  _ui32F,
const LSUINT32 &  _ui32L,
const LSUINT32 &  _ui32R 
) [static, protected]

"Mersenne Twist" up values.

Parameters:
_ui32FA value.
_ui32LA value.
_ui32RA value.
Returns:
Returns the twisted value.
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::MixBits ( const LSUINT32 &  _ui32L,
const LSUINT32 &  _ui32R 
) [static, protected]

Mixes bits.

Parameters:
_ui32LLeft operand.
_ui32RRight operand.
Returns:
Returns the mixed bits.
LSE_INLINE LSREAL LSE_FCALL lsm::CRand::RandReal ( LSREAL  _fLow,
LSREAL  _fHigh 
) const

Get a random floating-point number from _fLow to _fHigh inclusive.

Parameters:
_fLowLowest allowed value.
_fHighHighest allowed value.
Returns:
Returns a random LSREAL between _fLow and _fHigh inclusive.
LSE_INLINE LSREAL LSE_FCALL lsm::CRand::RandReal ( ) const

Get a random floating-point number from 0 to 1 inclusive.

Returns:
A random LSREAL value from 0 to 1 inclusive.
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::RandUInt32 ( LSUINT32  _ui32Max) const

Get an unsigned integer within a certain range (exclusive).

Parameters:
_ui32MaxUpper bounds of the number, exclusive. Number is generated from 0 to (_ui32Max - 1).
Returns:
A random number from 0 to (_ui32Max - 1).
LSE_INLINE LSUINT32 LSE_FCALL lsm::CRand::RandUInt32 ( ) const

Get a random unsigned integer.

Returns:
Returns a random unsigned 32-bit integer from 0x00000000 to 0xFFFFFFFF.
LSE_INLINE LSUINT64 LSE_FCALL lsm::CRand::RandUInt64 ( ) const

Get a random unsigned integer.

Returns:
Returns a random unsigned 64-bit integer from 0x0000000000000000ULL to 0xFFFFFFFFFFFFFFFFULL.
LSE_INLINE LSUINT64 LSE_FCALL lsm::CRand::RandUInt64 ( LSUINT64  _ui64Max) const

Get an unsigned integer within a certain range (exclusive).

Parameters:
_ui64MaxUpper bounds of the number, exclusive. Number is generated from 0 to (_ui64Max - 1).
Returns:
A random number from 0 to (_ui64Max - 1).
LSE_INLINE LSVOID LSE_FCALL lsm::CRand::Reload ( ) const [protected]

Refill the state array.

LSE_INLINE LSVOID LSE_FCALL lsm::CRand::Seed ( LSUINT32  _ui32Seed)

Seed the number generator.

Parameters:
_ui32SeedThe seed, usually obtained by getting the current time.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator