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§
Sourceconst HAS_TRUE_FMA: bool
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§
Required Methods§
Sourcefn mul_add(self, a: A, b: B) -> Self::Output
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.
Sourcefn mul_sub(self, a: A, b: B) -> Self::Output
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.
Sourcefn nmul_add(self, a: A, b: B) -> Self::Output
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.
Sourcefn nmul_sub(self, a: A, b: B) -> Self::Output
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.
Sourcefn mul_adde(self, a: A, b: B) -> Self::Output
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.
Sourcefn mul_sube(self, a: A, b: B) -> Self::Output
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".