ars5

The ars5 counter-based pseudorandom number generator.

Description

The ars5 engine is a keyed family of counter-based BRNG. The state consists of a 128-bit integer counter c and a 128-bit key k. The BRNG is based on the AES encryption algorithm [FIPS-197].

Generation algorithm

The generator has a 32-bit integer output obtained in the following way [Salmon11]:

  1. The i-th number is defined by the following formula ri=(f(i/4)>>((i mod 4)32)) mod 232

  2. Function f(c) takes a 128-bit argument and returns a 128-bit number. The returned number is obtained as follows:

    2.1. c0=ck and k0=k.

    2.2. The following recurrence is calculated N = 5 times:

    ci+1=SubBytes(c)

    ci+1=ShiftRows(ci+1)

    ci+1=MixColumns(ci+1), this step is omitted if i+1=N

    ci+1=AddRoundKey(ci+1,kj)

    Lo(ki+1)=Lo(k)+0x9E3779B97F4A7C15

    Hi(ki+1)=Hi(k)+0xBB67AE8584CAA73B

    Specification for SubBytes,ShiftRows,MixColumns,AddRoundKey functions can be found in [FIPS-197].

    2.3. Put f(c)=cN, where N=10

  3. Real output: un=(int)rn/232+1/2

class ars5

Syntax

namespace oneapi::mkl::rng {
class ars5 {
public:
        static constexpr std::uint64_t default_seed = 0;

        ars5(sycl::queue queue, std::uint64_t seed = default_seed);

        ars5(sycl::queue queue, std::initializer_list<std::uint64_t> seed);

        ars5(const ars5& other);

        ars5(ars5&& other);

        ars5& operator=(const ars5& other);

        ars5& operator=(ars5&& other);

        ~ars5();
};
}

Class Members

Routine

Description

ars5(sycl::queue queue, std::uint64_t seed)

Constructor for common seed initialization of the engine

ars5(sycl::queue queue, std::initializer_list<std::uint64_t> seed)

Constructor for extended seed initialization of the engine

ars5(const ars5& other)

Copy constructor

ars5(ars5&& other)

Move constructor

ars5& operator=(const ars5& other)

Copy assignment operator

ars5& operator=(ars5&& other)

Move assignment operator

Constructors

ars5::ars5(sycl::queue queue, std::uint64_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, assume k=seed,c=0, where k is 128-bit key, c is 128-bit counter.

ars5::ars5(sycl::queue queue, std::initializer_list<std::uint64_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, assume if n=0:k=0,c=0

if n=1:k=seed[0],c=0

if n=2:k=seed[0]+seed[1]264,c=0

if n=3:k=seed[0]+seed[1]264,c=seed[2]

if n=4:k=seed[0]+seed[1]264,c=seed[2]+seed[3]264

for n>4 following arguments are ignored

ars5::ars5(const ars5& other)

Input Parameters

other

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

ars5::ars5(ars5&& other)

Input Parameters

other

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

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

Input Parameters

other

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

ars5::ars5& operator=(ars5&& other)

Input Parameters

other

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

Parent topic: Engines (Basic Random Number Generators)