Skip to main content

Float

Trait Float 

pub trait Float: Num {
    const ZERO: Self;
    const ONE: Self;

    // Required method
    fn from_f64(value: f64) -> Self;
}
Expand description

Floating-point dtypes.

Required Associated Constants§

const ZERO: Self

The additive identity.

const ONE: Self

The multiplicative identity.

Required Methods§

fn from_f64(value: f64) -> Self

Materialize a scalar constant of this float type from an f64 literal.

Kernels are generic over D: Float, so they cannot use bare f32/f64 literals when building constant tensors (e.g. T::full(shape, value: D)). from_f64 provides the one hook needed to construct arbitrary constants generically; each concrete float type narrows/keeps the value as needed.

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§

§

impl Float for f32

§

const ZERO: f32 = 0.0

§

const ONE: f32 = 1.0

§

fn from_f64(value: f64) -> f32

§

impl Float for f64

§

const ZERO: f64 = 0.0

§

const ONE: f64 = 1.0

§

fn from_f64(value: f64) -> f64

Implementors§