A very simple but fast Pseudo-random number generator.
More...
#include <misc_types.h>
A very simple but fast Pseudo-random number generator.
- Note
- This class is a replacement for the standard rand-function. It is provided in order to get reproducible random numbers among different compilers.
Clasp::RNG::RNG |
( |
uint32 |
seed = 1 | ) |
|
|
inlineexplicit |
double Clasp::RNG::drand |
( |
| ) |
|
|
inline |
random floating point number in the range [0, 1.0)
unsigned Clasp::RNG::irand |
( |
unsigned |
max | ) |
|
|
inline |
random number in the range [0, max)
uint32 Clasp::RNG::operator() |
( |
unsigned |
max | ) |
|
|
inline |
uint32 Clasp::RNG::operator() |
( |
| ) |
|
|
inline |
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.
uint32 Clasp::RNG::seed |
( |
| ) |
const |
|
inline |
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.
The documentation for this class was generated from the following file:
- /Users/danielbaeck/Dropbox/Uni Klagenfurt/Diplomarbeit/gringo44/libclasp/clasp/util/misc_types.h