WELLEngine

WELL(512a) Random Number Generator. See: http://www.iro.umontreal.ca/~panneton/WELLRNG.html

  1. alias WELLEngine(string name) = WELLEngine!(uint, name)
    alias WELLEngine(string name) = WELLEngine!(uint, name)
  2. struct WELLEngine(UIntType, string name)

Examples

1 import std.algorithm;
2 import std.range;
3 import std.stdio;
4 
5 WELLEngine!"512a" rng;
6 
7 static assert(isUniformRNG!(typeof(rng)));
8 static assert(isSeedable!(typeof(rng)));
9 
10 rng.seed(100);
11 
12 assert(equal(rng.save.take(8),
13   [ 2230636158,
14     1842930638,
15     155680193,
16     1855495099,
17     2311897807,
18     3102313483,
19     3970788677,
20     3720522367,]));
21 
22 // save test
23 auto saved1 = rng.save;
24 auto saved2 = rng.save;
25 
26 rng.popFrontN(100);
27 assert(equal(saved1.save.take(64), saved2.save.take(64)));
28 
29 saved1.popFrontN(100);
30 assert(equal(rng.save.take(64), saved1.save.take(64)));
31 
32 assert(rng.front == 1947823519);
33 rng.popFront();
34 rng.popFrontN(10000);
35 assert(rng.front == 2831551372);

Meta