RandomLib  1.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
RandomLib::SFMT19937< RandomType > Class Template Reference

The SFMT random number engine. More...

#include <RandomLib/RandomAlgorithm.hpp>

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

Static Public Attributes

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

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 gives 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.

Template Parameters
RandomTypethe type of the results, either Random_u32 or Random_u64.

Written by Charles Karney charl.nosp@m.es@k.nosp@m.arney.nosp@m..com and licensed under the MIT/X11 License. For more information, see http://randomlib.sourceforge.net/

Definition at line 233 of file RandomAlgorithm.hpp.

Member Typedef Documentation

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

The result RandomType

Definition at line 238 of file RandomAlgorithm.hpp.

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

The internal numeric type for SFMT19337::Transition

Definition at line 247 of file RandomAlgorithm.hpp.

Member Enumeration Documentation

template<class RandomType >
anonymous enum
Enumerator
N 

The size of the state. The long lag for SFMT19937

Definition at line 322 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.

Parameters
[in]counthow many batches to advance.
[in,out]statevthe internal state of the random number generator.
template<class RandomType >
static engine_type RandomLib::SFMT19937< RandomType >::Generate ( engine_type  y)
throw (
)
inlinestatic

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

Parameters
[in]ya word of the state.
Returns
the result.

Definition at line 346 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.

Parameters
[in,out]statethe state of the generator.
template<class RandomType >
void RandomLib::SFMT19937< RandomType >::CheckState ( const engine_type  state[],
Random_u32::type check 
)
static

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

Parameters
[in]statethe state of the generator.
[in,out]checkan accumulated checksum.

Definition at line 1170 of file Random.cpp.

template<class RandomType >
static std::string RandomLib::SFMT19937< RandomType >::Name ( )
throw (
)
inlinestatic

Return the name of the engine

Returns
the name.

Definition at line 372 of file RandomAlgorithm.hpp.

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

Definition at line 1041 of file Random.cpp.

References SFMT19937_REVSTEP32, and SFMT19937_STEP32.

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

Definition at line 1108 of file Random.cpp.

References SFMT19937_REVSTEP64, and SFMT19937_STEP64.

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

Definition at line 1141 of file Random.cpp.

References STATIC_ASSERT.

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

Definition at line 1156 of file Random.cpp.

References STATIC_ASSERT.

Member Data Documentation

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


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