pub struct Xoshiro256PlusPlus { /* private fields */ }Expand description
Xoshiro256++ generator state.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let rng = Xoshiro256PlusPlus::from_u64_seed(42);Implementations§
Source§impl Xoshiro256PlusPlus
impl Xoshiro256PlusPlus
Sourcepub fn from_seed(seed: [u8; 32]) -> Self
pub fn from_seed(seed: [u8; 32]) -> Self
Builds an instance from a 32-byte seed, whitened via SplitMix64.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let seed = [0u8; 32];
let mut rng = Xoshiro256PlusPlus::from_seed(seed);
assert_ne!(rng.next_u64(), 0);Sourcepub fn from_u64_seed(seed: u64) -> Self
pub fn from_u64_seed(seed: u64) -> Self
Convenience constructor from a single u64 seed.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::from_u64_seed(12345);
assert_ne!(rng.next_u64(), 0);Sourcepub fn next_u64(&mut self) -> u64
pub fn next_u64(&mut self) -> u64
Generates the next random u64.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::from_u64_seed(42);
let n = rng.next_u64();Sourcepub fn next_u32(&mut self) -> u32
pub fn next_u32(&mut self) -> u32
Generates the next random u32 by taking the high 32 bits of the
next u64.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::from_u64_seed(42);
let n = rng.next_u32();Sourcepub fn fill_bytes(&mut self, dest: &mut [u8])
pub fn fill_bytes(&mut self, dest: &mut [u8])
Fills dest with random bytes.
With the simd feature, large buffers go through a SIMD-batched
path that holds K independent Xoshiro256++ lanes in vector
registers (K = 2 on AArch64 NEON, K = 4 on x86_64 AVX2). Same
seed produces a different byte stream under simd vs.
scalar - see crate::xoshiro_simd for the contract.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::from_u64_seed(42);
let mut buf = [0u8; 16];
rng.fill_bytes(&mut buf);Sourcepub fn jump(&mut self)
pub fn jump(&mut self)
Advances the state by 2^128 calls to Self::next_u64.
§Examples
use vrd::xoshiro::Xoshiro256PlusPlus;
let mut rng = Xoshiro256PlusPlus::from_u64_seed(42);
rng.jump();Trait Implementations§
Source§impl Clone for Xoshiro256PlusPlus
impl Clone for Xoshiro256PlusPlus
Source§fn clone(&self) -> Xoshiro256PlusPlus
fn clone(&self) -> Xoshiro256PlusPlus
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Xoshiro256PlusPlus
impl Debug for Xoshiro256PlusPlus
Source§impl<'de> Deserialize<'de> for Xoshiro256PlusPlus
impl<'de> Deserialize<'de> for Xoshiro256PlusPlus
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for Xoshiro256PlusPlus
impl Hash for Xoshiro256PlusPlus
Source§impl Ord for Xoshiro256PlusPlus
impl Ord for Xoshiro256PlusPlus
Source§fn cmp(&self, other: &Xoshiro256PlusPlus) -> Ordering
fn cmp(&self, other: &Xoshiro256PlusPlus) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Xoshiro256PlusPlus
impl PartialEq for Xoshiro256PlusPlus
Source§impl PartialOrd for Xoshiro256PlusPlus
impl PartialOrd for Xoshiro256PlusPlus
Source§impl SeedableRng for Xoshiro256PlusPlus
impl SeedableRng for Xoshiro256PlusPlus
Source§type Seed = [u8; 32]
type Seed = [u8; 32]
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N] for some N). Read more§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64 seed. Read more§fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
fn from_rng<R>(rng: &mut R) -> Selfwhere
R: Rng + ?Sized,
Create a new PRNG seeded from an infallible
Rng. Read moreSource§impl Serialize for Xoshiro256PlusPlus
impl Serialize for Xoshiro256PlusPlus
Source§impl TryRng for Xoshiro256PlusPlus
impl TryRng for Xoshiro256PlusPlus
Source§type Error = Infallible
type Error = Infallible
The type returned in the event of a RNG error. Read more
Source§fn try_next_u32(&mut self) -> Result<u32, Self::Error>
fn try_next_u32(&mut self) -> Result<u32, Self::Error>
Return the next random
u32.Source§fn try_next_u64(&mut self) -> Result<u64, Self::Error>
fn try_next_u64(&mut self) -> Result<u64, Self::Error>
Return the next random
u64.impl Copy for Xoshiro256PlusPlus
impl Eq for Xoshiro256PlusPlus
impl StructuralPartialEq for Xoshiro256PlusPlus
Auto Trait Implementations§
impl Freeze for Xoshiro256PlusPlus
impl RefUnwindSafe for Xoshiro256PlusPlus
impl Send for Xoshiro256PlusPlus
impl Sync for Xoshiro256PlusPlus
impl Unpin for Xoshiro256PlusPlus
impl UnsafeUnpin for Xoshiro256PlusPlus
impl UnwindSafe for Xoshiro256PlusPlus
Blanket Implementations§
§impl<R> TryRngCore for Rwhere
R: TryRng,
impl<R> TryRngCore for Rwhere
R: TryRng,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<R> Rng for Rwhere
R: TryRng<Error = Infallible> + ?Sized,
impl<R> Rng for Rwhere
R: TryRng<Error = Infallible> + ?Sized,
§impl<R> RngExt for Rwhere
R: Rng + ?Sized,
impl<R> RngExt for Rwhere
R: Rng + ?Sized,
§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read more§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>where
Self: Sized,
StandardUniform: Distribution<T>,
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>where
Self: Sized,
StandardUniform: Distribution<T>,
§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read more§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read more§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more