SIM_Random Class Reference

#include <SIM_Random.h>

Inheritance diagram for SIM_Random:

SIM_Data SIM_RandomTwister

List of all members.

Public Member Functions

void setSeed (uint seed)
 Sets the seed to the system.
uint urandom ()
 Gets a random unsigned integer.
fpreal frandom ()
 Returns a random float from [0..1).
fpreal frandom0 ()
 Returns a random float from [-.5...5).
int choice (int choices)
int irange (int a, int b)
fpreal frange (fpreal a, fpreal b)
bool chance (fpreal probability)

Protected Member Functions

 SIM_Random (const SIM_DataFactory *factory)
virtual ~SIM_Random ()
virtual void setSeedSubclass (uint seed)=0
 Override this function to initialize the random number generator.
virtual uint urandomSubclass ()=0
 Override this function to implement a new random number generator.


Detailed Description

This class defines a bunch of useful tools for random number generation. It is designed to be attached as subdata to objects or solvers that need a stream of random numbers.
Examples:

SIM/SIM_SolverSNOW.C, and SIM/SIM_SolverSNOW.h.

Definition at line 24 of file SIM_Random.h.


Constructor & Destructor Documentation

SIM_Random::SIM_Random ( const SIM_DataFactory factory  )  [explicit, protected]

virtual SIM_Random::~SIM_Random (  )  [protected, virtual]


Member Function Documentation

bool SIM_Random::chance ( fpreal  probability  ) 

Returns true with the givent probability. < 0 always false, > 1 always true.

int SIM_Random::choice ( int  choices  ) 

Returns a random integer from [0..choices-1] 0 choices will return 0. Negative choices will go for [-choices+1..0]

Examples:
SIM/SIM_SolverSNOW.C.

fpreal SIM_Random::frandom (  ) 

Returns a random float from [0..1).

Examples:
SIM/SIM_SolverSNOW.C.

fpreal SIM_Random::frandom0 (  ) 

Returns a random float from [-.5...5).

fpreal SIM_Random::frange ( fpreal  a,
fpreal  b 
)

int SIM_Random::irange ( int  a,
int  b 
)

Returns a number within the range [a..b] In the floating point case, the range is [a..b)

void SIM_Random::setSeed ( uint  seed  ) 

Sets the seed to the system.

virtual void SIM_Random::setSeedSubclass ( uint  seed  )  [protected, pure virtual]

Override this function to initialize the random number generator.

Implemented in SIM_RandomTwister.

uint SIM_Random::urandom (  ) 

Gets a random unsigned integer.

virtual uint SIM_Random::urandomSubclass (  )  [protected, pure virtual]

Override this function to implement a new random number generator.

Implemented in SIM_RandomTwister.


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

Generated on Fri May 25 00:10:40 2012 for HDK by  doxygen 1.5.9