Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Static Private Attributes
RandomLib::SFMT19937 Class Reference

The SFMT random number engine. More...

#include <RandomLib-2010-01/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

Private Attributes

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 PARITY1 = width == 32 ? 0U : 0x13c9e68400000000ULL
static const engine_type PARITY2 = 0U
static const engine_type PARITY3 = width == 32 ? 0x13c9e684UL : 0U

Static Private Attributes

static const unsigned width = engine_t::width
static const engine_type magic0 = width == 32 ? 0x1fffefULL : 0x1ecb7f001fffefULL
static const engine_type mask18 = engine_type(0xfffc0000fffc0000ULL)
static const engine_type PARITY0 = 1U
static const unsigned PARITY_LSB = 0
static const engine_type mask = engine_t::mask

Detailed Description

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://randomlib.sourceforge.net/


Member Typedef Documentation

The result RandomType

Definition at line 211 of file RandomAlgorithm.hpp.

The internal numeric type for SFMT19337::Transition

Definition at line 220 of file RandomAlgorithm.hpp.

The unsigned type of engine_t

Definition at line 226 of file RandomAlgorithm.hpp.


Member Enumeration Documentation

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 231 of file RandomAlgorithm.hpp.

anonymous enum
Enumerator:
N 

The size of the state. The long lag for SFMT19937

Definition at line 294 of file RandomAlgorithm.hpp.


Member Function Documentation

static void RandomLib::SFMT19937::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.

static engine_type RandomLib::SFMT19937::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 312 of file RandomAlgorithm.hpp.

static void RandomLib::SFMT19937::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.

void RandomLib::SFMT19937::CheckState ( const engine_type  state[],
Random_u32::type check 
) throw (std::out_of_range) [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 1173 of file Random.cpp.

static std::string RandomLib::SFMT19937::Name ( ) throw () [inline, static]

Return the name of the engine

Definition at line 332 of file RandomAlgorithm.hpp.

References RandomLib::MT19937::width.

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

Definition at line 1044 of file Random.cpp.

References SFMT19937_STEP32, and SFMT19937_REVSTEP32.

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

Definition at line 1111 of file Random.cpp.

References SFMT19937_STEP64, and SFMT19937_REVSTEP64.

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

Definition at line 1144 of file Random.cpp.

References STATIC_ASSERT.

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

Definition at line 1159 of file Random.cpp.

References STATIC_ASSERT.


Member Data Documentation

const unsigned RandomLib::SFMT19937::width = engine_t::width [static, private]

The width of the engine_t

Definition at line 230 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::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 265 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::magic1 = width == 32 ? 0x1ecb7fULL : 0x1ffff6001affffULL [private]

Definition at line 266 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::magic2 = width == 32 ? 0x1affffULL : 0ULL [private]

Definition at line 267 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::magic3 = width == 32 ? 0x1ffff6ULL : 0ULL [private]

Definition at line 268 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::mask18 = engine_type(0xfffc0000fffc0000ULL) [static, private]

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

Definition at line 273 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::PARITY0 = 1U [static, private]

Magic constants needed by "period certification"

Definition at line 278 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::PARITY1 = width == 32 ? 0U : 0x13c9e68400000000ULL [private]

Definition at line 279 of file RandomAlgorithm.hpp.

Definition at line 280 of file RandomAlgorithm.hpp.

const engine_type RandomLib::SFMT19937::PARITY3 = width == 32 ? 0x13c9e684UL : 0U [private]

Definition at line 281 of file RandomAlgorithm.hpp.

const unsigned RandomLib::SFMT19937::PARITY_LSB = 0 [static, private]

Least significant bit of PARITY

Definition at line 285 of file RandomAlgorithm.hpp.

Definition at line 286 of file RandomAlgorithm.hpp.

const unsigned RandomLib::SFMT19937::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 293 of file RandomAlgorithm.hpp.


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