Library of Assembled Shared Sources
lass::num::RandomMT19937 Class Reference

implemenents a mersenne twister MT19937. More...

#include <random.h>

Public Types

using result_type = num::Tuint32
 type of return value.
 
typedef num::Tuint32 TValue
 type of return value.
 

Public Member Functions

 RandomMT19937 ()
 default constructor.
 
 RandomMT19937 (result_type seed)
 construct with seed.
 
template<typename ForwardIterator>
 RandomMT19937 (ForwardIterator first, ForwardIterator last)
 construct by a range of initializing keys Requirements:
 
void seed (result_type seed)
 initializes with a seed.
 
template<typename ForwardIterator>
void seed (ForwardIterator first, ForwardIterator last)
 initialize by a range of initializing keys Requirements:
 
result_type operator() ()
 draw a random number
 
result_type operator() (result_type supremum)
 draw a random number remapped to range [0, supremum)
 

Static Public Member Functions

static constexpr result_type min ()
 minimum return value.
 
static constexpr result_type max ()
 maximum return value.
 

Detailed Description

implemenents a mersenne twister MT19937.

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:

  • It is designed with consideration on the flaws of various existing generators.
  • Far longer period and far higher order of equidistribution than any other implemented generators. (It is proved that the period is 2^19937-1, and 623-dimensional equidistribution property is assured.)
  • Fast generation. (Although it depends on the system, it is reported that MT is sometimes faster than the standard ANSI-C library in a system with pipeline and cache memory.)
  • Efficient use of the memory. (The implementation consumes only 624 words of working area.)

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 157 of file random.h.

Member Typedef Documentation

◆ TValue

typedef num::Tuint32 lass::num::RandomMT19937::TValue

type of return value.

Deprecated

Definition at line 163 of file random.h.

Constructor & Destructor Documentation

◆ RandomMT19937() [1/2]

lass::num::RandomMT19937::RandomMT19937 ( )

default constructor.

will seed with default value on first use.

Definition at line 104 of file random.cpp.

◆ RandomMT19937() [2/2]

template<typename ForwardIterator>
lass::num::RandomMT19937::RandomMT19937 ( ForwardIterator first,
ForwardIterator last )

construct by a range of initializing keys Requirements:

  • ForwardIterator is a forward iterator to elements of type TValue. It must really be a forward iterator and not just an input iterator, since it must be possible to iterator over the same range more than once.

Definition at line 141 of file random.inl.

References seed().

Member Function Documentation

◆ seed()

template<typename ForwardIterator>
void lass::num::RandomMT19937::seed ( ForwardIterator first,
ForwardIterator last )

initialize by a range of initializing keys Requirements:

  • ForwardIterator is a forward iterator to elements of type TValue. It must really be a forward iterator and not just an input iterator, since it must be possible to iterator over the same range more than once.

Definition at line 155 of file random.inl.

References LASS_META_ASSERT, and seed().

◆ operator()()

RandomMT19937::TValue lass::num::RandomMT19937::operator() ( result_type supremum)
inline

draw a random number remapped to range [0, supremum)

Deprecated
this is A VERY BAD WAY TO DO IT!

Definition at line 207 of file random.inl.


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