rand_distr::uniform

Struct UniformFloat

Source
pub struct UniformFloat<X> { /* private fields */ }
Expand description

The back-end implementing UniformSampler for floating-point types.

Unless you are implementing UniformSampler for your own type, this type should not be used directly, use Uniform instead.

§Implementation notes

UniformFloat implementations convert RNG output to a float in the range [1, 2) via transmutation, map this to [0, 1), then scale and translate to the desired range. Values produced this way have what equals 23 bits of random digits for an f32 and 52 for an f64.

§Bias and range errors

Bias may be expected within the least-significant bit of the significand. It is not guaranteed that exclusive limits of a range are respected; i.e. when sampling the range [a, b) it is not guaranteed that b is never sampled.

Trait Implementations§

Source§

impl<X> Clone for UniformFloat<X>
where X: Clone,

Source§

fn clone(&self) -> UniformFloat<X>

Returns a copy 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<X> Debug for UniformFloat<X>
where X: Debug,

Source§

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

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

impl<'de, X> Deserialize<'de> for UniformFloat<X>
where X: Deserialize<'de>,

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<UniformFloat<X>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<X> PartialEq for UniformFloat<X>
where X: PartialEq,

Source§

fn eq(&self, other: &UniformFloat<X>) -> 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<X> Serialize for UniformFloat<X>
where X: Serialize,

Source§

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

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

impl UniformSampler for UniformFloat<Simd<f32, 16>>

Source§

type X = Simd<f32, 16>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 16>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 16>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f32, 16>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 16>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 16>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f32, 2>>

Source§

type X = Simd<f32, 2>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 2>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 2>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f32, 2>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 2>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 2>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f32, 4>>

Source§

type X = Simd<f32, 4>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 4>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 4>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f32, 4>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 4>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 4>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f32, 8>>

Source§

type X = Simd<f32, 8>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 8>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f32, 8>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f32, 8>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 8>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f32, 8>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f64, 2>>

Source§

type X = Simd<f64, 2>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 2>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 2>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f64, 2>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 2>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 2>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f64, 4>>

Source§

type X = Simd<f64, 4>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 4>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 4>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f64, 4>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 4>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 4>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<Simd<f64, 8>>

Source§

type X = Simd<f64, 8>

The type sampled by this implementation.
Source§

fn new<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 8>>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<Simd<f64, 8>>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>( &self, rng: &mut R, ) -> <UniformFloat<Simd<f64, 8>> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 8>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<Simd<f64, 8>> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<f32>

Source§

type X = f32

The type sampled by this implementation.
Source§

fn new<B1, B2>(low_b: B1, high_b: B2) -> Result<UniformFloat<f32>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<f32>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>(&self, rng: &mut R) -> <UniformFloat<f32> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<f32> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<f32> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl UniformSampler for UniformFloat<f64>

Source§

type X = f64

The type sampled by this implementation.
Source§

fn new<B1, B2>(low_b: B1, high_b: B2) -> Result<UniformFloat<f64>, Error>

Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn new_inclusive<B1, B2>( low_b: B1, high_b: B2, ) -> Result<UniformFloat<f64>, Error>

Construct self, with inclusive bounds [low, high]. Read more
Source§

fn sample<R>(&self, rng: &mut R) -> <UniformFloat<f64> as UniformSampler>::X
where R: Rng + ?Sized,

Sample a value.
Source§

fn sample_single<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<f64> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Source§

fn sample_single_inclusive<R, B1, B2>( low_b: B1, high_b: B2, rng: &mut R, ) -> Result<<UniformFloat<f64> as UniformSampler>::X, Error>

Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
Source§

impl<X> Copy for UniformFloat<X>
where X: Copy,

Source§

impl<X> StructuralPartialEq for UniformFloat<X>

Auto Trait Implementations§

§

impl<X> Freeze for UniformFloat<X>
where X: Freeze,

§

impl<X> RefUnwindSafe for UniformFloat<X>
where X: RefUnwindSafe,

§

impl<X> Send for UniformFloat<X>
where X: Send,

§

impl<X> Sync for UniformFloat<X>
where X: Sync,

§

impl<X> Unpin for UniformFloat<X>
where X: Unpin,

§

impl<X> UnwindSafe for UniformFloat<X>
where X: UnwindSafe,

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

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