SplitMix64 structv0.1.0

Source
The seeding generator: a fast mixer with a 64-bit state, used to spread one seed over a larger one.
pub struct SplitMix64 {
    // private fields
}

Not for general use — its period is only 2^64 and it fails statistical tests a real generator passes. Its job is the one thing it is very good at: turning a seed a human chose, which is very likely to be zero or one or a timestamp, into a full-entropy state for a generator that deserves better input than that. Seeding a 256-bit generator by copying a small integer into one word and leaving the rest zero is a classic way to get correlated streams out of an excellent algorithm.

Constructors

SplitMix64

pub func SplitMix64(seed: uint64) -> SplitMix64

A mixer starting from seed. Every seed is acceptable, including zero.

NameTypeDescription
seeduint64the value the generator starts from

Returns: a generator seeded with that value

Source

Implements RandomGenerator

SplitMix64 conforms to RandomGenerator.

NextUint64

pub func NextUint64(self: &var SplitMix64) -> uint64

The next word: the state advanced by an odd constant, then avalanched. The additive step guarantees the full period of 2^64 whatever the seed, and the mixing afterwards is what turns a counter into something that looks random. Both constants are Steele, Lea and Flood's.

Returns: the next 64 bits

Source