Open benruijl opened 5 years ago
At the moment the dual implementation of the MulAdd trait simply does self * a + b, which actually doesn't honor the trait:
MulAdd
self * a + b
Fused multiply-add. Computes (self * a) + b with only one rounding error, yielding a more accurate result than an unfused multiply-add.
Instead we should use something like:
impl<T: Scalar + Num + Mul + Add + MulAdd<Output = T>, N: Dim + DimName> MulAdd<T, T> for DualN<T, N> where DefaultAllocator: Allocator<T, N>, Owned<T, N>: Copy, { type Output = DualN<T, N>; #[inline] fn mul_add(self, a: T, b: T) -> DualN<T, N> { self.map_dual(self.real().mul_add(a, b), |x| *x * a) } }
At the moment the dual implementation of the
MulAdd
trait simply doesself * a + b
, which actually doesn't honor the trait:Instead we should use something like: