Constructor (RNG instances can only be initialized with a specified seed).
Provides a copy of this RNG instance with identical internal state.
Range primitives
(Re)seeds the generator.
Range primitives
Marks this range as a uniform random number generator
Largest generated value
Smallest generated value (0)
import std.array : array; import std.random : isUniformRNG, randomSample, uniform; import std.range : iota, take; import dxorshift.splitmix64; // splitmix64 generators must be initialized // with a specified seed auto gen = SplitMix64(123456); // verify it is indeed a uniform RNG as defined // in the standard library, whether accessed // directly or via a pointer static assert(isUniformRNG!(typeof(gen))); static assert(isUniformRNG!(typeof(&gen))); // since the postblit is disabled, we must // pass a pointer to any functionality that // would otherwise copy the RNG by value assert((&gen).take(2).array == [4172122716518060777uL, 4753009419905186825uL]); // this means, of course, that we must guarantee // the lifetime of the pointer is valid for the // lifetime of any functionality that uses it auto sample = iota(100).randomSample(10, &gen).array; // however, we can pass the RNG as-is to any // functionality that takes it by ref and does // not try to copy it by value auto val = uniform!"()"(-0.5, 0.5, gen); // in circumstances where we really want to // copy the RNG state, we can use `dup` auto gen2 = gen.dup; assert((&gen).take(3).array == (&gen2).take(3).array);
This implementation is ported from the public-domain C implementation by Sebastiano Vigna, available at http://xoroshiro.di.unimi.it/splitmix64.c
For more details on the SplittableRandom generator, see http://dx.doi.org/10.1145/2714064.2660195 and http://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html
This is a fixed-increment version of Java 8's SplittableRandom generator. It is a very fast generator passing BigCrush, and can be useful if for some reason exactly 64 bits of state are needed; otherwise, it is suggested to use Xoroshiro128plus (for moderately parallel computations) or Xorshift1024star (for massively parallel computations).
The generator period is 2 ^^ 64.