Use numext::sqrt in ConjugateGradient.

This commit is contained in:
Antonio Sánchez 2022-07-29 20:17:23 +00:00 committed by Rasmus Munk Larsen
parent e618c4a5e9
commit 7896c7dc6b

View File

@ -31,8 +31,6 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
const Preconditioner& precond, Index& iters,
typename Dest::RealScalar& tol_error)
{
using std::sqrt;
using std::abs;
typedef typename Dest::RealScalar RealScalar;
typedef typename Dest::Scalar Scalar;
typedef Matrix<Scalar,Dynamic,1> VectorType;
@ -58,7 +56,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
if (residualNorm2 < threshold)
{
iters = 0;
tol_error = sqrt(residualNorm2 / rhsNorm2);
tol_error = numext::sqrt(residualNorm2 / rhsNorm2);
return;
}
@ -88,7 +86,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
p = z + beta * p; // update search direction
i++;
}
tol_error = sqrt(residualNorm2 / rhsNorm2);
tol_error = numext::sqrt(residualNorm2 / rhsNorm2);
iters = i;
}