RandomLib::SFMT19937< RandomType > Class Template Reference

The SFMT random number engine. More...

#include <RandomLib/RandomAlgorithm.hpp>

List of all members.

Public Types

enum  { N = N128 * R }
typedef RandomType engine_t
typedef engine_t::type internal_type

Public Member Functions

template<>
void Transition (long long count, internal_type statev[]) throw()
template<>
void Transition (long long count, internal_type statev[]) throw()
template<>
void NormalizeState (engine_type state[]) throw()
template<>
void NormalizeState (engine_type state[]) throw()

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) throw (std::out_of_range)
static std::string Name () throw ()

Static Public Attributes

static const unsigned version = 0x456e534dUL + (engine_t::width/32 - 1)

Private Types

enum  {
  P = 19937, N128 = (P + 128 - 1)/128, R = 128 / width, M128 = 122,
  M = M128 * R
}
typedef engine_t::type engine_type

Static Private Attributes

static const unsigned width = engine_t::width
static const engine_type magic0 = width == 32 ? 0x1fffefULL : 0x1ecb7f001fffefULL
static const engine_type magic1 = width == 32 ? 0x1ecb7fULL : 0x1ffff6001affffULL
static const engine_type magic2 = width == 32 ? 0x1affffULL : 0ULL
static const engine_type magic3 = width == 32 ? 0x1ffff6ULL : 0ULL
static const engine_type mask18 = engine_type(0xfffc0000fffc0000ULL)
static const engine_type PARITY0 = 1U
static const engine_type PARITY1 = width == 32 ? 0U : 0x13c9e68400000000ULL
static const engine_type PARITY2 = 0U
static const engine_type PARITY3 = width == 32 ? 0x13c9e684UL : 0U
static const unsigned PARITY_LSB = 0
static const engine_type mask = engine_t::mask

Detailed Description

template<class RandomType>
class RandomLib::SFMT19937< RandomType >

The SFMT random number engine.

This provides an implementation of the SIMD-oriented Fast Mersenne Twister random number engine, SFMT. See
Mutsuo Saito,
An Application of Finite Field: Design and Implementation of 128-bit Instruction-Based Fast Pseudorandom Number Generator,
Master's Thesis, Dept. of Math., Hiroshima University (Feb. 2007).
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/M062821.pdf Mutsuo Saito and Makoto Matsumoto,
SIMD-oriented Fast Mersenne Twister: a 128-bit Pseudorandom Number Generator,
accepted in the proceedings of MCQMC2006
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/sfmt.pdf

The template argument give the type RandomType of the "natural" result. This incorporates the bit width and the C++ type of the result. The 32-bit and 64-bit versions of SFMT19937 produce the same sequences and the differing only in whether how the state is represented. The implementation includes a version using 128-bit SSE2 instructions. On machines without these instructions, portable implementations using traditional operations are provided. With the same starting seed, SRandom32::Ran64() and SRandom64::Ran64() produces the same sequences. Similarly SRandom64::Ran32() produces every other member of the sequence produced by SRandom32::Ran32().

The class chiefly supplies the method for advancing the state by Transition.

Written by Charles Karney <charles@karney.com> and licensed under the LGPL. For more information, see http://charles.karney.info/random/

Definition at line 207 of file RandomAlgorithm.hpp.


Member Typedef Documentation

template<class RandomType >
typedef RandomType RandomLib::SFMT19937< RandomType >::engine_t

The result RandomType

Definition at line 212 of file RandomAlgorithm.hpp.

template<class RandomType >
typedef engine_t::type RandomLib::SFMT19937< RandomType >::internal_type

The internal numeric type for MT19337::Transition

Definition at line 221 of file RandomAlgorithm.hpp.

template<class RandomType >
typedef engine_t::type RandomLib::SFMT19937< RandomType >::engine_type [private]

The unsigned type of engine_t

Definition at line 227 of file RandomAlgorithm.hpp.


Member Enumeration Documentation

template<class RandomType >
anonymous enum [private]
Enumerator:
P 

The Mersenne prime is 2P - 1

N128 

The long lag for SFMT19937 in units of 128-bit words

R 

How many width words per 128-bit word.

M128 

The short lag for SFMT19937 in units of 128-bit words

M 

The short lag for SFMT19937

Definition at line 232 of file RandomAlgorithm.hpp.

template<class RandomType >
anonymous enum
Enumerator:
N 

The size of the state. The long lag for SFMT19937

Definition at line 295 of file RandomAlgorithm.hpp.


Member Function Documentation

template<class RandomType >
static void RandomLib::SFMT19937< RandomType >::Transition ( long long  count,
internal_type  statev[] 
) throw () [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 SFMT19937 engine.

template<class RandomType >
static engine_type RandomLib::SFMT19937< RandomType >::Generate ( engine_type  y  )  throw () [inline, static]

Manipulate a word of the state prior to output. This is a no-op for SFMT19937.

Definition at line 313 of file RandomAlgorithm.hpp.

template<class RandomType >
static void RandomLib::SFMT19937< RandomType >::NormalizeState ( engine_type  state[]  )  throw () [static]

Convert an arbitrary state into a legal one. This consists a period certification to ensure that the period of the generator is at least 2P - 1.

template<class RandomType >
void RandomLib::SFMT19937< RandomType >::CheckState ( const engine_type  state[],
Random_u32::type check 
) throw (std::out_of_range) [inline, static]

Check that the state is legal, throwing an exception if it is not. This merely verfies that the state is not all zero. At the same time, accumulate a checksum of the state.

Definition at line 1170 of file Random.cpp.

template<class RandomType >
static std::string RandomLib::SFMT19937< RandomType >::Name (  )  throw () [inline, static]

Return the name of the engine

Definition at line 333 of file RandomAlgorithm.hpp.

References RandomLib::MT19937< RandomType >::width.

template<>
void RandomLib::SFMT19937< Random_u32 >::Transition ( long long  count,
internal_type  statev[] 
) throw() [inline]

Definition at line 1043 of file Random.cpp.

References SFMT19937_REVSTEP32, and SFMT19937_STEP32.

template<>
void RandomLib::SFMT19937< Random_u64 >::Transition ( long long  count,
internal_type  statev[] 
) throw() [inline]

Definition at line 1109 of file Random.cpp.

References SFMT19937_REVSTEP64, and SFMT19937_STEP64.

template<>
void RandomLib::SFMT19937< Random_u32 >::NormalizeState ( engine_type  state[]  )  throw() [inline]

Definition at line 1141 of file Random.cpp.

References STATIC_ASSERT.

template<>
void RandomLib::SFMT19937< Random_u64 >::NormalizeState ( engine_type  state[]  )  throw() [inline]

Definition at line 1156 of file Random.cpp.

References STATIC_ASSERT.


Member Data Documentation

template<class RandomType >
const unsigned RandomLib::SFMT19937< RandomType >::width = engine_t::width [static, private]

The width of the engine_t

Definition at line 231 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::magic0 = width == 32 ? 0x1fffefULL : 0x1ecb7f001fffefULL [static, private]

Magic matrix for SFMT19937. Only the low 21 (= 32 - 11) bits need to be set. (11 is the right shift applied to the words before masking.

Definition at line 266 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::magic1 = width == 32 ? 0x1ecb7fULL : 0x1ffff6001affffULL [static, private]

Definition at line 267 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::magic2 = width == 32 ? 0x1affffULL : 0ULL [static, private]

Definition at line 268 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::magic3 = width == 32 ? 0x1ffff6ULL : 0ULL [static, private]

Definition at line 269 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::mask18 = engine_type(0xfffc0000fffc0000ULL) [static, private]

Mask for simulating u32 << 18 with 64-bit words

Definition at line 274 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::PARITY0 = 1U [static, private]

Magic constants needed by "period certification"

Definition at line 279 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::PARITY1 = width == 32 ? 0U : 0x13c9e68400000000ULL [static, private]

Definition at line 280 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::PARITY2 = 0U [static, private]

Definition at line 281 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::PARITY3 = width == 32 ? 0x13c9e684UL : 0U [static, private]

Definition at line 282 of file RandomAlgorithm.hpp.

template<class RandomType >
const unsigned RandomLib::SFMT19937< RandomType >::PARITY_LSB = 0 [static, private]

Least significant bit of PARITY

Definition at line 286 of file RandomAlgorithm.hpp.

template<class RandomType >
const engine_type RandomLib::SFMT19937< RandomType >::mask = engine_t::mask [static, private]

Definition at line 287 of file RandomAlgorithm.hpp.

template<class RandomType >
const unsigned RandomLib::SFMT19937< RandomType >::version = 0x456e534dUL + (engine_t::width/32 - 1) [static]

A version number "EnSM" or "EnSN" to ensure safety of Save/Load. This needs to be unique across RandomAlgorithms.

Definition at line 294 of file RandomAlgorithm.hpp.


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

Generated on Thu Dec 31 15:24:30 2009 by  doxygen 1.6.1