Xoshiro256 structv0.1.0
pub struct Xoshiro256 {
// private fields
}
Constructors
Xoshiro256
pub func Xoshiro256(seed: uint64) -> Xoshiro256
A generator seeded by spreading seed through SplitMix64.
Every seed is acceptable, zero included: the mixer's output is what fills the state, and it cannot
produce four zero words from any seed. Seeding by copying the seed into one word and leaving the rest
zero — which is what a caller does by hand — gives a state so close to the fixed point that the first
several outputs are visibly poor, which is the whole reason this goes through the mixer.
| Name | Type | Description |
|---|---|---|
seed | uint64 | the value the generator starts from |
Returns: a generator seeded with that value
Associated functions
FromState
pub func FromState(words: uint64[N]) -> Xoshiro256
A generator from four words of state given directly, for reproducing a stream recorded elsewhere. An all-zero state is the one state with no future, so it is replaced by the mixer's output for a zero seed rather than accepted into a generator that would return zero forever.
| Name | Type | Description |
|---|---|---|
words | uint64[N] | the generator's state words, taken as they are |
Returns: a generator with exactly those state words
Implements RandomGenerator
Xoshiro256 conforms to RandomGenerator.
NextUint64
pub func NextUint64(self: &var Xoshiro256) -> uint64
The next word. The result is computed from the state before it advances, which is the published order and the reason two implementations agree on the first word rather than being one step apart forever.
Returns: the next 64 bits
Related
XoshiroFromEntropy
pub func XoshiroFromEntropy() -> Xoshiro256 ! EntropyError
A Xoshiro256 seeded from the operating system's entropy.
Fails with why the entropy could not be obtained. A caller that is content with a predictable generator when
the system has no entropy recovers explicitly, as in XoshiroFromEntropy() catch { else => Xoshiro256(0u64) }.
Returns: a generator seeded from the system, or why it could not be seeded