SFC64

Struct SFC64 

Source
pub struct SFC64 { /* private fields */ }
Expand description

The “Small Fast Chaotic” PRNG, originally designed by Chris Doty-Humphrey.

This PRNG holds 256 bits of state (including a 64-bit counter) and generates 64 bits of output with each step. The minimum cycle length is $2^{64}$, and the expected period is $~2^{255}$. Independent seeds are guaranteed to not collide within the first $2^{64}$ steps, although the actual time to collision may be much longer.

This specific implementation passes PractRand with >2TB of output for each of several low-entropy seeds, and >1TB for sets of 8 and 64 parallel streams whose seed differs by only a single bit.

§Seeding (construction)

This generator implements the [SeedableRng] trait. Any method may be used, and the results are guaranteed to be portable.

Seeding the generator with seed_from_u64 is often the most convenient and guarantees good pseudorandom statistics.

use hoomd_rand::SFC64;
use rand::SeedableRng;
let rng = SFC64::seed_from_u64(42);

See also Seeding RNGs in the Rust Rand book.

§Generation

The generators implements [TryRng] and thus also Rng. See also the Random Values chapter in the Rust Rand book.

Trait Implementations§

Source§

impl Clone for SFC64

Source§

fn clone(&self) -> SFC64

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SFC64

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SFC64

Source§

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 PartialEq for SFC64

Source§

fn eq(&self, other: &SFC64) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl SeedableRng for SFC64

Source§

type Seed = [u8; 24]

Seed type, which is restricted to types mutably-dereferenceable as u8 arrays (we recommend [u8; N] for some N). Read more
Source§

fn from_seed(seed: Self::Seed) -> Self

Create a new PRNG using the given seed. Read more
Source§

fn seed_from_u64(state: u64) -> Self

Create a new PRNG using a u64 seed. Read more
§

fn from_rng<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Create a new PRNG seeded from an infallible Rng. Read more
§

fn try_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>
where R: TryRng + ?Sized,

Create a new PRNG seeded from a potentially fallible Rng. Read more
§

fn fork(&mut self) -> Self
where Self: Rng,

Fork this PRNG Read more
§

fn try_fork(&mut self) -> Result<Self, Self::Error>
where Self: TryRng,

Fork this PRNG Read more
Source§

impl Serialize for SFC64

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryRng for SFC64

Source§

type Error = Infallible

The type returned in the event of a RNG error. Read more
Source§

fn try_next_u64(&mut self) -> Result<u64, Self::Error>

Return the next random u64.
Source§

fn try_next_u32(&mut self) -> Result<u32, Self::Error>

Return the next random u32.
Source§

fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Self::Error>

Fill dst entirely with random data.
Source§

impl Eq for SFC64

Source§

impl StructuralPartialEq for SFC64

Auto Trait Implementations§

§

impl Freeze for SFC64

§

impl RefUnwindSafe for SFC64

§

impl Send for SFC64

§

impl Sync for SFC64

§

impl Unpin for SFC64

§

impl UnwindSafe for SFC64

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<R> Rng for R
where R: TryRng<Error = Infallible> + ?Sized,

§

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. Read more
§

impl<R> RngExt for R
where R: Rng + ?Sized,

§

fn random<T>(&mut self) -> T
where 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>,

Return an iterator over random variates Read more
§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
§

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

Return a bool with a probability of numerator/denominator of being true. Read more
§

fn sample<T, D>(&mut self, distr: D) -> T
where 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,

Create an iterator that generates values using the given distribution. Read more
§

fn fill<T>(&mut self, dest: &mut [T])
where T: Fill,

Fill any type implementing [Fill] with random data Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<R> TryRngCore for R
where R: TryRng,

§

type Error = <R as TryRng>::Error

👎Deprecated since 0.10.0: use TryRng instead
Error type.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<R> RngCore for R
where R: Rng,