Pcg64Dxsm structv0.1.0
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.
| Name | Type | Description |
|---|---|---|
seed | uint64 | the value the generator starts from |
Returns: a generator seeded with that value, on the default stream
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.
| Name | Type | Description |
|---|---|---|
seed | uint64 | the value the generator starts from |
stream | uint64 | which of the generator's independent sequences to draw from |
Returns: a generator seeded with that value, on the given stream
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
Related
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.
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.
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.
Parameters
| Name | Type | Description |
|---|---|---|
stream | uint64 | which 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