numcodecs_random_projection

Trait FloatExt

Source
pub trait FloatExt:
    Float
    + ConstZero
    + ConstOne
    + FloatConst
    + AddAssign {
    const HALF: Self;
    const TWO: Self;

    // Required methods
    fn from_f64(x: f64) -> Self;
    fn from_usize(n: usize) -> Self;
    fn into_usize(self) -> usize;
    fn u01x2(hash: u64) -> (ClosedOpenUnit<Self>, OpenClosedUnit<Self>);
}
Expand description

Floating point types.

Required Associated Constants§

Source

const HALF: Self

0.5

Source

const TWO: Self

2.0

Required Methods§

Source

fn from_f64(x: f64) -> Self

Converts from a f64.

Source

fn from_usize(n: usize) -> Self

Converts from a usize.

Source

fn into_usize(self) -> usize

Converts into a usize.

Source

fn u01x2(hash: u64) -> (ClosedOpenUnit<Self>, OpenClosedUnit<Self>)

Generates two uniform random numbers from a random hash value.

The first is sampled from [0.0, 1.0), the second from (0.0, 1.0].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FloatExt for f32

Source§

const HALF: Self = 0.5f32

Source§

const TWO: Self = 2f32

Source§

fn from_f64(x: f64) -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn into_usize(self) -> usize

Source§

fn u01x2(hash: u64) -> (ClosedOpenUnit<Self>, OpenClosedUnit<Self>)

Source§

impl FloatExt for f64

Source§

const HALF: Self = 0.5f64

Source§

const TWO: Self = 2f64

Source§

fn from_f64(x: f64) -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn into_usize(self) -> usize

Source§

fn u01x2(hash: u64) -> (ClosedOpenUnit<Self>, OpenClosedUnit<Self>)

Implementors§