Reference

using tinymt::tinymt32 = tinymt_engine<uint_fast32_t, 32, detail::tinymt32_default_param_mat1, detail::tinymt32_default_param_mat2, detail::tinymt32_default_param_tmat, false>

TinyMT32 generator engine with the parameter set specified in RFC 8682.

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

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

Note

Currently WordSize must be 32.

Note

When Mat, Mat2 and TMat are all zero, the generator parameter set must be provided in initialization (“Dynamic Creation” (DC) mode).

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

Public Types

using result_type = UIntType

Integral type generated by the engine.

using param_type = typename impl::param_type

Type of the generator parameter set.

Public Functions

template<TINYMT_CPP_ENABLE_WHEN(!status_type::is_dynamic::value)> tinymt_engine (result_type seed=default_seed)

Constructs the engine (non-DC mode).

Parameters
  • seed: random seed

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

Parameters
  • param: parameter set

  • seed: random seed

void seed(result_type value = default_seed)

Reinitializes the engine.

Parameters
  • value: random seed

void discard(unsigned long long z)

Advances the state of the engine by the given amount.

Parameters
  • z: number of advances

result_type operator()()

Returns the next pseudo-random number.

Return

generated value

Public Static Functions

constexpr result_type min()

Returns the smallest possible value in the output range.

Return

smallest value

constexpr result_type max()

Returns the largest possible value in the output range.

Return

largest value

Public Static Attributes

constexpr std::size_t word_size = WordSize

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

constexpr std::size_t state_size = impl::state_size

Size of the state of the generator in words.

constexpr result_type default_seed = 1

Default seed.

Friends

friend bool operator==(const tinymt_engine &a, const tinymt_engine &b)

Compares two engines.

Return

true if the engines are equivalent including their internal states, false otherwise

Parameters
  • a: first engine

  • b: second engine

friend bool operator!=(const tinymt_engine &a, const tinymt_engine &b)

Compares two engines.

Return

true if the engines are not equivalent including their internal states, false otherwise

Parameters
  • a: first engine

  • b: second engine

template<class CharT, class Traits>
friend 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.

Return

os

Parameters
  • os: output stream

  • e: engine to be serialized

template<class CharT, class Traits>
friend 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.

Return

is

Parameters
  • is: input stream

  • e: engine to be deserialized