mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-13 01:43:13 +08:00
Use numext::sqrt in ConjugateGradient.
This commit is contained in:
parent
e618c4a5e9
commit
7896c7dc6b
@ -31,8 +31,6 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
|
|||||||
const Preconditioner& precond, Index& iters,
|
const Preconditioner& precond, Index& iters,
|
||||||
typename Dest::RealScalar& tol_error)
|
typename Dest::RealScalar& tol_error)
|
||||||
{
|
{
|
||||||
using std::sqrt;
|
|
||||||
using std::abs;
|
|
||||||
typedef typename Dest::RealScalar RealScalar;
|
typedef typename Dest::RealScalar RealScalar;
|
||||||
typedef typename Dest::Scalar Scalar;
|
typedef typename Dest::Scalar Scalar;
|
||||||
typedef Matrix<Scalar,Dynamic,1> VectorType;
|
typedef Matrix<Scalar,Dynamic,1> VectorType;
|
||||||
@ -58,7 +56,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
|
|||||||
if (residualNorm2 < threshold)
|
if (residualNorm2 < threshold)
|
||||||
{
|
{
|
||||||
iters = 0;
|
iters = 0;
|
||||||
tol_error = sqrt(residualNorm2 / rhsNorm2);
|
tol_error = numext::sqrt(residualNorm2 / rhsNorm2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ void conjugate_gradient(const MatrixType& mat, const Rhs& rhs, Dest& x,
|
|||||||
p = z + beta * p; // update search direction
|
p = z + beta * p; // update search direction
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
tol_error = sqrt(residualNorm2 / rhsNorm2);
|
tol_error = numext::sqrt(residualNorm2 / rhsNorm2);
|
||||||
iters = i;
|
iters = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user