WELLEngine

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

  1. alias WELLEngine(string name) = WELLEngine!(uint, name)
  2. struct WELLEngine(UIntType, string name)
    struct WELLEngine (
    UIntType
    string name
    ) if (
    name == "512a" ||
    name == "521a"
    ||
    name == "521b"
    ||
    name == "607a"
    ||
    name == "607b"
    ||
    name == "800a"
    ||
    name == "800b"
    ||
    name == "1024a"
    ||
    name == "1024b"
    ||
    name == "19937a"
    ||
    name == "19937b"
    ||
    name == "19937c"
    ||
    name == "21701a"
    ||
    name == "23209a"
    ||
    name == "23209b"
    ||
    name == "44497a"
    ||
    name == "44497b"
    ) {
    enum Constant;
    enum size_t _stateSize;
    enum uint MASKU;
    enum uint MASKU;
    enum uint MASKL;
    }

Constructors

this
this(uint value)

Members

Functions

popFront
void popFront()

range primitives

seed
void seed(uint value)

Manifest constants

isUniformRandom
enum isUniformRandom;

Mark as Random Number Generator

Properties

front
uint front [@property getter]
save
typeof(this) save [@property getter]
empty
enum bool empty;

range primitives

Variables

max
enum UIntType max;

maximum value

min
enum UIntType min;

minimum value

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