The OpenD Programming Language

staffordMix13

Well known sets of parameters for fmix64. Predefined are murmurHash3Mix and staffordMix01 through staffordMix14.

See David Stafford's 2011 blog entry Better Bit Mixing - Improving on MurmurHash3's 64-bit Finalizer.

import mir.random.engine.splitmix;
@nogc nothrow @safe
alias staffordMix13() = .fmix64!(0xbf58476d1ce4e5b9UL, 0x94d049bb133111ebUL, 30, 27, 31)

Examples

enum ulong x1 = murmurHash3Mix(0x1234_5678_9abc_defeUL);//Mix some number at compile time.
static assert(x1 == 0xb194_3cfe_a4f7_8f08UL);

immutable ulong x2 = murmurHash3Mix(0x1234_5678_9abc_defeUL);//Mix some number at run time.
assert(x1 == x2);//Same result.
//Verify all sets of predefined parameters are valid
//and no two are identical.
ulong[15] array;
array[0] = murmurHash3Mix(1);
array[1] = staffordMix01(1);
array[2] = staffordMix02(1);
array[3] = staffordMix03(1);
array[4] = staffordMix04(1);
array[5] = staffordMix05(1);
array[6] = staffordMix06(1);
array[7] = staffordMix07(1);
array[8] = staffordMix08(1);
array[9] = staffordMix09(1);
array[10] = staffordMix10(1);
array[11] = staffordMix11(1);
array[12] = staffordMix12(1);
array[13] = staffordMix13(1);
array[14] = staffordMix14(1);
foreach (i; 1 .. array.length)
    foreach (e; array[0 .. i])
        if (e == array[i])
            assert(0, "fmix64 predefines are not all distinct!");

Meta