Struct Mcg128Xsl64
pub struct Mcg128Xsl64 { /* private fields */ }
A PCG random number generator (XSL 128/64 (MCG) variant).
Permuted Congruential Generator with 128-bit state, internal Multiplicative Congruential Generator, and 64-bit output via "xorshift low (bits), random rotation" output function.
This is a 128-bit MCG with the PCG-XSL-RR output function, also known as
pcg64_fast.
Note that compared to the standard pcg64 (128-bit LCG with PCG-XSL-RR
output function), this RNG is faster, also has a long cycle, and still has
good performance on statistical tests.
Implementations
impl Mcg128Xsl64
fn advance(&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) -> SelfConstruct an instance compatible with PCG seed.
Note that PCG specifies a default value for the parameter:
state = 0xcafef00dd15ea5e5
fn state(&self) -> u128Current state of the generator
Will always be odd.
Trait Implementations
impl Clone for Mcg128Xsl64
fn clone(&self) -> Mcg128Xsl64
impl Debug for Mcg128Xsl64
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Mcg128Xsl64
impl PartialEq for Mcg128Xsl64
fn eq(&self, other: &Mcg128Xsl64) -> bool
impl SeedableRng for Mcg128Xsl64
type Seed = [u8; 16];fn from_seed(seed: Self::Seed) -> Self
impl Serialize for Mcg128Xsl64
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer,
impl StructuralPartialEq for Mcg128Xsl64
impl TryRng for Mcg128Xsl64
type Error = never;fn try_next_u32(&mut self) -> Result<u32, Infallible>fn try_next_u64(&mut self) -> Result<u64, Infallible>fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Infallible>
impl<'de> Deserialize<'de> for Mcg128Xsl64
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where __D: Deserializer<'de>,
Auto Trait Implementations
impl Freeze for Mcg128Xsl64
impl RefUnwindSafe for Mcg128Xsl64
impl Send for Mcg128Xsl64
impl Sync for Mcg128Xsl64
impl Unpin for Mcg128Xsl64
impl UnsafeUnpin for Mcg128Xsl64
impl UnwindSafe for Mcg128Xsl64
Blanket Implementations
impl<R> Rng for Mcg128Xsl64
where
R: TryRng<Error = never> + ?Sized,
fn next_u32(&mut self) -> u32fn next_u64(&mut self) -> u64fn fill_bytes(&mut self, dst: &mut [u8])
impl<R> RngCore for Mcg128Xsl64
where
R: Rng,
impl<R> TryRngCore for Mcg128Xsl64
where
R: TryRng,
type Error = <R as TryRng>::Error;
impl<T> Any for Mcg128Xsl64
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Mcg128Xsl64
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Mcg128Xsl64
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Mcg128Xsl64
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> DeserializeOwned for Mcg128Xsl64
where
T: for<'de> Deserialize<'de>,
impl<T> From<T> for Mcg128Xsl64
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Mcg128Xsl64
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Mcg128Xsl64
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Mcg128Xsl64
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Mcg128Xsl64
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>