Use numext::fma in more places in SparseCore.
diff --git a/Eigen/src/SparseCore/SparseDot.h b/Eigen/src/SparseCore/SparseDot.h
index 76a4f6c..8aeebc8 100644
--- a/Eigen/src/SparseCore/SparseDot.h
+++ b/Eigen/src/SparseCore/SparseDot.h
@@ -67,7 +67,7 @@
Scalar res(0);
while (i && j) {
if (i.index() == j.index()) {
- res += numext::conj(i.value()) * j.value();
+ res = numext::fma(numext::conj(i.value()), j.value(), res);
++i;
++j;
} else if (i.index() < j.index())
diff --git a/Eigen/src/SparseCore/TriangularSolver.h b/Eigen/src/SparseCore/TriangularSolver.h
index 7753a24..10e27d7 100644
--- a/Eigen/src/SparseCore/TriangularSolver.h
+++ b/Eigen/src/SparseCore/TriangularSolver.h
@@ -41,7 +41,7 @@
lastVal = it.value();
lastIndex = it.index();
if (lastIndex == i) break;
- tmp -= lastVal * other.coeff(lastIndex, col);
+ tmp = numext::fma(-lastVal, other.coeff(lastIndex, col), tmp);
}
if (Mode & UnitDiag)
other.coeffRef(i, col) = tmp;
@@ -75,7 +75,7 @@
} else if (it && it.index() == i)
++it;
for (; it; ++it) {
- tmp -= it.value() * other.coeff(it.index(), col);
+ tmp = numext::fma(-it.value(), other.coeff(it.index(), col), tmp);
}
if (Mode & UnitDiag)
@@ -107,7 +107,9 @@
tmp /= it.value();
}
if (it && it.index() == i) ++it;
- for (; it; ++it) other.coeffRef(it.index(), col) -= tmp * it.value();
+ for (; it; ++it) {
+ other.coeffRef(it.index(), col) = numext::fma(-tmp, it.value(), other.coeffRef(it.index(), col));
+ }
}
}
}
@@ -135,7 +137,9 @@
other.coeffRef(i, col) /= it.value();
}
LhsIterator it(lhsEval, i);
- for (; it && it.index() < i; ++it) other.coeffRef(it.index(), col) -= tmp * it.value();
+ for (; it && it.index() < i; ++it) {
+ other.coeffRef(it.index(), col) = numext::fma(-tmp, it.value(), other.coeffRef(it.index(), col));
+ }
}
}
}
@@ -215,9 +219,13 @@
tempVector.restart();
if (IsLower) {
if (it.index() == i) ++it;
- for (; it; ++it) tempVector.coeffRef(it.index()) -= ci * it.value();
+ for (; it; ++it) {
+ tempVector.coeffRef(it.index()) = numext::fma(-ci, it.value(), tempVector.coeffRef(it.index()));
+ }
} else {
- for (; it && it.index() < i; ++it) tempVector.coeffRef(it.index()) -= ci * it.value();
+ for (; it && it.index() < i; ++it) {
+ tempVector.coeffRef(it.index()) = numext::fma(-ci, it.value(), tempVector.coeffRef(it.index()));
+ }
}
}
}