library of assembled shared sources |
http://lass.cocamware.com |
#include <random.h>
Public Types | |
typedef num::Tuint32 | TValue |
type of return value. | |
Public Member Functions | |
RandomMT19937 () | |
default constructor. | |
RandomMT19937 (TValue seed) | |
construct with seed. | |
template<typename ForwardIterator > | |
RandomMT19937 (ForwardIterator first, ForwardIterator last) | |
construct by a range of initializing keys Requirements: | |
void | seed (TValue seed) |
initializes with a seed. | |
template<typename ForwardIterator > | |
void | seed (ForwardIterator first, ForwardIterator last) |
initialize by a range of initializing keys Requirements: | |
const TValue | operator() () |
draw a random number | |
const TValue | operator() (TValue supremum) |
draw a random number remapped to range [0, supremum) | |
template<typename OutputIterator > | |
OutputIterator | getState (OutputIterator first) const |
template<typename InputIterator > | |
void | setState (InputIterator first, InputIterator last) |
Static Public Attributes | |
static const TValue | max = 0xffffffff |
maximum return value. | |
Private Types | |
enum | { stateSize_ = 624, shiftSize_ = 397 } |
Private Member Functions | |
LASS_META_ASSERT (sizeof(TValue)*lass::bitsPerByte==32, MersenneTwister_is_designed_to_be_a_32_bits_random_number_generator) | |
void | reload () |
generate N words at a time | |
const TValue | twist (TValue a, TValue b, TValue c) const |
Private Attributes | |
TValue | state_ [stateSize_] |
the array for the state vector. | |
TValue | index_ |
index in state vector. | |
Static Private Attributes | |
static TValue | wordMask_ |
static TValue | lowerMask_ |
static TValue | upperMask_ |
RandomMT19937 is the LASS implementation of the Mersenne twister. Mersenne Twister(MT) is a pseudorandom number generator developped by Makoto Matsumoto and Takuji Nishimura (alphabetical order) during 1996-1997. MT has the following merits:
M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally equidistributed uniform pseudorandom number generator", ACM Trans. on Modeling and Computer Simulation Vol. 8, No. 1, January pp.3-30 1998, http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
Our version is implemented after the MT19937 standard code of 2002/1/26 (mt19937ar.c)
Definition at line 150 of file random.h.
anonymous enum [private] |
lass::num::RandomMT19937::RandomMT19937 | ( | ) |
default constructor.
will seed with default value on first use.
Definition at line 111 of file random.cpp.
lass::num::RandomMT19937::RandomMT19937 | ( | TValue | seed | ) | [explicit] |
lass::num::RandomMT19937::RandomMT19937 | ( | ForwardIterator | first, | |
ForwardIterator | last | |||
) | [inline] |
construct by a range of initializing keys Requirements:
Definition at line 133 of file random.inl.
References seed().
void lass::num::RandomMT19937::seed | ( | TValue | seed | ) |
initializes with a seed.
Definition at line 129 of file random.cpp.
References index_, state_, and stateSize_.
Referenced by RandomMT19937(), reload(), and seed().
void lass::num::RandomMT19937::seed | ( | ForwardIterator | first, | |
ForwardIterator | last | |||
) | [inline] |
initialize by a range of initializing keys Requirements:
Definition at line 147 of file random.inl.
References lass::bitsPerByte, lass::prim::distance(), LASS_ASSERT, LASS_META_ASSERT(), seed(), state_, and stateSize_.
const RandomMT19937::TValue lass::num::RandomMT19937::operator() | ( | ) |
draw a random number
Definition at line 144 of file random.cpp.
References index_, reload(), state_, and stateSize_.
const RandomMT19937::TValue lass::num::RandomMT19937::operator() | ( | TValue | supremum | ) | [inline] |
draw a random number remapped to range [0, supremum)
Definition at line 200 of file random.inl.
OutputIterator lass::num::RandomMT19937::getState | ( | OutputIterator | first | ) | const [inline] |
void lass::num::RandomMT19937::setState | ( | InputIterator | first, | |
InputIterator | last | |||
) | [inline] |
lass::num::RandomMT19937::LASS_META_ASSERT | ( | sizeof(TValue)*lass::bitsPerByte | = =32 , |
|
MersenneTwister_is_designed_to_be_a_32_bits_random_number_generator | ||||
) | [private] |
Referenced by seed().
void lass::num::RandomMT19937::reload | ( | ) | [private] |
generate N words at a time
Definition at line 168 of file random.cpp.
References index_, seed(), shiftSize_, state_, stateSize_, and twist().
Referenced by operator()().
const RandomMT19937::TValue lass::num::RandomMT19937::twist | ( | TValue | a, | |
TValue | b, | |||
TValue | c | |||
) | const [inline, private] |
const RandomMT19937::TValue lass::num::RandomMT19937::max = 0xffffffff [static] |
TValue lass::num::RandomMT19937::state_[stateSize_] [private] |
the array for the state vector.
Definition at line 184 of file random.h.
Referenced by getState(), operator()(), reload(), seed(), and setState().
TValue lass::num::RandomMT19937::index_ [private] |
index in state vector.
Definition at line 185 of file random.h.
Referenced by getState(), operator()(), reload(), seed(), and setState().
TValue lass::num::RandomMT19937::wordMask_ [static, private] |
TValue lass::num::RandomMT19937::lowerMask_ [static, private] |
TValue lass::num::RandomMT19937::upperMask_ [static, private] |
Generated on Mon Nov 10 14:22:10 2008 for Library of Assembled Shared Sources by 1.5.7.1 |