FX::Maths::FRandomness Class Reference

#include <FXMaths.h>

Inheritance diagram for FX::Maths::FRandomness:

Inheritance graph
[legend]

List of all members.


Detailed Description

A fast quality source of pseudo entropy.

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.


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

Constructor & Destructor Documentation

FX::Maths::FRandomness::FRandomness ( FXulong  seed  )  throw () [inline]

Constructs, using seed seed.

FX::Maths::FRandomness::FRandomness ( FXuchar *  seed,
FXuval  len 
) throw () [inline]

Constructs, using seed seed.


Member Function Documentation

FXulong FX::Maths::FRandomness::int64 (  )  throw () [inline]

Generates a random number on [0, 2^64-1]-interval.

Reimplemented in FX::Maths::SysRandomness.

Referenced by FX::Maths::SysRandomness::int64().

void FX::Maths::FRandomness::fill ( FXuchar *  d,
FXuval  len 
) throw () [inline]

Generates lots of random data (make sure it's 16 byte aligned!).

double FX::Maths::FRandomness::real1 (  )  throw () [inline]

generates a random number on [0,1]-real-interval by division of 2^53-1

Reimplemented in FX::Maths::SysRandomness.

Referenced by FX::Maths::SysRandomness::real1().

double FX::Maths::FRandomness::real2 (  )  throw () [inline]

generates a random number on [0,1)-real-interval by division of 2^53

Reimplemented in FX::Maths::SysRandomness.

Referenced by FX::Maths::SysRandomness::real2().

double FX::Maths::FRandomness::real3 (  )  throw () [inline]

generates a random number on (0,1)-real-interval by division of 2^52

Reimplemented in FX::Maths::SysRandomness.

Referenced by FX::Maths::SysRandomness::real3().


Member Data Documentation

const bool FX::Maths::FRandomness::usingSIMD [static]

Indicates if implemented using SIMD.


The documentation for this class was generated from the following file:

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:30:20 2008 for TnFOX by doxygen v1.5.6