How to create a custom Murmur Avalanche Mixer?

寵の児 提交于 2019-12-05 15:29:11

If you really are interested not in collisions, but in the randomness of the results, then you should try to use PRNG with 128bits state and 64bits output.

And pretty good is well-known PRNG called Xoroshiro128+ - fast, quite good randomness.

Code could be found here

UPDATE

Yes, looks like problem to use it for caching due to the fact RNG returns first just a sum modulo 264. Wondering if simple modification (basically, moving result computation after the rotations/xors) will help

static inline uint64_t rotl(const uint64_t x, int k) {
    return (x << k) | (x >> (64 - k));
}

uint64_t next(uint64_t* s) {
    const uint64_t s0 = s[0];
    uint64_t s1 = s[1];

    s1 ^= s0;
    s[0] = rotl(s0, 55) ^ s1 ^ (s1 << 14); // a, b
    s[1] = rotl(s1, 36); // c

    return s[0] + s[1];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!