Skip to main content

Float

Trait Float 

Source
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§

Source

const ZERO: Self

The additive identity.

Source

const ONE: Self

The multiplicative identity.

Required Methods§

Source

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§

Source§

impl Float for f32

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn from_f64(value: f64) -> Self

Source§

impl Float for f64

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

fn from_f64(value: f64) -> Self

Implementors§