The OpenD Programming Language

SplitMixEngine

Generic SplitMixEngine.

The first parameter mixer should be a explicit instantiation of fmix64 or a predefined parameterization of fmix64 such as murmurHash3Mix or staffordMix13.

The second parameter is whether the split operation is enabled. Allows each instance to have a distinct increment, increasing the size from 64 bits to 128 bits. If split is not enabled then the opCall, seed, and skip operations will be shared provided the platform supports 64-bit atomic operations.

The third parameter is the default_increment. If the SplitMixEngine has a fixed increment this value will be used for each instance. If omitted this parameter defaults to DEFAULT_SPLITMIX_INCREMENT.

Constructors

this
this(ulong x0)

Constructs a SplitMixEngine generator seeded with x0.

this
this(ulong x0, ulong increment)

Constructs a SplitMixEngine generator seeded with x0 using the specified increment.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Aliases

gamma
alias gamma = increment

Either an enum or a settable value depending on whether increment_specifiable == true. This should always be an odd number. The paper refers to this as γ so it is aliased as gamma.

popFrontExactly
alias popFrontExactly() = skip

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

Functions

opCall
ulong opCall()

Advances the random sequence.

opIndex
ulong opIndex(size_t n)
popFront
void popFront()
popFrontN
size_t popFrontN(size_t n)
seed
void seed(ulong x0)
void seed(ulong x0, ulong increment)

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

skip
void skip(size_t n)

Skip forward in the random sequence in O(1) time.

split
typeof(this) split()

Produces a splitmix generator with a different counter-value and increment-value than the current generator. Only available when <a href="#.SplitMixEngine.increment_specifiable"> increment_specifiable == true</a>.

Properties

front
ulong front [@property getter]
save
typeof(this) save [@property getter]

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

Variables

default_increment
enum ulong default_increment;

Either DEFAULT_SPLITMIX_INCREMENT or the optional third argument of this template.

empty
enum bool empty;

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

increment
ulong increment;
enum ulong increment;

Either an enum or a settable value depending on whether increment_specifiable == true. This should always be an odd number. The paper refers to this as γ so it is aliased as gamma.

increment_specifiable
enum bool increment_specifiable;

Whether each instance can set its increment individually. Enables the split operation at the cost of increasing size from 64 bits to 128 bits.

isRandomEngine
enum bool isRandomEngine;

Marks as a Mir random engine.

isUniformRandom
enum bool isUniformRandom;

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

max
enum ulong max;

Largest generated value.

min
enum ulong min;

Compatibility with Phobos library methods. Presents this RNG as an InputRange.

period_pow2
enum uint period_pow2;

Full period (2 ^^ 64).

state
ulong state;

Current internal state of the generator.

Examples

//Can specify engine like this:
alias RNG1 = SplitMixEngine!staffordMix13;
alias RNG2 = SplitMixEngine!(fmix64!(0xbf58476d1ce4e5b9UL, 0x94d049bb133111ebUL, 30, 27, 31));

//Each way of writing it results in the same sequence.
assert(RNG1(1).opCall() == RNG2(1).opCall());

//However not each result's name is equally informative.
static assert(RNG1.stringof == `SplitMixEngine!(staffordMix13, false)`);
static assert(RNG2.stringof == `SplitMixEngine!(fmix64, false)`);//Doesn't include parameters of fmix64!

Meta