mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-23 21:34:30 +08:00
Use numext::fma in more places in SparseCore.
This commit is contained in:
parent
d7fa5ebe0e
commit
2cf66d4b0d
@ -67,7 +67,7 @@ inline typename internal::traits<Derived>::Scalar SparseMatrixBase<Derived>::dot
|
|||||||
Scalar res(0);
|
Scalar res(0);
|
||||||
while (i && j) {
|
while (i && j) {
|
||||||
if (i.index() == j.index()) {
|
if (i.index() == j.index()) {
|
||||||
res += numext::conj(i.value()) * j.value();
|
res = numext::fma(numext::conj(i.value()), j.value(), res);
|
||||||
++i;
|
++i;
|
||||||
++j;
|
++j;
|
||||||
} else if (i.index() < j.index())
|
} else if (i.index() < j.index())
|
||||||
|
@ -41,7 +41,7 @@ struct sparse_solve_triangular_selector<Lhs, Rhs, Mode, Lower, RowMajor> {
|
|||||||
lastVal = it.value();
|
lastVal = it.value();
|
||||||
lastIndex = it.index();
|
lastIndex = it.index();
|
||||||
if (lastIndex == i) break;
|
if (lastIndex == i) break;
|
||||||
tmp -= lastVal * other.coeff(lastIndex, col);
|
tmp = numext::fma(-lastVal, other.coeff(lastIndex, col), tmp);
|
||||||
}
|
}
|
||||||
if (Mode & UnitDiag)
|
if (Mode & UnitDiag)
|
||||||
other.coeffRef(i, col) = tmp;
|
other.coeffRef(i, col) = tmp;
|
||||||
@ -75,7 +75,7 @@ struct sparse_solve_triangular_selector<Lhs, Rhs, Mode, Upper, RowMajor> {
|
|||||||
} else if (it && it.index() == i)
|
} else if (it && it.index() == i)
|
||||||
++it;
|
++it;
|
||||||
for (; it; ++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)
|
if (Mode & UnitDiag)
|
||||||
@ -107,7 +107,9 @@ struct sparse_solve_triangular_selector<Lhs, Rhs, Mode, Lower, ColMajor> {
|
|||||||
tmp /= it.value();
|
tmp /= it.value();
|
||||||
}
|
}
|
||||||
if (it && it.index() == i) ++it;
|
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 @@ struct sparse_solve_triangular_selector<Lhs, Rhs, Mode, Upper, ColMajor> {
|
|||||||
other.coeffRef(i, col) /= it.value();
|
other.coeffRef(i, col) /= it.value();
|
||||||
}
|
}
|
||||||
LhsIterator it(lhsEval, i);
|
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 @@ struct sparse_solve_triangular_sparse_selector<Lhs, Rhs, Mode, UpLo, ColMajor> {
|
|||||||
tempVector.restart();
|
tempVector.restart();
|
||||||
if (IsLower) {
|
if (IsLower) {
|
||||||
if (it.index() == i) ++it;
|
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 {
|
} 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()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user