Trait MulAdd

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

    // Required method
    fn mul_add(self, a: A, b: B) -> Self::Output;
}
Expand description

Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.

Using mul_add can be more performant than an unfused multiply-add if the target architecture has a dedicated fma CPU instruction.

Note that A and B are Self by default, but this is not mandatory.

§Example

use std::f32;

let m = 10.0_f32;
let x = 4.0_f32;
let b = 60.0_f32;

// 100.0
let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();

assert!(abs_difference <= 100.0 * f32::EPSILON);

Required Associated Types§

Source

type Output

The resulting type after applying the fused multiply-add.

Required Methods§

Source

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

Performs the fused multiply-add operation (self * a) + b

Implementations on Foreign Types§

Source§

impl MulAdd for f32

Source§

type Output = f32

Source§

fn mul_add(self, a: f32, b: f32) -> <f32 as MulAdd>::Output

Source§

impl MulAdd for f64

Source§

type Output = f64

Source§

fn mul_add(self, a: f64, b: f64) -> <f64 as MulAdd>::Output

Source§

impl MulAdd for i8

Source§

type Output = i8

Source§

fn mul_add(self, a: i8, b: i8) -> <i8 as MulAdd>::Output

Source§

impl MulAdd for i16

Source§

type Output = i16

Source§

fn mul_add(self, a: i16, b: i16) -> <i16 as MulAdd>::Output

Source§

impl MulAdd for i32

Source§

type Output = i32

Source§

fn mul_add(self, a: i32, b: i32) -> <i32 as MulAdd>::Output

Source§

impl MulAdd for i64

Source§

type Output = i64

Source§

fn mul_add(self, a: i64, b: i64) -> <i64 as MulAdd>::Output

Source§

impl MulAdd for i128

Source§

type Output = i128

Source§

fn mul_add(self, a: i128, b: i128) -> <i128 as MulAdd>::Output

Source§

impl MulAdd for isize

Source§

impl MulAdd for u8

Source§

type Output = u8

Source§

fn mul_add(self, a: u8, b: u8) -> <u8 as MulAdd>::Output

Source§

impl MulAdd for u16

Source§

type Output = u16

Source§

fn mul_add(self, a: u16, b: u16) -> <u16 as MulAdd>::Output

Source§

impl MulAdd for u32

Source§

type Output = u32

Source§

fn mul_add(self, a: u32, b: u32) -> <u32 as MulAdd>::Output

Source§

impl MulAdd for u64

Source§

type Output = u64

Source§

fn mul_add(self, a: u64, b: u64) -> <u64 as MulAdd>::Output

Source§

impl MulAdd for u128

Source§

type Output = u128

Source§

fn mul_add(self, a: u128, b: u128) -> <u128 as MulAdd>::Output

Source§

impl MulAdd for usize

Source§

impl<'a, 'b, T> MulAdd<&'b Complex<T>> for &'a Complex<T>
where T: Clone + Num + MulAdd<Output = T>,

Source§

type Output = Complex<T>

Source§

fn mul_add(self, other: &Complex<T>, add: &Complex<T>) -> Complex<T>

Source§

impl<'a, 'b, T> MulAdd<&'b Complex<T>> for &'a Complex<T>
where T: Clone + Num + MulAdd<Output = T>,

Source§

type Output = Complex<T>

Source§

fn mul_add(self, other: &Complex<T>, add: &Complex<T>) -> Complex<T>

Source§

impl<Frac, MulFrac> MulAdd<FixedI8<MulFrac>> for FixedI8<Frac>
where MulFrac: LeEqU8,

Source§

type Output = FixedI8<Frac>

Source§

fn mul_add(self, a: FixedI8<MulFrac>, b: FixedI8<Frac>) -> FixedI8<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedI16<MulFrac>> for FixedI16<Frac>
where MulFrac: LeEqU16,

Source§

type Output = FixedI16<Frac>

Source§

fn mul_add(self, a: FixedI16<MulFrac>, b: FixedI16<Frac>) -> FixedI16<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedI32<MulFrac>> for FixedI32<Frac>
where MulFrac: LeEqU32,

Source§

type Output = FixedI32<Frac>

Source§

fn mul_add(self, a: FixedI32<MulFrac>, b: FixedI32<Frac>) -> FixedI32<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedI64<MulFrac>> for FixedI64<Frac>
where MulFrac: LeEqU64,

Source§

type Output = FixedI64<Frac>

Source§

fn mul_add(self, a: FixedI64<MulFrac>, b: FixedI64<Frac>) -> FixedI64<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedI128<MulFrac>> for FixedI128<Frac>
where MulFrac: LeEqU128,

Source§

type Output = FixedI128<Frac>

Source§

fn mul_add(self, a: FixedI128<MulFrac>, b: FixedI128<Frac>) -> FixedI128<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedU8<MulFrac>> for FixedU8<Frac>
where MulFrac: LeEqU8,

Source§

type Output = FixedU8<Frac>

Source§

fn mul_add(self, a: FixedU8<MulFrac>, b: FixedU8<Frac>) -> FixedU8<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedU16<MulFrac>> for FixedU16<Frac>
where MulFrac: LeEqU16,

Source§

type Output = FixedU16<Frac>

Source§

fn mul_add(self, a: FixedU16<MulFrac>, b: FixedU16<Frac>) -> FixedU16<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedU32<MulFrac>> for FixedU32<Frac>
where MulFrac: LeEqU32,

Source§

type Output = FixedU32<Frac>

Source§

fn mul_add(self, a: FixedU32<MulFrac>, b: FixedU32<Frac>) -> FixedU32<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedU64<MulFrac>> for FixedU64<Frac>
where MulFrac: LeEqU64,

Source§

type Output = FixedU64<Frac>

Source§

fn mul_add(self, a: FixedU64<MulFrac>, b: FixedU64<Frac>) -> FixedU64<Frac>

Source§

impl<Frac, MulFrac> MulAdd<FixedU128<MulFrac>> for FixedU128<Frac>
where MulFrac: LeEqU128,

Source§

type Output = FixedU128<Frac>

Source§

fn mul_add(self, a: FixedU128<MulFrac>, b: FixedU128<Frac>) -> FixedU128<Frac>

Source§

impl<T> MulAdd for Complex<T>
where T: Clone + Num + MulAdd<Output = T>,

Source§

type Output = Complex<T>

Source§

fn mul_add(self, other: Complex<T>, add: Complex<T>) -> Complex<T>

Source§

impl<T> MulAdd for Complex<T>
where T: Clone + Num + MulAdd<Output = T>,

Source§

type Output = Complex<T>

Source§

fn mul_add(self, other: Complex<T>, add: Complex<T>) -> Complex<T>

Implementors§

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Extent2<T>, &'b Extent2<T>> for &'c Extent2<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Extent3<T>, &'b Extent3<T>> for &'c Extent3<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Rgb<T>, &'b Rgb<T>> for &'c Rgb<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Rgba<T>, &'b Rgba<T>> for &'c Rgba<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Vec2<T>, &'b Vec2<T>> for &'c Vec2<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Vec3<T>, &'b Vec3<T>> for &'c Vec3<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, 'c, T> MulAdd<&'a Vec4<T>, &'b Vec4<T>> for &'c Vec4<T>
where &'c T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Extent2<T>, &'b Extent2<T>> for Extent2<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Extent3<T>, &'b Extent3<T>> for Extent3<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Rgb<T>, &'b Rgb<T>> for Rgb<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Rgba<T>, &'b Rgba<T>> for Rgba<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Vec2<T>, &'b Vec2<T>> for Vec2<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Vec3<T>, &'b Vec3<T>> for Vec3<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'b, T> MulAdd<&'a Vec4<T>, &'b Vec4<T>> for Vec4<T>
where T: MulAdd<&'a T, &'b T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Extent2<T>, Extent2<T>> for &'c Extent2<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Extent3<T>, Extent3<T>> for &'c Extent3<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Rgb<T>, Rgb<T>> for &'c Rgb<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Rgba<T>, Rgba<T>> for &'c Rgba<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Vec2<T>, Vec2<T>> for &'c Vec2<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Vec3<T>, Vec3<T>> for &'c Vec3<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, 'c, T> MulAdd<&'a Vec4<T>, Vec4<T>> for &'c Vec4<T>
where &'c T: MulAdd<&'a T, T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Extent2<T>> for Extent2<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Extent3<T>> for Extent3<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Rgb<T>> for Rgb<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Rgba<T>> for Rgba<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Vec2<T>> for Vec2<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Vec3<T>> for Vec3<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'a, T> MulAdd<&'a Vec4<T>> for Vec4<T>
where T: MulAdd<&'a T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Extent2<T>, &'b Extent2<T>> for &'c Extent2<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Extent3<T>, &'b Extent3<T>> for &'c Extent3<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Rgb<T>, &'b Rgb<T>> for &'c Rgb<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Rgba<T>, &'b Rgba<T>> for &'c Rgba<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Vec2<T>, &'b Vec2<T>> for &'c Vec2<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Vec3<T>, &'b Vec3<T>> for &'c Vec3<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, 'c, T> MulAdd<Vec4<T>, &'b Vec4<T>> for &'c Vec4<T>
where &'c T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Extent2<T>, &'b Extent2<T>> for Extent2<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Extent3<T>, &'b Extent3<T>> for Extent3<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Rgb<T>, &'b Rgb<T>> for Rgb<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Rgba<T>, &'b Rgba<T>> for Rgba<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Vec2<T>, &'b Vec2<T>> for Vec2<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Vec3<T>, &'b Vec3<T>> for Vec3<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'b, T> MulAdd<Vec4<T>, &'b Vec4<T>> for Vec4<T>
where T: MulAdd<T, &'b T, Output = T>,

Source§

impl<'c, T> MulAdd<Extent2<T>, Extent2<T>> for &'c Extent2<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Extent3<T>, Extent3<T>> for &'c Extent3<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Rgb<T>, Rgb<T>> for &'c Rgb<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Rgba<T>, Rgba<T>> for &'c Rgba<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Vec2<T>, Vec2<T>> for &'c Vec2<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Vec3<T>, Vec3<T>> for &'c Vec3<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<'c, T> MulAdd<Vec4<T>, Vec4<T>> for &'c Vec4<T>
where &'c T: MulAdd<T, T, Output = T>,

Source§

impl<T> MulAdd for Extent2<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Extent3<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Rgb<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Rgba<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Vec2<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Vec3<T>
where T: MulAdd<Output = T>,

Source§

impl<T> MulAdd for Vec4<T>
where T: MulAdd<Output = T>,