tinymt-cpp  0.0.1
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > Class Template Reference

Pseudo-random number generator engine based on the TinyMT algorithms. More...

#include <tinymt.h>

Public Types

using result_type = UIntType
 Integral type generated by the engine. More...
 
using param_type = typename impl::param_type
 Type of the generator parameter set. More...
 

Public Member Functions

template<TINYMT_CPP_ENABLE_WHEN(!status_type::is_dynamic::value) >
 tinymt_engine (result_type seed=default_seed)
 Constructs the engine (non-DC mode). More...
 
template<TINYMT_CPP_ENABLE_WHEN(status_type::is_dynamic::value) >
 tinymt_engine (const param_type &param, result_type seed=default_seed)
 Constructs the engine (DC mode). More...
 
void seed (result_type value=default_seed)
 Reinitializes the engine. More...
 
void discard (unsigned long long z)
 Advances the state of the engine by the given amount. More...
 
result_type operator() ()
 Returns the next pseudo-random number. More...
 

Static Public Member Functions

static constexpr result_type min ()
 Returns the smallest possible value in the output range. More...
 
static constexpr result_type max ()
 Returns the largest possible value in the output range. More...
 

Static Public Attributes

static constexpr std::size_t word_size = WordSize
 Word size that determines the range of numbers generated by the engine. More...
 
static constexpr std::size_t state_size = impl::state_size
 Size of the state of the generator in words. More...
 
static constexpr result_type default_seed = 1
 Default seed. More...
 

Friends

bool operator== (const tinymt_engine &a, const tinymt_engine &b)
 Compares two engines. More...
 
bool operator!= (const tinymt_engine &a, const tinymt_engine &b)
 Compares two engines. More...
 
template<class CharT , class Traits >
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &os, const tinymt_engine &e)
 Serializes the state of the given engine into a stream. More...
 
template<class CharT , class Traits >
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &is, tinymt_engine &e)
 Deserializes the state of the given engine from a stream. More...
 

Detailed Description

template<class UIntType, std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
class tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >

Pseudo-random number generator engine based on the TinyMT algorithms.

Template Parameters
UIntTypeunsigned integral type generated by the engine
WordSizeword size for the generated numbers
Mat1parameter used in the linear state transition function
Mat2parameter used in the linear state transition function
TMatparameter used in the non-linear output function
DoPeriodCertificationwhether or not period certification is performed in initialization
Note
Currently WordSize must be 32.
When Mat, Mat2 and TMat are all zero, the generator parameter set must be provided in initialization ("Dynamic Creation" (DC) mode).

Member Typedef Documentation

◆ param_type

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
using tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::param_type = typename impl::param_type

Type of the generator parameter set.

◆ result_type

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
using tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::result_type = UIntType

Integral type generated by the engine.

Constructor & Destructor Documentation

◆ tinymt_engine() [1/2]

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
template<TINYMT_CPP_ENABLE_WHEN(!status_type::is_dynamic::value) >
tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::tinymt_engine ( result_type  seed = default_seed)
inlineexplicit

Constructs the engine (non-DC mode).

Parameters
seedrandom seed

◆ tinymt_engine() [2/2]

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
template<TINYMT_CPP_ENABLE_WHEN(status_type::is_dynamic::value) >
tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::tinymt_engine ( const param_type param,
result_type  seed = default_seed 
)
inlineexplicit

Constructs the engine (DC mode).

Parameters
paramparameter set
seedrandom seed

Member Function Documentation

◆ discard()

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
void tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::discard ( unsigned long long  z)
inline

Advances the state of the engine by the given amount.

Parameters
znumber of advances

◆ max()

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
static constexpr result_type tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::max ( )
inlinestatic

Returns the largest possible value in the output range.

Returns
largest value

◆ min()

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
static constexpr result_type tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::min ( )
inlinestatic

Returns the smallest possible value in the output range.

Returns
smallest value

◆ operator()()

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
result_type tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::operator() ( )
inline

Returns the next pseudo-random number.

Returns
generated value

◆ seed()

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
void tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::seed ( result_type  value = default_seed)
inline

Reinitializes the engine.

Parameters
valuerandom seed

Friends And Related Function Documentation

◆ operator!=

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
bool operator!= ( const tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  a,
const tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  b 
)
friend

Compares two engines.

Parameters
afirst engine
bsecond engine
Returns
true if the engines are not equivalent including their internal states, false otherwise

◆ operator<<

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
template<class CharT , class Traits >
std::basic_ostream<CharT, Traits>& operator<< ( std::basic_ostream< CharT, Traits > &  os,
const tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  e 
)
friend

Serializes the state of the given engine into a stream.

Parameters
osoutput stream
eengine to be serialized
Returns
os

◆ operator==

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
bool operator== ( const tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  a,
const tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  b 
)
friend

Compares two engines.

Parameters
afirst engine
bsecond engine
Returns
true if the engines are equivalent including their internal states, false otherwise

◆ operator>>

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
template<class CharT , class Traits >
std::basic_istream<CharT, Traits>& operator>> ( std::basic_istream< CharT, Traits > &  is,
tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification > &  e 
)
friend

Deserializes the state of the given engine from a stream.

Parameters
isinput stream
eengine to be deserialized
Returns
is

Member Data Documentation

◆ default_seed

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
constexpr result_type tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::default_seed = 1
static

Default seed.

◆ state_size

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
constexpr std::size_t tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::state_size = impl::state_size
static

Size of the state of the generator in words.

◆ word_size

template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
constexpr std::size_t tinymt::tinymt_engine< UIntType, WordSize, Mat1, Mat2, TMat, DoPeriodCertification >::word_size = WordSize
static

Word size that determines the range of numbers generated by the engine.


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