Clarify in the docs that mul_add is not always faster.
Fixes https://github.com/rust-lang/rust/issues/49842. Other resources: - https://users.rust-lang.org/t/why-does-the-mul-add-method-produce-a-more-accurate-result-with-better-performance/1626 - https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
This commit is contained in:
@@ -195,8 +195,10 @@ impl f32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
||||||
/// error. This produces a more accurate result with better performance than
|
/// error, yielding a more accurate result than an unfused multiply-add.
|
||||||
/// a separate multiplication operation followed by an add.
|
///
|
||||||
|
/// Using `mul_add` can be more performant than an unfused multiply-add if
|
||||||
|
/// the target architecture has a dedicated `fma` CPU instruction.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::f32;
|
/// use std::f32;
|
||||||
|
|||||||
@@ -173,8 +173,10 @@ impl f64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
||||||
/// error. This produces a more accurate result with better performance than
|
/// error, yielding a more accurate result than an unfused multiply-add.
|
||||||
/// a separate multiplication operation followed by an add.
|
///
|
||||||
|
/// Using `mul_add` can be more performant than an unfused multiply-add if
|
||||||
|
/// the target architecture has a dedicated `fma` CPU instruction.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let m = 10.0_f64;
|
/// let m = 10.0_f64;
|
||||||
|
|||||||
Reference in New Issue
Block a user