View source code
Display the source code in std/random.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Struct std.random.XorshiftEngine
Xorshift generator using 32bit algorithm.
struct XorshiftEngine(UIntType, UIntType bits, UIntType a, UIntType b, UIntType c)
if (isUnsigned!UIntType);
Implemented according to Xorshift RNGs.
Supporting bits are below, bits
means second parameter of XorshiftEngine.
bits | period |
---|---|
32 | 2^32 - 1 |
64 | 2^64 - 1 |
96 | 2^96 - 1 |
128 | 2^128 - 1 |
160 | 2^160 - 1 |
192 | 2^192 - 2^32 |
Constructors
Name | Description |
---|---|
this
|
Constructs a XorshiftEngine generator seeded with x0.
|
Properties
Name | Type | Description |
---|---|---|
front [get]
|
UIntType | Returns the current number in the random sequence. |
save [get]
|
typeof(this) | Captures a range state. |
Methods
Name | Description |
---|---|
opEquals
|
Compares against rhs for equality. |
popFront
|
Advances the random sequence. |
seed
|
(Re)seeds the generator. |
Example
alias Xorshift96 = XorshiftEngine!(uint, 96, 10, 5, 26);
auto rnd = Xorshift96(42);
auto num = rnd .front; // same for each run
writeln(num); // 2704588748
Authors
Andrei Alexandrescu Masahiro Nakagawa (Xorshift random generator) Joseph Rushton Wakeling (Algorithm D for random sampling) Ilya Yaroshenko (Mersenne Twister implementation, adapted from mir-random)
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.