Trait matrix::scalar::Scalar

source ·
pub trait Scalar: Copy + Clone + Debug + Zero + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self> + Div<Output = Self> + AddAssign + SubAssign + MulAssign + DivAssign + PartialOrd + PartialEq {
    // Required methods
    fn to_f32(self) -> f32;
    fn from_f32(value: f32) -> Self;

    // Provided methods
    fn fma(a: Self, b: Self, c: Self) -> Self { ... }
    fn fms(a: Self, b: Self, c: Self) -> Self { ... }
}
Expand description

A trait for types that act as scalars in mathematical operations, like real numbers or complex numbers. I concider a scalar, any struct which contains all the traits listed bellow. f32 is an example if the Scalar implementation. In the future a Complex Number struct implementation could potentially fit and allign with all the traits listed bellow.

Required Methods§

source

fn to_f32(self) -> f32

source

fn from_f32(value: f32) -> Self

Provided Methods§

source

fn fma(a: Self, b: Self, c: Self) -> Self

Fused Multiply-Add (FMA): Default implementation that computes a * b + c.

source

fn fms(a: Self, b: Self, c: Self) -> Self

Fused Multiply-Sub (FMS): Default implementation that computes a * b - c.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Scalar for f32

source§

fn fma(a: f32, b: f32, c: f32) -> f32

source§

fn fms(a: f32, b: f32, c: f32) -> f32

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

source§

impl Scalar for f64

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

source§

impl Scalar for i32

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

source§

impl Scalar for i64

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

source§

impl Scalar for u32

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

source§

impl Scalar for u64

source§

fn from_f32(value: f32) -> Self

source§

fn to_f32(self) -> f32

Implementors§