Skip to main content

MulAddExt

Trait MulAddExt 

Source
pub trait MulAddExt<A = Self, B = Self> {
    type Output;

    const HAS_TRUE_FMA: bool;

    // Required methods
    fn mul_add(self, a: A, b: B) -> Self::Output;
    fn mul_sub(self, a: A, b: B) -> Self::Output;
    fn nmul_add(self, a: A, b: B) -> Self::Output;
    fn nmul_sub(self, a: A, b: B) -> Self::Output;
    fn mul_adde(self, a: A, b: B) -> Self::Output;
    fn mul_sube(self, a: A, b: B) -> Self::Output;
    fn nmul_adde(self, a: A, b: B) -> Self::Output;
    fn nmul_sube(self, a: A, b: B) -> Self::Output;
}
Expand description

Trait for fused multiply-add operations. This contains all variants of fused multiply-add, including guaranteed FMA and maybe FMA versions.

If the platform does not have native FMA support, the guaranteed FMA will either use a fast compensated arithmetic algorithm, or fall back to slow scalar evaluation to ensure correctness.

This trait is superior to num_traits::MulAdd, but does not include it as a supertrait due to the potential for multiple conflicting implementation warnings.

Required Associated Constants§

Source

const HAS_TRUE_FMA: bool

Indicates whether the implementation uses true fused-multiply-add instructions.

Non-e variants will always be accurate, regardless of this flag, but the e variants will fallback to separate multiply and add operations if this is false.

Required Associated Types§

Source

type Output

The result of the fused operation.

Required Methods§

Source

fn mul_add(self, a: A, b: B) -> Self::Output

Guaranteed fused-multiply-add operation.

If the target architecture does not support native FMA, this will use either compensated arithmetic or slow scalar evaluation to ensure correctness.

Source

fn mul_sub(self, a: A, b: B) -> Self::Output

Guaranteed fused-multiply-subtract operation.

If the target architecture does not support native FMA, this will use either compensated arithmetic or slow scalar evaluation to ensure correctness.

Source

fn nmul_add(self, a: A, b: B) -> Self::Output

Guaranteed fused-negated-multiply-add operation.

If the target architecture does not support native FMA, this will use either compensated arithmetic or slow scalar evaluation to ensure correctness.

Source

fn nmul_sub(self, a: A, b: B) -> Self::Output

Guaranteed fused-negated-multiply-subtract operation.

If the target architecture does not support native FMA, this will use either compensated arithmetic or slow scalar evaluation to ensure correctness.

Source

fn mul_adde(self, a: A, b: B) -> Self::Output

Fused-multiply-add operation where possible. May gracefully degrade to separate multiply and add if the target architecture does not support native FMA.

Source

fn mul_sube(self, a: A, b: B) -> Self::Output

Fused-multiply-subtract operation where possible. May gracefully degrade to separate multiply and subtract if the target architecture does not support native FMA.

Source

fn nmul_adde(self, a: A, b: B) -> Self::Output

Fused-negated-multiply-add operation where possible. May gracefully degrade to separate multiply and add if the target architecture does not support native FMA.

Source

fn nmul_sube(self, a: A, b: B) -> Self::Output

Fused-negated-multiply-subtract operation where possible. May gracefully degrade to separate multiply and subtract if the target architecture does not support native FMA.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MulAddExt for f32

Source§

const HAS_TRUE_FMA: bool = <f32 as FloatRegister>::HAS_TRUE_FMA

Source§

type Output = f32

Source§

fn mul_add(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_sub(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_add(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_sub(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_adde(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_sube(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_adde(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_sube(self, rhs: Self, acc: Self) -> Self

Source§

impl MulAddExt for f64

Source§

const HAS_TRUE_FMA: bool = <f64 as FloatRegister>::HAS_TRUE_FMA

Source§

type Output = f64

Source§

fn mul_add(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_sub(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_add(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_sub(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_adde(self, rhs: Self, acc: Self) -> Self

Source§

fn mul_sube(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_adde(self, rhs: Self, acc: Self) -> Self

Source§

fn nmul_sube(self, rhs: Self, acc: Self) -> Self

Implementors§

Source§

impl<R: FloatRegister> MulAddExt for Vector<R>

Source§

const HAS_TRUE_FMA: bool = R::HAS_TRUE_FMA

Source§

type Output = Vector<R>