mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-16 05:35:57 +08:00
Use numext::sqrt in ConjugateGradient.
(cherry picked from commit 7896c7dc6bd1bd34dd9636bdd3426e3c28e6a246)
This commit is contained in:
parent
a5469a6f0f
commit
61efca2e90
@ -29,8 +29,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;
|
||||||
@ -56,7 +54,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +84,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,10 +279,10 @@ struct vectorization_logic_half
|
|||||||
// which causes many of these tests to fail since they don't vectorize if
|
// which causes many of these tests to fail since they don't vectorize if
|
||||||
// EIGEN_UNALIGNED_VECTORIZE is 0 (the matrix is assumed unaligned).
|
// EIGEN_UNALIGNED_VECTORIZE is 0 (the matrix is assumed unaligned).
|
||||||
// Adjust the matrix sizes to account for these alignment issues.
|
// Adjust the matrix sizes to account for these alignment issues.
|
||||||
constexpr int PacketBytes = sizeof(Scalar)*PacketSize;
|
enum { PacketBytes = sizeof(Scalar)*PacketSize };
|
||||||
constexpr int MinVSize = EIGEN_UNALIGNED_VECTORIZE ? PacketSize
|
enum { MinVSize = EIGEN_UNALIGNED_VECTORIZE ? PacketSize
|
||||||
: PacketBytes >= EIGEN_MIN_ALIGN_BYTES ? PacketSize
|
: PacketBytes >= EIGEN_MIN_ALIGN_BYTES ? PacketSize
|
||||||
: (EIGEN_MIN_ALIGN_BYTES + sizeof(Scalar) - 1) / sizeof(Scalar);
|
: (EIGEN_MIN_ALIGN_BYTES + sizeof(Scalar) - 1) / sizeof(Scalar) };
|
||||||
|
|
||||||
typedef Matrix<Scalar,MinVSize,1> Vector1;
|
typedef Matrix<Scalar,MinVSize,1> Vector1;
|
||||||
typedef Matrix<Scalar,MinVSize,MinVSize> Matrix11;
|
typedef Matrix<Scalar,MinVSize,MinVSize> Matrix11;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user