Created by Scott Robert Ladd at Coyote Gulch Productions.
Implements CMWC4096, a peudorandom number generator. More...
#include <cmwc4096.h>
Public Member Functions | |
cmwc4096 () | |
Default constructor, reading seed from/dev/urandom or the time. More... | |
cmwc4096 (uint32_t seed) | |
Default constructor, with optional seed. More... | |
virtual void | init (uint32_t seed) |
Initializes the generator with "seed". More... | |
virtual uint32_t | get_rand () |
Get the next integer. More... | |
![]() | |
prng () | |
Default constructor, reading seed from/dev/urandom or the time. More... | |
prng (uint32_t seed) | |
Default constructor, with optional seed. More... | |
uint32_t | get_seed () |
Returns the original seed value. More... | |
uint32_t | get_rand_range (uint32_t lo, uint32_t hi) |
Get the next integer in the range [lo,hi]. More... | |
size_t | get_rand_index (size_t length) |
Get the next random value as a size_t index. More... | |
double | get_rand_real1 () |
Get the next number in the range [0,1]. More... | |
double | get_rand_real2 () |
Get the next number in the range [0,1) More... | |
double | get_rand_real3 () |
Get the next number in the range (0,1) More... | |
double | get_rand_real53 () |
Get the next number in the range [0,1) More... | |
Additional Inherited Members | |
![]() | |
uint32_t | m_seed |
Initialization seed. | |
The cmwc4096 class encapsulates a complimentary-multiply-with-carry algorithm for psuedorandom number generation, as suggested by George Marsaglia.
libcoyotl::cmwc4096::cmwc4096 | ( | ) |
The constructor initializes the prng seed from either the time or some stochastic source such as /dev/random or /dev/urandom.
libcoyotl::cmwc4096::cmwc4096 | ( | uint32_t | seed | ) |
The constructor uses an explicit value for the seed.
seed | - Seed value used to "start" or seed the generator |
|
virtual |
Returns the next uint32_t in sequence.
Implements libcoyotl::prng.
|
virtual |
Resets the generator using the provided seed value.
seed | - Seed value used to "start" or seed the generator |
Reimplemented from libcoyotl::prng.
© 1996-2005 Scott Robert Ladd. All rights reserved.
HTML documentation generated by Dimitri van Heesch's excellent Doxygen tool.