The OpenD Programming Language

Xorshift64Star32

Generates 32 bits of output from 64 bits of state. A fast generator with excellent statistical properties for memory-constrained situations where more than 64 bits of state would be too much and generating only 32 bits with each opCall will not cause a slowdown. If you need a generator with 64 bits of state that produces output 64 bits at a time SplitMix64 is an option.

Note that xorshift64*/32 is slower than xorshift1024* even when only 32 bits of output are needed at a time. <a href="https://web.archive.org/web/20151209100332/http://xorshift.di.unimi.it:80/"> Per Vigna:</a> <blockquote> The three xor/shifts of a xorshift64* generator must be executed sequentially, as each one is dependent on the result of the previous one. In a xorshift1024* generator two of the xor/shifts are completely independent and can be parallelized internally by the CPU. </blockquote>

<a href="https://web.archive.org/web/20151011045529/http://xorshift.di.unimi.it:80/xorshift64star.c"> Public domain xorshift64* reference implementation (Internet Archive).</a>

import mir.random.engine.xorshift;
alias Xorshift64Star32 = XorshiftStarEngine!(ulong, 64, 12, 25, 27, 2685821657736338717uL, uint)

Examples

import mir.random.engine : isSaturatedRandomEngine;
static assert(isSaturatedRandomEngine!Xorshift64Star32);
Xorshift64Star32 rnd = Xorshift64Star32(123456789);
uint x = rnd();
assert(x == 3988833114);

Meta