Very Simple Cross-Platform Library
|
#include <PseudoRandom.h>
Public Member Functions | |
PseudoRandom () | |
PseudoRandom (uint32_t seed) | |
uint32_t | next () |
unsigned | nextUnsigned (unsigned to=MAX, unsigned from=0) |
double | nextDouble (double to=1.0, double from=0.0) |
Static Public Attributes | |
static const uint32_t | MAX = (1<<31) |
Private Member Functions | |
void | initialize (uint32_t seed) |
Private Attributes | |
uint32_t | vector [vectorSize] |
int | nextIndex |
Static Private Attributes | |
static const size_t | vectorSize = 34 |
static const size_t | numDiscarded = 344 |
A pseudo-random number generator. The algorithm is the same as described in http://www.mathstat.dal.ca/~selinger/random, i.e. the GNU libc random number generator. It is reimplemented, because Windows does not provide a thread-safe, reentrable pseudo-random number generation facility, so it should have been implemented for Win32 anyway.
Definition at line 52 of file PseudoRandom.h.
|
inline |
Construct the random number generator with a default seed (taken by calling time()).
Definition at line 121 of file PseudoRandom.h.
|
inline |
Construct the random number generator with the given seed.
Definition at line 128 of file PseudoRandom.h.
|
private |
Initialize the random number generator with the given seed.
Definition at line 39 of file PseudoRandom.cc.
|
inline |
Get the next raw value.
Definition at line 135 of file PseudoRandom.h.
|
inline |
Get the next random number as a double value between [from, to].
Definition at line 158 of file PseudoRandom.h.
|
inline |
Get the next random number as an unsigned value between [from, to].
Definition at line 150 of file PseudoRandom.h.
|
static |
The largest random number generated in the unconverted sequence.
Definition at line 59 of file PseudoRandom.h.
|
private |
The index of the next random number.
Definition at line 80 of file PseudoRandom.h.
|
staticprivate |
The number of random numbers thrown away.
Definition at line 70 of file PseudoRandom.h.
|
private |
The vector of random numbers used to generate the next one.
Definition at line 75 of file PseudoRandom.h.
|
staticprivate |
The size of the vector.
Definition at line 65 of file PseudoRandom.h.