#include <FXMaths.h>
Inheritance diagram for FX::Maths::FRandomness:
Unlike FX::Secure::PRandomness, this class provides a much faster but not cryptographically secure pseudo random generator. In this it is much like FX::fxrandom(), except that instead of a 2^32 period this one has a mathematically proven 2^216091 period and is considered a much higher quality generator. Also, unlike FX::Secure::PRandomness, this class doesn't require the OpenSSL library to be compiled in.
Most use will by via FX::Maths::SysRandSrc which is a mutex protected static instance which can be used safely by multiple threads.
More specifically, this class is an implementation of the Mersenne Twister. Previous to v0.88 of TnFOX, this was a generic 64 bit implementation as detailed at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html. Since v0.88, a SIMD-based improved version has been added (the old version is still used instead on big-endian machines or x86 with no SSE).
You should be aware that each instance consumes about 2.5Kb of internal state and thus shouldn't be copied around nor constructed & destructed repeatedly. The old pre-v0.88 version could generate around 1Gb/sec of randomness on a 3.0Ghz Core 2 processor. The new SIMD version can more than double that, even more so again when compiled with Intel's C++ compiler.
Definition at line 1479 of file FXMaths.h.
Public Member Functions | |
FRandomness (FXulong seed) throw () | |
FRandomness (FXuchar *seed, FXuval len) throw () | |
FXulong | int64 () throw () |
void | fill (FXuchar *d, FXuval len) throw () |
double | real1 () throw () |
double | real2 () throw () |
double | real3 () throw () |
Static Public Attributes | |
static const bool | usingSIMD |