#include <cmnRandomSequence.h>
Collaboration diagram for cmnRandomSequence:

Class cmnRandomSequence provides a reproducible random sequence. A random sequence is defined as a sequence of elements of type ElementaryRandomNumber, which is generated by a more or less good random number generator. The random number generator is initialized with a seed, and outputs a sequence of numbers.
In order to reproduce a random sequence, we need to store the seed and the position in the sequence. We can then resume to any position in the sequence using the method SetSequencePosition().
Important note: In the current implementation, we are using the rand() function of the standard C/C++ library. However, as the rand() function does not have a cross-platform standardized behavior, our random sequence is only reproducible within the scope of one compiler on one machine. In addition, as we depend on a global mechanism, all the random sequences use the same resource. This means that in fact, there is only one random sequence in the system. Therefore, the current implementation is as a Singleton.
Useful background on randomization can be found, for example, in Numerical Recipes: http://www.nr.com . Due to copyright issues, we are currently delaying its use. Another possible source for randomization functions is in the Gnu Scientific Library (GSL): http://www.gnu.org/software/gsl/gsl.html .
Definition at line 67 of file cmnRandomSequence.h.
| typedef unsigned int cmnRandomSequence::SeedType |
type of the randomization seed
Definition at line 72 of file cmnRandomSequence.h.
| typedef int cmnRandomSequence::ElementaryRandomNumber |
type of the elementary random number that's generated by cmnRandomSequence
Definition at line 76 of file cmnRandomSequence.h.
| typedef unsigned long cmnRandomSequence::SequenceCounterType |
type of counter of the number of elements that were extracted from the sequence
Definition at line 80 of file cmnRandomSequence.h.
| cmnRandomSequence::cmnRandomSequence | ( | ) | [inline, protected] |
Default constructor -- initialize the randomization seed to the default seed and start at the first element of the random sequence.
Definition at line 99 of file cmnRandomSequence.h.
| cmnRandomSequence::cmnRandomSequence | ( | const SeedType | seed, | |
| const SequenceCounterType | position = 0 | |||
| ) | [inline, protected] |
Parametrized constructor -- initialize the randomization seed by a parameter and start at the specified position (zero based) of the random sequence
Definition at line 108 of file cmnRandomSequence.h.
| cmnRandomSequence::cmnRandomSequence | ( | const cmnRandomSequence & | other | ) | [inline, protected] |
Copy constructor -- initialize the seed and the sequence position identically to the other object
Definition at line 118 of file cmnRandomSequence.h.
References GetSeed(), and GetSequencePosition().
| cmnRandomSequence& cmnRandomSequence::operator= | ( | const cmnRandomSequence & | other | ) | [inline, protected] |
Assignment operator -- see copy constructor
Definition at line 127 of file cmnRandomSequence.h.
References GetSeed(), and GetSequencePosition().
| static cmnRandomSequence& cmnRandomSequence::GetInstance | ( | void | ) | [inline, static] |
Access the Singleton instance
Definition at line 143 of file cmnRandomSequence.h.
Referenced by vctRandom().
| SeedType cmnRandomSequence::GetSeed | ( | ) | const [inline] |
Return the randomization seed for this object
Definition at line 151 of file cmnRandomSequence.h.
Referenced by cmnRandomSequence(), and operator=().
| void cmnRandomSequence::SetSeed | ( | SeedType | seed | ) | [inline] |
Set the randomization seed to the given value, and move to sequence position 0.
Definition at line 159 of file cmnRandomSequence.h.
| SequenceCounterType cmnRandomSequence::GetSequencePosition | ( | ) | const [inline] |
Return the number of random sequence elements extracted so far.
Definition at line 169 of file cmnRandomSequence.h.
Referenced by cmnRandomSequence(), and operator=().
| void cmnRandomSequence::SetSequencePosition | ( | SequenceCounterType | position | ) | [inline] |
Move to the specified position (zero based) in the random sequence starting with the current seed.
Definition at line 178 of file cmnRandomSequence.h.
| ElementaryRandomNumber cmnRandomSequence::ExtractRandomElement | ( | ) | [inline] |
Extract a single random element from the sequence. This is the basic operation on the random sequence.
Definition at line 189 of file cmnRandomSequence.h.
| void cmnRandomSequence::ExtractRandomValue | ( | _valueType & | result | ) |
Extract a random value for a templated type. These methods are specialized by the type argument so that they can be used generically, e.g., in sequence testing.
Referenced by vctRandom().
| void cmnRandomSequence::ExtractRandomValue | ( | const _valueType | min, | |
| const _valueType | max, | |||
| _valueType & | result | |||
| ) | [inline] |
Extract a random value for a templated type. These methods are specialized by the type argument so that they can be used generically, e.g., in sequence testing.
| void cmnRandomSequence::ExtractRandomValueArray | ( | const _valueType | min, | |
| const _valueType | max, | |||
| _valueType * | array, | |||
| const size_t | arraySize | |||
| ) | [inline] |
Extract a random value for a templated type. These methods are specialized by the type argument so that they can be used generically, e.g., in sequence testing.
| float cmnRandomSequence::ExtractRandomFloat | ( | ) | [inline] |
Return a random floating point number in the range (0..1)
Definition at line 211 of file cmnRandomSequence.h.
| float cmnRandomSequence::ExtractRandomFloat | ( | const float | min, | |
| const float | max | |||
| ) | [inline] |
Return a random floating point number in the range [min..max]
Definition at line 220 of file cmnRandomSequence.h.
| double cmnRandomSequence::ExtractRandomDouble | ( | ) | [inline] |
Return a random double-precision floating point number in the range (0..1)
Definition at line 234 of file cmnRandomSequence.h.
| double cmnRandomSequence::ExtractRandomDouble | ( | const double | min, | |
| const double | max | |||
| ) | [inline] |
Return a random double-precision floating point number in the range [min..max]
Definition at line 240 of file cmnRandomSequence.h.
| void cmnRandomSequence::ExtractRandomPermutation | ( | const size_t | length, | |
| unsigned int * | array | |||
| ) |
Fill the given array with a random permutation of the numbers 0..length
| void cmnRandomSequence::ExtractRandomPermutation | ( | const size_t | length, | |
| unsigned long int * | array | |||
| ) |
Fill the given array with a random permutation of the numbers 0..length
const SeedType cmnRandomSequence::DefaultSeed [static] |
The default randomization seed.
Definition at line 84 of file cmnRandomSequence.h.
const ElementaryRandomNumber cmnRandomSequence::LowerRandomBound [static] |
the lower bound for a value of an elementary random number
Definition at line 88 of file cmnRandomSequence.h.
const ElementaryRandomNumber cmnRandomSequence::UpperRandomBound [static] |
the upper bound for a value of an elementary random number
Definition at line 92 of file cmnRandomSequence.h.
cmnRandomSequence cmnRandomSequence::RandomInstance [static, protected] |
The Singleton instance
Definition at line 137 of file cmnRandomSequence.h.