Pseudo-random number generator engine based on the TinyMT algorithms.
More...
#include <tinymt.h>
|
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...
|
|
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
-
UIntType | unsigned integral type generated by the engine |
WordSize | word size for the generated numbers |
Mat1 | parameter used in the linear state transition function |
Mat2 | parameter used in the linear state transition function |
TMat | parameter used in the non-linear output function |
DoPeriodCertification | whether 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).
◆ param_type
template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
Type of the generator parameter set.
◆ result_type
template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
Integral type generated by the engine.
◆ 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) >
Constructs the engine (non-DC mode).
- Parameters
-
◆ 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) >
Constructs the engine (DC mode).
- Parameters
-
param | parameter set |
seed | random seed |
◆ 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
-
◆ max()
template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
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>
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>
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>
Reinitializes the engine.
- Parameters
-
◆ 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
-
a | first engine |
b | second 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
-
os | output stream |
e | engine 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
-
a | first engine |
b | second 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
-
is | input stream |
e | engine to be deserialized |
- Returns
is
◆ default_seed
template<class UIntType , std::size_t WordSize, UIntType Mat1, UIntType Mat2, UIntType TMat, bool DoPeriodCertification = true>
◆ 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: