### Xoshiro128PlusPlus Jump Example Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Demonstrates how to use the jump() method to advance the generator state by 2^64 calls. This is useful for generating non-overlapping subsequences for parallel computations. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128PlusPlus; let rng1 = Xoroshiro128PlusPlus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Xoshiro256PlusPlus Jump Example Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256PlusPlus.html Demonstrates how to use the `jump()` method to create non-overlapping subsequences for parallel computations. This is achieved by cloning the RNG and calling `jump()` on the clone. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro256PlusPlus; let rng1 = Xoshiro256PlusPlus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Xoshiro128Plus state() Method Example Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Shows how to retrieve the internal state of the Xoshiro128Plus generator as a byte array. This state can be used to reconstruct an identical generator using `SeedableRng::from_seed`. ```rust pub fn state(&self) -> [u8; 16] ``` -------------------------------- ### Xoshiro128Plus jump() Method Example Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Demonstrates how to use the `jump()` method to advance the generator's state by 2^64 calls to `next_u32()`. This is useful for generating non-overlapping subsequences for parallel computations. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128StarStar; let rng1 = Xoroshiro128StarStar::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Xoshiro256Plus Jump Example Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256Plus.html Demonstrates how to use the `jump` method to advance the generator's state, creating non-overlapping subsequences for parallel computations. This is useful for generating independent streams of random numbers. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro256Plus; let rng1 = Xoshiro256Plus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Xoshiro128StarStar Jump Forward Example Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro128starstar.rs.html Demonstrates how to use the `jump` method to advance the RNG state, useful for generating non-overlapping subsequences for parallel computations. This is equivalent to 2^64 calls to `next_u32()`. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128StarStar; let rng1 = Xoroshiro128StarStar::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Seeding Xoshiro512Plus from a u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512Plus.html Seeds a Xoshiro512Plus generator using a u64 value via the SplitMix64 algorithm. The all-zero state is remapped to ensure a valid starting point. ```rust pub fn seed_from_u64(seed: u64) -> Xoshiro512Plus ``` -------------------------------- ### Xoshiro256Plus::from_seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256Plus.html Creates a new `Xoshiro256Plus` generator from a 32-byte seed. If the provided seed is all zeros, it is remapped to a different seed to ensure a valid starting state. ```APIDOC ## pub fn from_seed(seed: [u8; 32]) -> Xoshiro256Plus ### Description Creates a new `Xoshiro256Plus` generator from a 32-byte seed. If the provided seed is all zeros, it is remapped to a different seed to ensure a valid starting state. ### Method `from_seed()` ### Parameters - `seed` (`[u8; 32]`): The 32-byte seed for the generator. ### Returns - `Xoshiro256Plus`: A new `Xoshiro256Plus` generator instance. ``` -------------------------------- ### Initialize Xoshiro256PlusPlus RNG Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/lib.rs.html Initializes a Xoshiro256PlusPlus random number generator using a 64-bit seed. This is a common way to start using the generator for generating random numbers. ```rust use rand_core::{SeedableRng, Rng}; use rand_xoshiro::Xoshiro256PlusPlus; let mut rng = Xoshiro256PlusPlus::seed_from_u64(0); let x = rng.next_u64(); ``` -------------------------------- ### Xoshiro512Plus Initialization from Seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plus.rs.html Shows how to create a new `Xoshiro512Plus` instance using a `Seed512` value. If the provided seed is all zeros, it will be mapped to a different seed. ```rust use rand_xoshiro::Seed512; use rand_xoshiro::Xoshiro512Plus; let seed = Seed512([0u64; 8]); // Example seed let rng = Xoshiro512Plus::from_seed(seed); ``` -------------------------------- ### Any Trait Implementation Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Seed512.html Provides a way to get the TypeId of a Seed512 instance, useful for dynamic type checking. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Get Xoshiro512StarStar Internal State Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512StarStar.html Retrieves the internal state of the Xoshiro512StarStar generator as a `Seed512`, allowing for exact reconstruction of the generator. ```rust pub fn state(&self) -> Seed512 ``` -------------------------------- ### Xoshiro512Plus Initialization from u64 Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plus.rs.html Demonstrates seeding a `Xoshiro512Plus` generator from a single `u64` value using the `SplitMix64` algorithm. ```rust use rand_xoshiro::Xoshiro512Plus; let rng = Xoshiro512Plus::seed_from_u64(12345); ``` -------------------------------- ### RngCore Methods Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512Plus.html Provides core random number generation functionalities like getting the next u32, u64, or filling a byte slice. ```APIDOC ## RngCore Methods ### Description Provides core random number generation functionalities like getting the next u32, u64, or filling a byte slice. ### Methods #### `fn next_u32(&mut self) -> u32` Return the next random `u32`. #### `fn next_u64(&mut self) -> u64` Return the next random `u64`. #### `fn fill_bytes(&mut self, dst: &mut [u8])` Fill `dest` with random data. ``` -------------------------------- ### Xoshiro128Plus try_next_u32() Method Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Shows how to get the next random u32 value from the Xoshiro128Plus generator. This method is part of the TryRng trait implementation. ```rust fn try_next_u32(&mut self) -> Result ``` -------------------------------- ### Get Internal State of Xoshiro512PlusPlus Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512PlusPlus.html Retrieves the current internal state of the Xoshiro512PlusPlus generator as a `Seed512`. This state can be used to reconstruct an identical generator later. ```rust fn state(&self) -> Seed512 ``` -------------------------------- ### impl CloneToUninit for T Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128StarStar.html Nightly-only experimental API for cloning to uninitialized memory. ```APIDOC ## impl CloneToUninit for T ### Description Nightly-only experimental API for cloning to uninitialized memory. Requires `T: Clone`. ### Method #### clone_to_uninit - **unsafe fn clone_to_uninit(&self, dest: *mut u8)**: Performs copy-assignment from `self` to `dest`. ``` -------------------------------- ### Get Internal State of Xoroshiro128Plus Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128Plus.html Retrieves the current internal state of the Xoroshiro128Plus generator as a 16-byte array. This state can be used to reconstruct the generator later. ```Rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128Plus; let mut rng = Xoroshiro128Plus::seed_from_u64(0); let state = rng.state(); // state is a [u8; 16] array ``` -------------------------------- ### Xoshiro128Plus Initialization from Seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro128plus.rs.html Shows how to create a new Xoshiro128Plus generator from a 16-byte seed. If the provided seed is all zeros, it will be mapped to a different seed. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro128Plus; Xoshiro128Plus::from_seed([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); ``` -------------------------------- ### Get Internal State Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro64StarStar.html Retrieves the internal state of the generator as little-endian bytes. This state can be used to reconstruct an identical generator using `SeedableRng::from_seed`. ```rust pub fn state(&self) -> [u8; 8] ``` -------------------------------- ### SeedableRng::from_seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256PlusPlus.html Creates a new `Xoshiro256PlusPlus` generator from a 32-byte seed. The all-zero seed is remapped to a non-zero seed to ensure a unique starting state. ```APIDOC ## SeedableRng::from_seed ### Description Creates a new `Xoshiro256PlusPlus` generator from a 32-byte seed. The all-zero seed is remapped to a non-zero seed to ensure a unique starting state. ### Method `from_seed(seed: [u8; 32]) -> Xoshiro256PlusPlus` ### Parameters * **seed** (`[u8; 32]`) - The 32-byte seed for the generator. ``` -------------------------------- ### Xoshiro128Plus seed_from_u64() Method Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Demonstrates seeding a Xoshiro128Plus generator from a u64 value using the SplitMix64 algorithm. ```rust fn seed_from_u64(seed: u64) -> Xoshiro128Plus ``` -------------------------------- ### Get Generator State as Seed512 Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/common.rs.html Retrieves the internal state of the generator as a 512-bit seed. This seed can be used to reconstruct an identical generator using `SeedableRng::from_seed`. ```rust pub fn state(&self) -> crate::Seed512 { let mut out = [0u8; 64]; for (i, word) in self.s.iter().enumerate() { out[i * 8..(i + 1) * 8].copy_from_slice(&word.to_le_bytes()); } crate::Seed512(out) } ``` -------------------------------- ### Xoshiro128PlusPlus Initialization from Seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro128plusplus.rs.html Shows how to create a new Xoshiro128PlusPlus generator from a 16-byte seed. If the provided seed is all zeros, a fallback seed is used. ```Rust use rand_xoshiro::Xoshiro128PlusPlus; use rand_core::SeedableRng; let mut rng = Xoshiro128PlusPlus::from_seed([1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); ``` -------------------------------- ### Get Internal State of Xoshiro256StarStar Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256StarStar.html Shows how to retrieve the internal state of the Xoshiro256StarStar generator as a byte array. This state can be used to reconstruct an identical generator later. ```rust pub fn state(&self) -> [u8; 32] ``` -------------------------------- ### Initialize Xoshiro256PlusPlus Generator Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/index.html Demonstrates how to initialize the Xoshiro256PlusPlus generator using a 64-bit seed and generate a random u64 value. Requires `SeedableRng` and `Rng` traits from `rand_core`. ```rust use rand_core::{SeedableRng, Rng}; use rand_xoshiro::Xoshiro256PlusPlus; let mut rng = Xoshiro256PlusPlus::seed_from_u64(0); let x = rng.next_u64(); ``` -------------------------------- ### Xoshiro256Plus Long Jump Forward Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plus.rs.html Advance the RNG state by 2^192 calls to `next_u64()`. Enables generating 2^64 starting points for parallel distributed computations. ```Rust impl_jump!( u64, self, [ 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 ] ); ``` -------------------------------- ### try_next_u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128StarStar.html Return the next random `u64`. ```APIDOC ## try_next_u64 ### Description Return the next random `u64`. ### Method `try_next_u64(&mut self) -> Result` ### Returns - `Result`: The next random `u64` or an error if the RNG fails. ``` -------------------------------- ### Xoroshiro128PlusPlus Long Jump Forward Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoroshiro128plusplus.rs.html Advance the RNG state by 2^96 calls to `next_u64()`. Useful for generating 2^32 starting points for parallel distributed computations. ```rust impl_jump!(u64, self, [0x360fd5f2cf8d5d99, 0x9c6e6877736c46e3]); ``` -------------------------------- ### Xoshiro512PlusPlus Initialization from Seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plusplus.rs.html Shows how to initialize the Xoshiro512PlusPlus generator using a `Seed512` type. The implementation handles zero seeds by mapping them to a different, valid seed. ```rust use rand_xoshiro::Seed512; use rand_xoshiro::Xoshiro512PlusPlus; let mut rng = Xoshiro512PlusPlus::from_seed(Seed512([ 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, ])); ``` -------------------------------- ### Xoshiro128Plus::try_next_u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Return the next random `u64`. ```APIDOC ## Xoshiro128Plus::try_next_u64 ### Description Return the next random `u64`. ### Method `try_next_u64(&mut self) -> Result` ### Parameters None ### Response #### Success Response - **u64** (u64) - The next random u64 value. #### Error Response - **Error** (Self::Error) - An error if the RNG fails. ``` -------------------------------- ### Zero Seed Fallback Test Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plus.rs.html Verifies that initializing `Xoshiro256Plus` with an all-zero seed correctly maps to the output of seeding with zero using `seed_from_u64`. ```Rust use super::*; let from_zero = Xoshiro256Plus::from_seed([0u8; 32]); let from_seed_from_u64_zero = Xoshiro256Plus::seed_from_u64(0); assert_eq!(from_zero, from_seed_from_u64_zero); ``` -------------------------------- ### Xoshiro512StarStar TryNextU64 Implementation Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512starstar.rs.html Provides the implementation for generating a `u64` random number using the `Xoshiro512StarStar` algorithm. It uses the `starstar_u64!` macro and `impl_xoshiro_large!` for state updates. ```rust impl TryRng for Xoshiro512StarStar { type Error = Infallible; #[inline] fn try_next_u32(&mut self) -> Result { // The lowest bits have some linear dependencies, so we use the // upper bits instead. Ok((self.next_u64() >> 32) as u32) } #[inline] fn try_next_u64(&mut self) -> Result { let result_starstar = starstar_u64!(self.s[1]); impl_xoshiro_large!(self); Ok(result_starstar) } #[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> { utils::fill_bytes_via_next_word(dest, || self.try_next_u64()) } } ``` -------------------------------- ### long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128PlusPlus.html Advances the generator's state by a very large amount, equivalent to 2^96 calls to `next_u64()`. This enables the generation of 2^32 starting points for parallel distributed computations. ```APIDOC ## long_jump ### Description Jump forward, equivalently to 2^96 calls to `next_u64()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ``` -------------------------------- ### Xoshiro512+ Seed from Zero Test Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plus.rs.html Verifies that initializing Xoshiro512+ with a zero seed results in the same state as seeding from a u64 value of zero. ```rust #[test] fn zero_seed_maps_to_seed_from_u64_zero() { let from_zero = Xoshiro512Plus::from_seed(Seed512([0u8; 64])); let from_sm0 = Xoshiro512Plus::seed_from_u64(0); assert_eq!(from_zero, from_sm0); } ``` -------------------------------- ### Long Jump Forward in Xoroshiro128StarStar Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoroshiro128starstar.rs.html Allows jumping the generator state forward by an equivalent of 2^96 calls to `next_u64()`. Useful for generating 2^32 starting points for parallel computations. ```rust pub fn long_jump(&mut self) { impl_jump!(u64, self, [0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1]); } ``` -------------------------------- ### TryRng::try_next_u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Return the next random `u64`. ```APIDOC ## TryRng::try_next_u64 ### Description Return the next random `u64`. ### Method `try_next_u64(&mut self) -> Result` ``` -------------------------------- ### Xoshiro512Plus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512Plus.html Advances the generator state by an even larger amount, equivalent to 2^384 calls to `next_u64()`. This enables the generation of 2^128 starting points for parallel distributed computations. ```APIDOC ## Xoshiro512Plus::long_jump ### Description Advances the generator state by an even larger amount, equivalent to 2^384 calls to `next_u64()`. This can be used to generate 2^128 starting points, from each of which `jump()` will generate 2^128 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ### Parameters - `self`: A mutable reference to the `Xoshiro512Plus` generator. ### Example ```rust use rand_xoshiro::Xoshiro512Plus; let mut rng = Xoshiro512Plus::seed_from_u64(1); rng.long_jump(); ``` ``` -------------------------------- ### Initialize Xoshiro256PlusPlus RNG with a seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plusplus.rs.html Demonstrates how to create a new Xoshiro256PlusPlus RNG instance using a 32-byte seed. If the provided seed is all zeros, it is mapped to a different seed to ensure proper initialization. ```rust use rand_core::SeedableRng; use rand_xoshiro::Xoshiro256PlusPlus; let seed = [0u8; 32]; let mut rng = Xoshiro256PlusPlus::from_seed(seed); ``` -------------------------------- ### Xoroshiro128Plus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128Plus.html Advances the generator state by a very large amount, equivalent to 2^96 calls to next_u64(). Useful for generating a large number of starting points for parallel distributed computations. ```APIDOC ## pub fn long_jump(&mut self) ### Description Jump forward, equivalently to 2^96 calls to `next_u64()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ``` -------------------------------- ### Zero Seed Fallback Test Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256starstar.rs.html Verifies that initializing Xoshiro256StarStar with an all-zero seed correctly maps to the result of seeding with `u64` zero. ```rust use rand_xoshiro::Xoshiro256StarStar; Xoshiro256StarStar::from_seed([0u8; 32]); ``` -------------------------------- ### Xoroshiro128PlusPlus Seeding from u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128PlusPlus.html Seeds a new Xoroshiro128PlusPlus generator using a u64 value via the `SplitMix64` algorithm. This is a common way to initialize the generator with a specific starting point. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128PlusPlus; let rng = Xoroshiro128PlusPlus::seed_from_u64(12345); // rng is now initialized and ready to generate random numbers ``` -------------------------------- ### Create Xoshiro512StarStar from Seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512StarStar.html Shows how to create a new Xoshiro512StarStar generator using a `Seed512` value. Note that an all-zero seed is remapped. ```rust fn from_seed(seed: Seed512) -> Xoshiro512StarStar ``` -------------------------------- ### Xoshiro256StarStar::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256StarStar.html Advances the generator's state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This enables generating 2^64 starting points for parallel distributed computations. ```APIDOC ## Xoshiro256StarStar::long_jump ### Description Advances the generator's state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This can be used to generate 2^64 starting points, from each of which `jump()` will generate 2^64 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ### Parameters None ``` -------------------------------- ### SeedableRng::from_seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Create a new `Xoshiro128PlusPlus`. If `seed` is entirely 0, it will be mapped to a different seed. ```APIDOC ## SeedableRng::from_seed ### Description Create a new `Xoshiro128PlusPlus`. If `seed` is entirely 0, it will be mapped to a different seed. ### Method `from_seed(seed: [u8; 16]) -> Xoshiro128PlusPlus` ``` -------------------------------- ### Xoshiro128Plus::from_seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Create a new `Xoshiro128Plus`. If `seed` is entirely 0, it will be mapped to a different seed. ```APIDOC ## Xoshiro128Plus::from_seed ### Description Create a new `Xoshiro128Plus`. If `seed` is entirely 0, it will be mapped to a different seed. ### Method `from_seed(seed: [u8; 16]) -> Xoshiro128Plus` ### Parameters - **seed** ([u8; 16]) - Required - The seed for the generator. ``` -------------------------------- ### Xoshiro128Plus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Jump forward, equivalently to 2^96 calls to `next_u32()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ```APIDOC ## Xoshiro128Plus::long_jump ### Description Jump forward, equivalently to 2^96 calls to `next_u32()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ### Parameters None ``` -------------------------------- ### Xoshiro256Plus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256Plus.html Advances the generator's state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This enables generating 2^64 starting points for parallel distributed computations. ```APIDOC ## pub fn long_jump(&mut self) ### Description Advances the generator's state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This enables generating 2^64 starting points for parallel distributed computations. ### Method `long_jump()` ### Parameters - `&mut self`: A mutable reference to the `Xoshiro256Plus` generator. ``` -------------------------------- ### Xoshiro128Plus from_seed() Method Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Illustrates creating a new Xoshiro128Plus generator from a 16-byte seed. The all-zero seed is remapped to a default seed to avoid an unreachable state. ```rust fn from_seed(seed: [u8; 16]) -> Xoshiro128Plus ``` -------------------------------- ### Xoshiro128StarStar::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128StarStar.html Advances the generator's state by an even larger amount, equivalent to 2^96 calls to `next_u32()`. Useful for generating 2^32 starting points for parallel distributed computations. ```APIDOC ## pub fn long_jump(&mut self) ### Description Advances the generator's state by an even larger amount, equivalent to 2^96 calls to `next_u32()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ``` -------------------------------- ### Xoshiro512Plus TryNextU64 Implementation Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plus.rs.html Illustrates the core logic for generating the next `u64` random number using the Xoshiro512+ algorithm. It uses the upper bits of the generated value for `u32` to avoid linear dependencies in lower bits. ```rust use rand_core::TryRng; use rand_xoshiro::Xoshiro512Plus; let mut rng = Xoshiro512Plus::seed_from_u64(0); let random_u64 = rng.try_next_u64().unwrap(); let random_u32 = rng.try_next_u32().unwrap(); ``` -------------------------------- ### try_next_u32 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128StarStar.html Return the next random `u32`. ```APIDOC ## try_next_u32 ### Description Return the next random `u32`. ### Method `try_next_u32(&mut self) -> Result` ### Returns - `Result`: The next random `u32` or an error if the RNG fails. ``` -------------------------------- ### Xoshiro128PlusPlus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Jump forward, equivalently to 2^96 calls to `next_u32()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ```APIDOC ## Xoshiro128PlusPlus::long_jump ### Description Jump forward, equivalently to 2^96 calls to `next_u32()`. This can be used to generate 2^32 starting points, from each of which `jump()` will generate 2^32 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ``` -------------------------------- ### Create Xoshiro256PlusPlus from Seed Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plusplus.rs.html Demonstrates creating a Xoshiro256PlusPlus generator from a fixed-size seed array and from a u64 value. Both methods should produce identical generator states. ```rust let from_zero = Xoshiro256PlusPlus::from_seed([0; 32]); let from_sm0 = Xoshiro256PlusPlus::seed_from_u64(0); assert_eq!(from_zero, from_sm0); ``` -------------------------------- ### Create Xoroshiro128Plus from Seed (u64) Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128Plus.html Initializes a new Xoroshiro128Plus generator using a u64 seed. This method uses SplitMix64 for seeding. ```Rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128Plus; let mut rng = Xoroshiro128Plus::seed_from_u64(1234); let next_val = rng.next_u64(); ``` -------------------------------- ### Xoshiro128StarStar Seed from U64 Zero Test Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro128starstar.rs.html Verifies that seeding Xoshiro128StarStar with a zero byte array is equivalent to seeding with U64 zero. ```rust #[test] fn zero_seed_maps_to_seed_from_u64_zero() { let from_zero = Xoshiro128StarStar::from_seed([0u8; 16]); let from_sm0 = Xoshiro128StarStar::seed_from_u64(0); assert_eq!(from_zero, from_sm0); } ``` -------------------------------- ### Xoshiro512PlusPlus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512PlusPlus.html The `long_jump` method advances the generator's state by a larger amount, equivalent to 2^384 calls to `next_u64()`. It facilitates generating 2^128 starting points for parallel distributed computations. ```APIDOC ## Xoshiro512PlusPlus::long_jump ### Description Advances the generator's state equivalently to 2^384 calls to `next_u64()`. This can be used to generate 2^128 starting points, from each of which `jump()` will generate 2^128 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ``` -------------------------------- ### PartialEq Implementation Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro64StarStar.html Provides methods for comparing two Xoroshiro64StarStar generators for equality. ```rust fn eq(&self, other: &Xoroshiro64StarStar) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Xoshiro128Plus::try_next_u32 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Return the next random `u32`. ```APIDOC ## Xoshiro128Plus::try_next_u32 ### Description Return the next random `u32`. ### Method `try_next_u32(&mut self) -> Result` ### Parameters None ### Response #### Success Response - **u32** (u32) - The next random u32 value. #### Error Response - **Error** (Self::Error) - An error if the RNG fails. ``` -------------------------------- ### Try Next U32 and U64 with Xoroshiro128StarStar Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoroshiro128starstar.rs.html Provides fallible methods to get the next u32 or u64 random number. These methods return a Result, with `Infallible` as the error type, indicating they will always succeed. ```rust impl TryRng for Xoroshiro128StarStar { type Error = Infallible; #[inline] fn try_next_u32(&mut self) -> Result { Ok(self.next_u64() as u32) } #[inline] fn try_next_u64(&mut self) -> Result { let r = starstar_u64!(self.s0); impl_xoroshiro_u64!(self); Ok(r) } #[inline] fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error> { utils::fill_bytes_via_next_word(dest, || self.try_next_u64()) } } ``` -------------------------------- ### Initialize RNG from u64 seed using SplitMix64 Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/common.rs.html Use this macro to initialize a random number generator from a `u64` seed by first using `SplitMix64`. ```rust macro_rules! from_splitmix { ($seed:expr) => {{ let mut rng = crate::SplitMix64::seed_from_u64($seed); Self::from_rng(&mut rng) }}; } ``` -------------------------------- ### Xoshiro256PlusPlus::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256PlusPlus.html Advances the generator state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This allows for generating 2^64 starting points, each capable of producing 2^64 non-overlapping subsequences via `jump()`. ```APIDOC ## Xoshiro256PlusPlus::long_jump ### Description Advances the generator state by an even larger amount, equivalent to 2^192 calls to `next_u64()`. This allows for generating 2^64 starting points, each capable of producing 2^64 non-overlapping subsequences via `jump()`. ### Method `long_jump(&mut self)` ### Parameters None ``` -------------------------------- ### SeedableRng::seed_from_u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Seed a `Xoshiro128PlusPlus` from a `u64` using `SplitMix64`. ```APIDOC ## SeedableRng::seed_from_u64 ### Description Seed a `Xoshiro128PlusPlus` from a `u64` using `SplitMix64`. ### Method `seed_from_u64(seed: u64) -> Xoshiro128PlusPlus` ``` -------------------------------- ### Xoshiro512StarStar::long_jump Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512StarStar.html Advances the generator's state by an extremely large amount, equivalent to 2^384 calls to `next_u64()`. This enables the creation of 2^128 starting points, each capable of generating 2^128 non-overlapping subsequences for parallel distributed computations. ```APIDOC ## Xoshiro512StarStar::long_jump ### Description Advances the generator's state by an extremely large amount, equivalent to 2^384 calls to `next_u64()`. This enables the creation of 2^128 starting points, each capable of generating 2^128 non-overlapping subsequences for parallel distributed computations. ### Method `long_jump(&mut self)` ### Parameters - `self`: A mutable reference to the `Xoshiro512StarStar` generator. ``` -------------------------------- ### Advance Xoshiro256PlusPlus RNG state by 2^192 calls Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plusplus.rs.html The `long_jump` method advances the RNG state by an even larger amount (equivalent to 2^192 calls to `next_u64`). This is useful for generating a large number of starting points for parallel distributed computations. ```rust use rand_xoshiro::Xoshiro256PlusPlus; let mut rng = Xoshiro256PlusPlus::seed_from_u64(0); rng.long_jump(); ``` -------------------------------- ### Xoshiro128Plus::seed_from_u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Seed a `Xoshiro128Plus` from a `u64` using `SplitMix64`. ```APIDOC ## Xoshiro128Plus::seed_from_u64 ### Description Seed a `Xoshiro128Plus` from a `u64` using `SplitMix64`. ### Method `seed_from_u64(seed: u64) -> Xoshiro128Plus` ### Parameters - **seed** (u64) - Required - The seed for the generator. ``` -------------------------------- ### Serialize Implementation Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro64StarStar.html Enables serialization of the Xoroshiro64StarStar generator to a Serde serializer. ```rust fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer ``` -------------------------------- ### try_fill_bytes Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128StarStar.html Fill `dst` entirely with random data. ```APIDOC ## try_fill_bytes ### Description Fill `dst` entirely with random data. ### Method `try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error>` ### Parameters #### Path Parameters - **dest** (`&mut [u8]`) - Required - The buffer to fill with random data. ### Returns - `Result<(), Self::Error>`: Ok if the buffer was filled successfully, or an error if the RNG fails. ``` -------------------------------- ### Fill a byte slice with random data Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro256plusplus.rs.html Demonstrates filling a mutable byte slice with random data using the `try_fill_bytes` method. This method is convenient for obtaining a specific number of random bytes. ```rust use rand_core::Rng; use rand_xoshiro::Xoshiro256PlusPlus; let mut rng = Xoshiro256PlusPlus::seed_from_u64(0); let mut buffer = [0u8; 16]; let _ = rng.fill_bytes(&mut buffer); ``` -------------------------------- ### Seed Xoshiro256StarStar with u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256StarStar.html Demonstrates seeding a Xoshiro256StarStar generator using a `u64` value, which is processed by the `SplitMix64` algorithm. ```rust fn seed_from_u64(seed: u64) -> Xoshiro256StarStar ``` -------------------------------- ### Xoshiro512Plus Reference Test Case Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plus.rs.html A test case that initializes the `Xoshiro512Plus` generator with a specific seed and compares the generated sequence against expected values from the reference implementation. ```rust use rand_xoshiro::Seed512; use rand_xoshiro::Xoshiro512Plus; #[rustfmt::skip] let mut rng = Xoshiro512Plus::from_seed(Seed512([ 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, ])); // These values were produced with the reference implementation: // http://xoshiro.di.unimi.it/xoshiro512plus.c let expected = [ 4, 8, 4113, 25169936, 52776585412635, ``` -------------------------------- ### Create Xoroshiro64Star from Seed (8 bytes) Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro64Star.html Creates a new Xoroshiro64Star generator from an 8-byte seed. The all-zero seed is remapped to a different value to ensure a valid, non-zero state. ```rust fn from_seed(seed: [u8; 8]) -> Xoroshiro64Star ``` -------------------------------- ### CloneToUninit Blanket Implementation Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro64StarStar.html A blanket implementation of CloneToUninit for types that implement Clone, facilitating copying to uninitialized memory. ```rust impl CloneToUninit for T where T: Clone ``` -------------------------------- ### CloneToUninit Trait Implementation (Nightly) Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Seed512.html An experimental nightly-only feature that allows cloning the Seed512 into uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Xoshiro128Plus::try_fill_bytes Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128Plus.html Fill `dst` entirely with random data. ```APIDOC ## Xoshiro128Plus::try_fill_bytes ### Description Fill `dst` entirely with random data. ### Method `try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error>` ### Parameters - **dest** (&mut [u8]) - Required - The buffer to fill with random data. ### Response #### Success Response (200) - **()** - Indicates success. #### Error Response - **Error** (Self::Error) - An error if the RNG fails. ``` -------------------------------- ### TryRng::try_fill_bytes Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Fill `dst` entirely with random data. ```APIDOC ## TryRng::try_fill_bytes ### Description Fill `dst` entirely with random data. ### Method `try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Self::Error>` ``` -------------------------------- ### Seed Xoshiro512StarStar from u64 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512StarStar.html Illustrates seeding a Xoshiro512StarStar generator from a `u64` value using the `SplitMix64` algorithm. ```rust fn seed_from_u64(seed: u64) -> Xoshiro512StarStar ``` -------------------------------- ### Xoroshiro128PlusPlus Try Fill Bytes Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoroshiro128plusplus.rs.html Fills a byte slice with random data using `utils::fill_bytes_via_next_word`. ```rust utils::fill_bytes_via_next_word(dest, || self.try_next_u64()) ``` -------------------------------- ### TryRng::try_next_u32 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro128PlusPlus.html Return the next random `u32`. ```APIDOC ## TryRng::try_next_u32 ### Description Return the next random `u32`. ### Method `try_next_u32(&mut self) -> Result` ``` -------------------------------- ### Xoroshiro128StarStar Seeding from Byte Array Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128StarStar.html Demonstrates creating a Xoroshiro128StarStar generator from a 16-byte seed. The all-zero seed is remapped to a default seed. ```rust fn from_seed(seed: [u8; 16]) -> Xoroshiro128StarStar ``` -------------------------------- ### Create Xoshiro256StarStar from Seed Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256StarStar.html Illustrates creating a new Xoshiro256StarStar generator from a 32-byte seed. Note that an all-zero seed is remapped to a default seed. ```rust fn from_seed(seed: [u8; 32]) -> Xoshiro256StarStar ``` -------------------------------- ### Xoroshiro128Plus Jump Forward Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128Plus.html Demonstrates how to use the `jump()` method to advance the generator's state by 2^64 calls. This is useful for creating non-overlapping subsequences for parallel processing. ```Rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128Plus; let rng1 = Xoroshiro128Plus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Create Xoroshiro128Plus from Seed (byte array) Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoroshiro128Plus.html Initializes a new Xoroshiro128Plus generator from a 16-byte seed array. The all-zero state is remapped to a default seed. ```Rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128Plus; let seed: [u8; 16] = [0; 16]; let mut rng = Xoroshiro128Plus::from_seed(seed); let next_val = rng.next_u64(); ``` -------------------------------- ### Cloning and Jumping Xoshiro512Plus RNGs Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512Plus.html Demonstrates how to seed a Xoshiro512Plus RNG and then use `jump()` to create non-overlapping subsequences for parallel computations. Cloning allows for independent RNG states. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro512Plus; let rng1 = Xoshiro512Plus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Jump Forward in Xoshiro512PlusPlus Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512PlusPlus.html Demonstrates how to use the `jump()` method to advance the generator's state, equivalent to 2^256 calls to `next_u64()`. Useful for generating non-overlapping subsequences for parallel computations. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro512PlusPlus; let rng1 = Xoshiro512PlusPlus::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ``` -------------------------------- ### Xoshiro512PlusPlus Fill Bytes Source: https://docs.rs/rand_xoshiro/latest/src/rand_xoshiro/xoshiro512plusplus.rs.html Demonstrates filling a byte slice with random data using the Xoshiro512PlusPlus generator. This utility method efficiently populates the buffer by repeatedly calling `next_u64`. ```rust use rand_xoshiro::rand_core::Rng; use rand_xoshiro::Xoshiro512PlusPlus; let mut rng = Xoshiro512PlusPlus::seed_from_u64(0); let mut buffer = [0u8; 16]; rng.fill_bytes(&mut buffer); ``` -------------------------------- ### Create Xoshiro512PlusPlus from Seed512 Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512PlusPlus.html Creates a new Xoshiro512PlusPlus generator from a `Seed512` type. Handles the all-zero seed by remapping it to a default seed. ```rust fn from_seed(seed: Seed512) -> Xoshiro512PlusPlus ``` -------------------------------- ### Jump Forward in Xoshiro512StarStar Source: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro512StarStar.html Demonstrates how to use the `jump()` method to advance the generator's state, useful for creating non-overlapping subsequences for parallel computations. ```rust use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoshiro512StarStar; let rng1 = Xoshiro512StarStar::seed_from_u64(0); let mut rng2 = rng1.clone(); rng2.jump(); let mut rng3 = rng2.clone(); rng3.jump(); ```