Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

RandomNumberGenerator< RNG > Class Template Reference

Random number generator wrapper. More...

#include <Random.h>

Inheritance diagram for RandomNumberGenerator< RNG >:

RandomNumberGeneratorInterface RandomInterface List of all members.

Public Types

typedef Ref< _State > State
typedef unsigned long int SeedType

Public Methods

virtual void setSeed (SeedType seed)
 Reseed the random number generator.

virtual State getState () const
 Save the current state of the generator.

virtual void setState (State const &)
 Restore the generator to a specific state saved with getState().

virtual double unit ()
 Return a random floating point value in the range [0,1).

virtual double uniform (double, double)
 Return a random floating point value in the range [lower,upper).

virtual long uniformInt (long lower, long upper)
 Return a random integer in the range lower to upper-1 (inclusive).

virtual long uniformInt (long upper)
 Equivalent to uniformInt(0, upper).

virtual unsigned long uniformUInt (unsigned long lower, unsigned long upper)
 Return a random integer in the range lower to upper-1 (inclusive).

virtual unsigned long uniformUInt (unsigned long upper)
 Equivalent to uniformUInt(0, upper).

virtual std::string getName () const
 Get the name of this generator.

RNG * operator-> ()
 Direct access to the underlying generator.

virtual void setSeed (SeedType seed)=0
 Set the generator seed.

virtual void setState (State const &state)=0
 Set the generator state.


Detailed Description

template<class RNG>
class RandomNumberGenerator< RNG >

Random number generator wrapper.

Random number generator wrapper, implementing the random number generator interface. These generics provide a uniform interface to the underlying generators and generator state data. The performance penalty relative to using the raw generators is typically about 20%.


Member Typedef Documentation

typedef unsigned long int RandomInterface::SeedType [inherited]
 

typedef Ref<_State> RandomInterface::State [inherited]
 


Member Function Documentation

template<class RNG>
std::string RandomNumberGenerator< RNG >::getName   [virtual]
 

Get the name of this generator.

Implements RandomInterface.

template<class RNG>
RandomInterface::State RandomNumberGenerator< RNG >::getState   [virtual]
 

Save the current state of the generator.

The state can be restored at any time with setState().

Implements RandomInterface.

template<class RNG>
RNG* RandomNumberGenerator< RNG >::operator->   [inline]
 

Direct access to the underlying generator.

Using the generator directly provides slightly faster access and generator-specific methods.

virtual void RandomInterface::setSeed SeedType    seed [pure virtual, inherited]
 

Set the generator seed.

Implemented in RandomNumberGenerator< rng::Taus2 >.

template<class RNG>
void RandomNumberGenerator< RNG >::setSeed SeedType    seed [virtual]
 

Reseed the random number generator.

Parameters:
seed  the new seed.

virtual void RandomInterface::setState State const &    state [pure virtual, inherited]
 

Set the generator state.

Implemented in RandomNumberGenerator< rng::Taus2 >.

template<class RNG>
void RandomNumberGenerator< RNG >::setState State const &    [virtual]
 

Restore the generator to a specific state saved with getState().

The subsequent random numbers will be identical to the sequence following the corresponding getState() call.

template<class RNG>
double RandomNumberGenerator< RNG >::uniform double   ,
double   
[virtual]
 

Return a random floating point value in the range [lower,upper).

Implements RandomNumberGeneratorInterface.

template<class RNG>
long RandomNumberGenerator< RNG >::uniformInt long    upper [virtual]
 

Equivalent to uniformInt(0, upper).

Implements RandomNumberGeneratorInterface.

template<class RNG>
long RandomNumberGenerator< RNG >::uniformInt long    lower,
long    upper
[virtual]
 

Return a random integer in the range lower to upper-1 (inclusive).

Parameters:
lower  lower bound (inclusive)
upper  upper bound (exclusive)
Returns:
a random integer int the range lower to upper-1 (inclusive)

Implements RandomNumberGeneratorInterface.

template<class RNG>
unsigned long RandomNumberGenerator< RNG >::uniformUInt unsigned long    upper [virtual]
 

Equivalent to uniformUInt(0, upper).

Implements RandomNumberGeneratorInterface.

template<class RNG>
unsigned long RandomNumberGenerator< RNG >::uniformUInt unsigned long    lower,
unsigned long    upper
[virtual]
 

Return a random integer in the range lower to upper-1 (inclusive).

Parameters:
lower  lower bound (inclusive)
upper  upper bound (exclusive)
Returns:
a random integer int the range lower to upper-1 (inclusive)

Implements RandomNumberGeneratorInterface.

template<class RNG>
double RandomNumberGenerator< RNG >::unit   [virtual]
 

Return a random floating point value in the range [0,1).

Implements RandomNumberGeneratorInterface.


The documentation for this class was generated from the following file:
SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:42 2003, using Doxygen 1.2.18.

[SF.net]