mcg31m1

Contents

mcg31m1#

The 31-bit multiplicative congruential pseudorandom number generator MCG(1132489760, 231 -1).

Description

The mcg31m1 engine is a 31-bit multiplicative congruential generator [L’Ecuyer99]. The mcg31m1 generator belongs to linear congruential generators with the period length of approximately \(2^{31}\). Such generators are still used as default random number generators in various software systems, mainly due to the simplicity of the portable versions implementation, speed, and compatibility with the earlier systems versions. However, their period length does not meet the requirements for modern basic generators. Still, the mcg31m1 generator possesses good statistic properties and you may successfully use it to generate random numbers of different distributions for small samplings.

Generation algorithm

\(x_n=ax_{n-1}(mod \ m)\)

\(u_n = x_n / m\)

\(a = 1132489760, m=2^{31} - 1\)

class mcg31m1#

Syntax

namespace oneapi::math::rng {
class mcg31m1 {
public:
    static constexpr std::uint32_t default_seed = 1;

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

    mcg31m1(const mcg31m1& other);

    mcg31m1(mcg31m1&& other);

    mcg31m1& operator=(const mcg31m1& other);

    mcg31m1& operator=(mcg31m1&& other);

    ~mcg31m1();
};
}

Class Members

Routine

Description

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

Constructor for common seed initialization of the engine

mcg31m1(const mcg31m1& other)

Copy constructor

mcg31m1(mcg31m1&& other)

Move constructor

mcg31m1& operator=(const mcg31m1& other)

Copy assignment operator

mcg31m1& operator=(mcg31m1&& other)

Move assignment operator

Constructors

mcg31m1::mcg31m1(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, assume \(x_0 = seed \ mod \ 0x7FFFFFFF\), if \(x_0 = 0\), assume \(x_0 = 1\).

mcg31m1::mcg31m1(const mcg31m1& other)

Input Parameters

other

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

mcg31m1::mcg31m1(mcg31m1&& other)

Input Parameters

other

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

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

Input Parameters

other

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

mcg31m1::mcg31m1& operator=(mcg31m1&& other)

Input Parameters

other

Valid mcg31m1 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)