RandomLib
1.10
|
The MT19937 random number engine. More...
#include <RandomLib/RandomAlgorithm.hpp>
Public Types | |
enum | { N = (P + width - 1)/width } |
typedef RandomType | engine_t |
typedef engine_t::type | internal_type |
Static Public Member Functions | |
static void | Transition (long long count, internal_type statev[]) throw () |
static engine_type | Generate (engine_type y) throw () |
static void | NormalizeState (engine_type state[]) throw () |
static void | CheckState (const engine_type state[], Random_u32::type &check) |
static std::string | Name () throw () |
Static Public Attributes | |
static const unsigned | version = 0x456e4d54UL + (engine_t::width/32 - 1) |
The MT19937 random number engine.
This provides an interface to Mersenne Twister random number engine, MT19937. See
Makoto Matsumoto and Takuji Nishimura,
Mersenne Twister: A 623-Dimensionally Equidistributed Uniform Pseudo-Random Number Generator,
ACM TOMACS 8, 3–30 (1998)
This is adapted from the 32-bit and 64-bit C versions available at http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html and http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html
The template argument give the type RandomType of the "natural" result. This incorporates the bit width and the C++ type of the result. Although the two versions of MT19937 produce different sequences, the implementations here are portable across 32-bit and 64-bit architectures.
The class chiefly supplies the method for advancing the state by Transition.
RandomType | the type of the results, either Random_u32 or Random_u64. |
Interface routines written by Charles Karney charl and licensed under the MIT/X11 License. For more information, see es@k arney .comhttp://randomlib.sourceforge.net/
Definition at line 66 of file RandomAlgorithm.hpp.
typedef RandomType RandomLib::MT19937< RandomType >::engine_t |
The result RandomType
Definition at line 71 of file RandomAlgorithm.hpp.
typedef engine_t::type RandomLib::MT19937< RandomType >::internal_type |
The internal numeric type for MT19337::Transition
Definition at line 75 of file RandomAlgorithm.hpp.
anonymous enum |
Enumerator | |
---|---|
N |
The size of the state. This is the long lag for MT19937. |
Definition at line 120 of file RandomAlgorithm.hpp.
|
static |
Advance state by count batches. For speed all N words of state are advanced together. If count is negative, the state is stepped backwards. This is the meat of the MT19937 engine.
[in] | count | how many batches to advance. |
[in,out] | statev | the internal state of the random number generator. |
Definition at line 687 of file Random.cpp.
References MT19937_REVSTEP, and MT19937_STEP.
|
static |
Manipulate a word of the state prior to output.
[in] | y | a word of the state. |
|
static |
Convert an arbitrary state into a legal one. This consists of (a) turning on one bit if the state is all zero and (b) making 31 bits of the state consistent with the other 19937 bits.
[in,out] | state | the state of the generator. |
Definition at line 714 of file Random.cpp.
|
static |
Check that the state is legal, throwing an exception if it is not. At the same time, accumulate a checksum of the state.
[in] | state | the state of the generator. |
[in,out] | check | an accumulated checksum. |
Definition at line 735 of file Random.cpp.
|
inlinestatic |
|
static |
A version number "EnMT" or "EnMU" to ensure safety of Save/Load. This needs to be unique across RandomAlgorithms.
Definition at line 119 of file RandomAlgorithm.hpp.