Trait num_traits::ops::mul_add::MulAdd [−][src]
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 <= f32::EPSILON);
Associated Types
type Output
The resulting type after applying the fused multiply-add.
Required Methods
Implementors
impl MulAdd for isize type Output = Self;
impl MulAdd for usize type Output = Self;
impl MulAdd for i8 type Output = Self;
impl MulAdd for u8 type Output = Self;
impl MulAdd for i16 type Output = Self;
impl MulAdd for u16 type Output = Self;
impl MulAdd for i32 type Output = Self;
impl MulAdd for u32 type Output = Self;
impl MulAdd for i64 type Output = Self;
impl MulAdd for u64 type Output = Self;
impl MulAdd for i128 type Output = Self;
impl MulAdd for u128 type Output = Self;