Pcg64Dxsm structv0.1.0

Source
A PCG64-DXSM generator.
pub struct Pcg64Dxsm {
    // private fields
}

Constructors

Pcg64Dxsm

pub func Pcg64Dxsm(seed: uint64) -> Pcg64Dxsm

A generator seeded by spreading seed through SplitMix64, on the default stream.

NameTypeDescription
seeduint64the value the generator starts from

Returns: a generator seeded with that value, on the default stream

Source

Associated functions

WithStream

pub func WithStream(
    seed: uint64,
    stream: uint64
) -> Pcg64Dxsm

A generator on the stream stream selects. Two generators with the same seed and different streams produce unrelated sequences of the same period, which is how independent parallel streams are made without the workers having to agree on anything but their own index.

NameTypeDescription
seeduint64the value the generator starts from
streamuint64which of the generator's independent sequences to draw from

Returns: a generator seeded with that value, on the given stream

Source

Implements RandomGenerator

Pcg64Dxsm conforms to RandomGenerator.

NextUint64

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

The next word. The output is computed from the state before it advances. The high half is folded twice and then multiplied by the low half forced odd — an odd multiplier is invertible, so that last step permutes the value rather than collapsing any of it.

Returns: the next 64 bits

Source

PcgMultiplier

pub const PcgMultiplier: uint64 = 0xDA942042E4DD58B5;

The multiplier used by both the state step and the output function. PCG's "cheap" 64-bit multiplier, which the DXSM variant uses in the 128-bit step as well.

Source

PcgFromEntropy

pub func PcgFromEntropy() -> Pcg64Dxsm ! EntropyError

A Pcg64Dxsm seeded from the operating system's entropy, on the default stream. Fails and recovers exactly as XoshiroFromEntropy does.

Source

Returns: a generator seeded from the system, or why it could not be seeded

PcgFromEntropyWithStream

pub func PcgFromEntropyWithStream(stream: uint64) -> Pcg64Dxsm ! EntropyError

A Pcg64Dxsm seeded from entropy on the stream stream selects. The intended shape for parallel work: every worker calls this with its own index, so the streams are independent by construction and the whole run is reproducible from the one seed if it is recorded.

Source

Parameters

NameTypeDescription
streamuint64which of the generator's independent sequences to draw from

Returns: a generator on that stream seeded from the system, or why it could not be seeded