Struct Lcg128Xsl64
struct Lcg128Xsl64 { ... }
A PCG random number generator (XSL RR 128/64 (LCG) variant).
Permuted Congruential Generator with 128-bit state, internal Linear Congruential Generator, and 64-bit output via "xorshift low (bits), random rotation" output function.
This is a 128-bit LCG with explicitly chosen stream with the PCG-XSL-RR
output function. This combination is the standard pcg64.
Despite the name, this implementation uses 32 bytes (256 bit) space
comprising 128 bits of state and 128 bits stream selector. These are both
set by SeedableRng, using a 256-bit seed.
Note that two generators with different stream parameters may be closely correlated.
Implementations
impl Lcg128Xsl64
fn advance(self: &mut Self, delta: u128)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_64()deltanumber of times.fn new(state: u128, stream: u128) -> 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 = 0xa02bdbf7bb3c0a7ac28fa16a64abf96
impl Clone for Lcg128Xsl64
fn clone(self: &Self) -> Lcg128Xsl64
impl Debug for Lcg128Xsl64
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for Lcg128Xsl64
impl Freeze for Lcg128Xsl64
impl PartialEq for Lcg128Xsl64
fn eq(self: &Self, other: &Lcg128Xsl64) -> bool
impl RefUnwindSafe for Lcg128Xsl64
impl RngCore for Lcg128Xsl64
fn next_u32(self: &mut Self) -> u32fn next_u64(self: &mut Self) -> u64fn fill_bytes(self: &mut Self, dest: &mut [u8])
impl SeedableRng for Lcg128Xsl64
fn from_seed(seed: <Self as >::Seed) -> SelfWe use a single 255-bit seed to initialise the state and select a stream. One
seedbit (lowest bit ofseed[8]) is ignored.
impl Send for Lcg128Xsl64
impl Serialize for Lcg128Xsl64
fn serialize<__S>(self: &Self, __serializer: __S) -> Result<<__S as >::Ok, <__S as >::Error> where __S: Serializer
impl StructuralPartialEq for Lcg128Xsl64
impl Sync for Lcg128Xsl64
impl Unpin for Lcg128Xsl64
impl UnsafeUnpin for Lcg128Xsl64
impl UnwindSafe for Lcg128Xsl64
impl<'de> Deserialize for Lcg128Xsl64
fn deserialize<__D>(__deserializer: __D) -> Result<Self, <__D as >::Error> where __D: Deserializer<'de>
impl<R> TryRngCore for Lcg128Xsl64
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 Lcg128Xsl64
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Lcg128Xsl64
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Lcg128Xsl64
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Lcg128Xsl64
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> DeserializeOwned for Lcg128Xsl64
impl<T> From for Lcg128Xsl64
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Lcg128Xsl64
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Lcg128Xsl64
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 Lcg128Xsl64
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Lcg128Xsl64
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>