pub struct PCG32 {
pub state: u64,
pub inc: u64,
}
Expand description
A Permuted Congruential Generator with 32-bit output.
- Period:
2**64
wheninc
is odd, otherwise less
Fields§
§state: u64
The generator’s state.
This changes with each step of the generator. It’s the generator’s “position” within the output stream.
inc: u64
The generator’s increment.
This doesn’t change as the generator advances. Instead it determines which
of the possible output streams the generator will use. Each inc
value
will give a different ordering of all the possible outputs.
Implementations§
Source§impl PCG32
impl PCG32
Sourcepub const fn new(state: u64, inc: u64) -> Self
pub const fn new(state: u64, inc: u64) -> Self
Creates a new generator by directly using the value given.
When a raw state
value is selected manually, the initial output of the
generator will frequently be 0. If the initial state
is not from a
randomization source then you should probably call seed
instead.
Sourcepub fn from_getrandom() -> Result<Self, Error>
Available on crate feature getrandom
only.
pub fn from_getrandom() -> Result<Self, Error>
getrandom
only.Create a new generator seeded with data from getrandom.
This method ensures that the inc
of the new generator is odd.