#include <random_generator.h>
Public Member Functions | |
unsigned int | generate (unsigned int limit=0xffffffffu) |
Return a random number in the given range (limit) using the Subtractive Ring method. | |
double | generate01 () |
Return a random number in the [0,1) real interval using the Subtractive Ring method. | |
double | generate01closed () |
Returns a random number in the [0,1] real interval using the Subtractive Ring method. | |
double | generate01open () |
Generates a random number in the (0,1) real interval using the Subtractive Ring method. | |
void | initialize (unsigned int seed) |
(Re-)initialize with a given seed. | |
SubtractiveRingRNG (int default_seed=161803398u) | |
virtual | ~SubtractiveRingRNG () |
Private Attributes | |
size_t | _M_index1 |
size_t | _M_index2 |
unsigned int | _M_table [55] |
Uniform RNG derived from a STL extension of sgi.
It is based on the Subtractive Ring method. This implementation assumes that int is 32 bits.
References
D. E. Knuth, The Art of Computer Programming. Volume 2: Seminumerical Algorithms, 2nd Edition. Addison-Wesley, 1981. (section 3.6 of Knuth for an implementation of the subtractive method in FORTRAN) (section 3.2.2 of Knuth analyzes this class of algorithms)
Definition at line 79 of file random_generator.h.
vcg::math::SubtractiveRingRNG::SubtractiveRingRNG | ( | int | default_seed = 161803398u |
) | [inline] |
Definition at line 94 of file random_generator.h.
virtual vcg::math::SubtractiveRingRNG::~SubtractiveRingRNG | ( | ) | [inline, virtual] |
Definition at line 99 of file random_generator.h.
unsigned int vcg::math::SubtractiveRingRNG::generate | ( | unsigned int | limit = 0xffffffffu |
) | [inline, virtual] |
Return a random number in the given range (limit) using the Subtractive Ring method.
Implements vcg::math::RandomGenerator.
Definition at line 128 of file random_generator.h.
double vcg::math::SubtractiveRingRNG::generate01 | ( | ) | [inline, virtual] |
Return a random number in the [0,1) real interval using the Subtractive Ring method.
Implements vcg::math::RandomGenerator.
Definition at line 137 of file random_generator.h.
double vcg::math::SubtractiveRingRNG::generate01closed | ( | ) | [inline, virtual] |
Returns a random number in the [0,1] real interval using the Subtractive Ring method.
Implements vcg::math::RandomGenerator.
Definition at line 145 of file random_generator.h.
double vcg::math::SubtractiveRingRNG::generate01open | ( | ) | [inline, virtual] |
Generates a random number in the (0,1) real interval using the Subtractive Ring method.
Implements vcg::math::RandomGenerator.
Definition at line 153 of file random_generator.h.
void vcg::math::SubtractiveRingRNG::initialize | ( | unsigned int | seed | ) | [inline, virtual] |
(Re-)initialize with a given seed.
Implements vcg::math::RandomGenerator.
Definition at line 106 of file random_generator.h.
size_t vcg::math::SubtractiveRingRNG::_M_index1 [private] |
Definition at line 87 of file random_generator.h.
size_t vcg::math::SubtractiveRingRNG::_M_index2 [private] |
Definition at line 88 of file random_generator.h.
unsigned int vcg::math::SubtractiveRingRNG::_M_table[55] [private] |
Definition at line 86 of file random_generator.h.