mt19937

Contents

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 2199371 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

xn=xn(624397)((xn624&0x80000000)|(xn624+1&0x7FFFFFFF))A

yn=xn

yn=yn(yn>>11)

yn=yn((yn<<7)&0x9D2C5680)

yn=yn((yn<<15)&0xEFC60000)

yn=yn(yn>>18)

un=yn/232

Matrix Aj(32x32) has the following format:

[010......00...0..................0...001a31a30......a0]

Where the 32-bit vector a=a31..a0 has the value a=0x9908B0DF.

class mt19937#

Syntax

namespace oneapi::math::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::math::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::math::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: Host Engines (Basic Random Number Generators)