LinearCongruentialRandom< FLOAT > Class Template Reference

#include <lib_math.h>

Detailed Description

template<typename FLOAT>
class maxon::LinearCongruentialRandom< FLOAT >

Linear congruential random value generator. The class will always produce the same output if the initialization seed was matching.

Public Member Functions

 LinearCongruentialRandom ()
 
void Init (UInt32 seed)
 
FLOAT Get01 ()
 
FLOAT Get11 ()
 
UInt32 GetUInt32 ()
 
UInt32 GetSeed () const
 
void SetSeed (UInt32 seed)
 

Private Attributes

UInt32 _seed
 

Constructor & Destructor Documentation

◆ LinearCongruentialRandom()

Member Function Documentation

◆ Init()

void Init ( UInt32  seed)

Initialize the random class with a custom seed value. The seed initially is advanced to avoid clustering close to 0 for typical user-adjusted values.

Parameters
[in]seedSeed value.

◆ Get01()

FLOAT Get01 ( )

Returns the next random value in the range of [0..1].

◆ Get11()

FLOAT Get11 ( )

Returns the next random value in the range of [-1..1].

◆ GetUInt32()

UInt32 GetUInt32 ( )

Returns the next 32-bit random value.

◆ GetSeed()

UInt32 GetSeed ( ) const

Returns the current seed value.

◆ SetSeed()

void SetSeed ( UInt32  seed)

Changes the seed value (.

See also
Init).

Member Data Documentation

◆ _seed

UInt32 _seed
private