Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
om::math::Random< T, RNG > Class Template Reference

A class representing a random number generator for the templated data type. More...

#include <omRandom.h>

Classes

class  State
 

Public Types

typedef RNG< WIDTHRNGType
 The type used for the internal random number generator. More...
 
typedef RNG< WIDTH >::SeedType SeedType
 The underlying type used to represent the random seed. More...
 
typedef RNG< WIDTH >::OutputType OutputType
 The underlying unsigned integer type that is the output of the PRNG. More...
 

Public Member Functions

 Random ()
 Create a random variable with a default initial seed value derived from the current system time. More...
 
 Random (SeedType newSeed)
 Create a random variable with the specified initial seed value. More...
 
sample ()
 Generate a sample from the random variable and return the result. More...
 
sample (T min, T max)
 Generate a sample from the random variable in the specified range. More...
 
void setSeed (SeedType newSeed)
 Set the initial seed for the random variable. More...
 
void setState (const SeedType newState[WIDTH])
 Set the entire state for the random variable. More...
 
void setState (const State &newState)
 Set the entire state for the random variable. More...
 
const StategetState () const
 Return an object containing the internal state storage of this random variable. More...
 
Size getStateSize () const
 Return the number of elements that make up the state of this random variable. More...
 
template<>
float sample ()
 
template<>
float sample (float min, float max)
 
template<>
double sample ()
 
template<>
double sample (double min, double max)
 

Static Public Attributes

static const Size WIDTH = sizeof(T)
 The number of seed values used as the state of this random variable. More...
 
static const Size SEED_SIZE = RNGType::SEED_SIZE
 The number of seed values that are part of the random state. More...
 

Detailed Description

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
class om::math::Random< T, RNG >

A class representing a random number generator for the templated data type.

Member Typedef Documentation

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
typedef RNG<WIDTH> om::math::Random< T, RNG >::RNGType

The type used for the internal random number generator.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
typedef RNG<WIDTH>::SeedType om::math::Random< T, RNG >::SeedType

The underlying type used to represent the random seed.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
typedef RNG<WIDTH>::OutputType om::math::Random< T, RNG >::OutputType

The underlying unsigned integer type that is the output of the PRNG.

Constructor & Destructor Documentation

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
om::math::Random< T, RNG >::Random ( )
inline

Create a random variable with a default initial seed value derived from the current system time.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
om::math::Random< T, RNG >::Random ( SeedType  newSeed)
inline

Create a random variable with the specified initial seed value.

Member Function Documentation

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
T om::math::Random< T, RNG >::sample ( )
inline

Generate a sample from the random variable and return the result.

The value returned may have any numerical value representable by the random variable's data type. The pseudorandom values returned over successive calls to this function will lie in a uniform distribution.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
T om::math::Random< T, RNG >::sample ( min,
max 
)
inline

Generate a sample from the random variable in the specified range.

The value returned can have any numerical value between and including the minimum and maximum values specified. The pseudorandom values returned over successive calls to this function will lie in a uniform distribution.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
void om::math::Random< T, RNG >::setSeed ( SeedType  newSeed)
inline

Set the initial seed for the random variable.

If the PRNG state is larger than one seed value, a simple RNG is used to generate the rest of the state from the initial seed. After setting the seed for the random variable, calls to the sample() methods will produce the same sequence of values for equal initial seed values.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
void om::math::Random< T, RNG >::setState ( const SeedType  newState[WIDTH])
inline

Set the entire state for the random variable.

After setting the state for the random variable, calls to the sample() methods will produce the same sequence of values for equal initial seed values.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
void om::math::Random< T, RNG >::setState ( const State newState)
inline

Set the entire state for the random variable.

After setting the state for the random variable, calls to the sample() methods will produce the same sequence of values for equal initial seed values.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
const State& om::math::Random< T, RNG >::getState ( ) const
inline

Return an object containing the internal state storage of this random variable.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
Size om::math::Random< T, RNG >::getStateSize ( ) const
inline

Return the number of elements that make up the state of this random variable.

template<>
float om::math::Random< float >::sample ( )
inline
template<>
float om::math::Random< float >::sample ( float  min,
float  max 
)
inline
template<>
double om::math::Random< double >::sample ( )
inline
template<>
double om::math::Random< double >::sample ( double  min,
double  max 
)
inline

Member Data Documentation

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
const Size om::math::Random< T, RNG >::WIDTH = sizeof(T)
static

The number of seed values used as the state of this random variable.

template<typename T, template< Size numBytes > class RNG = Xoroshiro128>
const Size om::math::Random< T, RNG >::SEED_SIZE = RNGType::SEED_SIZE
static

The number of seed values that are part of the random state.


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