The OpenD Programming Language

SplitMix64

Canonical fixed increment (non-splittable) SplitMix64 engine.

64 bits of state, period of 2 ^^ 64.

import mir.random.engine.splitmix;
@nogc nothrow @safe
alias SplitMix64 = SplitMixEngine!(staffordMix13, false)

Examples

import mir.random;
static assert(isSaturatedRandomEngine!SplitMix64);
auto rng = SplitMix64(1u);
ulong x = rng.rand!ulong;
assert(x == 10451216379200822465UL);
import mir.random;
import std.range.primitives: isRandomAccessRange;
// SplitMix64 should be both a Mir-style saturated
// random engine and a Phobos-style uniform RNG
// and random access range.
static assert(isPhobosUniformRNG!SplitMix64);
static assert(isRandomAccessRange!SplitMix64);
static assert(isSaturatedRandomEngine!SplitMix64);

SplitMix64 a = SplitMix64(1);
immutable ulong x = a.front;
SplitMix64 b = a.save;
assert (x == a.front);
assert (x == b.front);
assert (x == a[0]);

immutable ulong y = a[1];
assert(x == a());
assert(x == b());
assert(a.front == y);

Meta