Struct Lcg64Xsh32
struct Lcg64Xsh32 { ... }
A PCG random number generator (XSH RR 64/32 (LCG) variant).
Permuted Congruential Generator with 64-bit state, internal Linear Congruential Generator, and 32-bit output via "xorshift high (bits), random rotation" output function.
This is a 64-bit LCG with explicitly chosen stream with the PCG-XSH-RR
output function. This combination is the standard pcg32.
Despite the name, this implementation uses 16 bytes (128 bit) space
comprising 64 bits of state and 64 bits stream selector. These are both set
by SeedableRng, using a 128-bit seed.
Note that two generators with different stream parameter may be closely correlated.
Implementations
impl Lcg64Xsh32
fn advance(self: &mut Self, delta: u64)Multi-step advance functions (jump-ahead, jump-back)
The method used here is based on Brown, "Random Number Generation with Arbitrary Stride,", Transactions of the American Nuclear Society (Nov. 1994). The algorithm is very similar to fast exponentiation.
Even though delta is an unsigned integer, we can pass a signed integer to go backwards, it just goes "the long way round".
Using this function is equivalent to calling
next_32()deltanumber of times.fn new(state: u64, stream: u64) -> SelfConstruct an instance compatible with PCG seed and stream.
Note that the highest bit of the
streamparameter is discarded to simplify upholding internal invariants.Note that two generators with different stream parameters may be closely correlated.
PCG specifies the following default values for both parameters:
state = 0xcafef00dd15ea5e5stream = 0xa02bdbf7bb3c0a7
impl Clone for Lcg64Xsh32
fn clone(self: &Self) -> Lcg64Xsh32
impl Debug for Lcg64Xsh32
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Lcg64Xsh32
impl Freeze for Lcg64Xsh32
impl PartialEq for Lcg64Xsh32
fn eq(self: &Self, other: &Lcg64Xsh32) -> bool
impl RefUnwindSafe for Lcg64Xsh32
impl RngCore for Lcg64Xsh32
fn next_u32(self: &mut Self) -> u32fn next_u64(self: &mut Self) -> u64fn fill_bytes(self: &mut Self, dest: &mut [u8])
impl SeedableRng for Lcg64Xsh32
fn from_seed(seed: <Self as >::Seed) -> SelfWe use a single 127-bit seed to initialise the state and select a stream. One
seedbit (lowest bit ofseed[8]) is ignored.
impl Send for Lcg64Xsh32
impl Serialize for Lcg64Xsh32
fn serialize<__S>(self: &Self, __serializer: __S) -> Result<<__S as >::Ok, <__S as >::Error> where __S: Serializer
impl StructuralPartialEq for Lcg64Xsh32
impl Sync for Lcg64Xsh32
impl Unpin for Lcg64Xsh32
impl UnsafeUnpin for Lcg64Xsh32
impl UnwindSafe for Lcg64Xsh32
impl<'de> Deserialize for Lcg64Xsh32
fn deserialize<__D>(__deserializer: __D) -> Result<Self, <__D as >::Error> where __D: Deserializer<'de>
impl<R> TryRngCore for Lcg64Xsh32
fn try_next_u32(self: &mut Self) -> Result<u32, <R as TryRngCore>::Error>fn try_next_u64(self: &mut Self) -> Result<u64, <R as TryRngCore>::Error>fn try_fill_bytes(self: &mut Self, dst: &mut [u8]) -> Result<(), <R as TryRngCore>::Error>
impl<T> Any for Lcg64Xsh32
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Lcg64Xsh32
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Lcg64Xsh32
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Lcg64Xsh32
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> DeserializeOwned for Lcg64Xsh32
impl<T> From for Lcg64Xsh32
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Lcg64Xsh32
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Lcg64Xsh32
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Lcg64Xsh32
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Lcg64Xsh32
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>