mt19937¶

Mersenne Twister pseudorandom number generator.

Description

The Mersenne Twister pseudorandom number generator, mt19937, is a modification of twisted generalized feedback shift register generator [Matsumoto98]. MT19937 has the period length of $$2^{19937} - 1$$ and is 623-dimensionally equidistributed with up to 32-bit accuracy. These properties make the generator applicable for simulations in various fields of science and engineering. The state of the generator is represented by 624 32-bit unsigned integer numbers.

Generation algorithm

$$x_{n}=x_{n-(624-397)} \oplus ( (x_{n-624} \& 0x80000000) | (x_{n - 624 + 1} \& 0x7FFFFFFF) )A$$

$$y_{n} = x_{n}$$

$$y_{n} = y_{n} \oplus (y_{n} >> 11)$$

$$y_{n} = y_{n} \oplus ( (y_{n} << 7) \& 0x9D2C5680)$$

$$y_{n} = y_{n} \oplus ( (y_{n} << 15) \& 0xEFC60000)$$

$$y_{n} = y_{n} \oplus (y_{n} >> 18)$$

$$u_{n} = y_{n} / 2^{32}$$

Matrix $$A_j(32x32)$$ has the following format:

$\begin{split}\left [ \begin{array}{ccccc} 0 & 1 & 0 & ... & ... \\ 0 & 0 & ... & 0 & ... \\ ... & ... & ... & ... & ... \\ 0 & ... & 0 & 0 & 1 \\ a_{31} & a_{30} & ... & ... & a_{0} \end{array}\right ]\end{split}$

Where the 32-bit vector $$a = a_{31}..a_{0}$$ has the value $$a=0x9908B0DF$$.

class mt19937¶

Syntax

namespace oneapi::mkl::rng {
class mt19937 {
public:
static constexpr std::uint32_t default_seed = 1;

mt19937(sycl::queue queue, std::uint32_t seed = default_seed);

mt19937(sycl::queue queue, std::initializer_list<std::uint32_t> seed);

mt19937(const mt19937& other);

mt19937(mt19937&& other);

mt19937& operator=(const mt19937& other);

mt19937& operator=(mt19937&& other);

~mt19937();
};
}


Class Members

Routine

Description

mt19937(sycl::queue queue, std::uint32_t seed = default_seed)

Constructor for common seed initialization of the engine

mt19937(sycl::queue queue, std::initializer_list<std::uint32_t> seed)

Constructor for extended seed initialization of the engine

mt19937(const mt19937& other)

Copy constructor

mt19937(mt19937&& other)

Move constructor

mt19937& operator=(const mt19937& other)

Copy assignment operator

mt19937& operator=(mt19937&& other)

Move assignment operator

Constructors

mt19937::mt19937(sycl::queue queue, std::uint32_t seed = default_seed)


Input Parameters

queue

Valid sycl::queue object, calls of the oneapi::mkl::rng::generate() routine submits kernels in this queue to obtain random numbers from a given engine.

seed

The initial conditions of the generator state. The initialization algorithm described in [MT2203].

mt19937::mt19937(sycl::queue queue, std::initializer_list<std::uint32_t> seed)


Input Parameters

queue

Valid sycl::queue object, calls of the oneapi::mkl::rng::generate() routine submits kernels in this queue to obtain random numbers from a given engine.

seed

The initial conditions of the generator state. The initialization algorithm described in [MT2203].

mt19937::mt19937(const mt19937& other)


Input Parameters

other

Valid mt19937 object. The queue and state of the other engine is copied and applied to the current engine.

mt19937::mt19937(mt19937&& other)


Input Parameters

other

Valid mt19937 object. The queue and state of the other engine is moved to the current engine.

mt19937::mt19937& operator=(const mt19937& other)


Input Parameters

other

Valid mt19937 object. The queue and state of the other engine is copied and applied to the current engine.

mt19937::mt19937& operator=(mt19937&& other)


Input Parameters

other

Valid mt19937 r-value object. The queue and state of the other engine is moved to the current engine.

Parent topic: Engines (Basic Random Number Generators)