Trait numcodecs_random_projection::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].

Object Safety§

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§