A very simple but fast Pseudo-random number generator. More...
#include <misc_types.h>
Public Member Functions | |
double | drand () |
random floating point number in the range [0, 1.0) | |
unsigned | irand (unsigned max) |
random number in the range [0, max) | |
uint32 | operator() (unsigned max) |
uint32 | operator() () |
uint32 | rand () |
Generates a pseudorandom number. | |
RNG (uint32 seed=1) | |
uint32 | seed () const |
void | srand (uint32 seed) |
Sets the starting point for random-number generation. | |
Private Attributes | |
uint32 | seed_ |
A very simple but fast Pseudo-random number generator.
Definition at line 136 of file misc_types.h.
Clasp::RNG::RNG | ( | uint32 | seed = 1 | ) | [inline, explicit] |
Definition at line 138 of file misc_types.h.
double Clasp::RNG::drand | ( | ) | [inline] |
random floating point number in the range [0, 1.0)
Definition at line 159 of file misc_types.h.
unsigned Clasp::RNG::irand | ( | unsigned | max | ) | [inline] |
random number in the range [0, max)
Definition at line 164 of file misc_types.h.
uint32 Clasp::RNG::operator() | ( | unsigned | max | ) | [inline] |
Definition at line 170 of file misc_types.h.
uint32 Clasp::RNG::operator() | ( | ) | [inline] |
Definition at line 171 of file misc_types.h.
uint32 Clasp::RNG::rand | ( | ) | [inline] |
Generates a pseudorandom number.
The rand function returns a pseudorandom integer in the range 0 to 32767 Use the srand function to seed the pseudorandom-number generator before calling rand.
Definition at line 154 of file misc_types.h.
uint32 Clasp::RNG::seed | ( | ) | const [inline] |
Definition at line 168 of file misc_types.h.
void Clasp::RNG::srand | ( | uint32 | seed | ) | [inline] |
Sets the starting point for random-number generation.
The function sets the starting point for generating a series of pseudorandom integers. To reinitialize the generator, use 1 as the seed argument. Any other value for seed sets the generator to a random starting point. Calling rand() before any call to srand() generates the same sequence as calling srand() with seed passed as 1.
Definition at line 147 of file misc_types.h.
uint32 Clasp::RNG::seed_ [private] |
Definition at line 173 of file misc_types.h.