Go to the documentation of this file.
10 #ifndef EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H
11 #define EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H
26 template<
typename MatrixType,
typename Rhs,
typename Dest,
typename Preconditioner>
29 const Preconditioner& precond,
Index& iters,
39 Index maxIters = iters;
43 VectorType residual = rhs -
mat *
x;
44 VectorType normal_residual =
mat.adjoint() * residual;
55 RealScalar residualNorm2 = normal_residual.squaredNorm();
56 if (residualNorm2 < threshold)
59 tol_error =
sqrt(residualNorm2 / rhsNorm2);
64 p = precond.solve(normal_residual);
66 VectorType z(
n), tmp(m);
71 tmp.noalias() =
mat * p;
75 residual -=
alpha * tmp;
76 normal_residual =
mat.adjoint() * residual;
78 residualNorm2 = normal_residual.squaredNorm();
79 if(residualNorm2 < threshold)
82 z = precond.solve(normal_residual);
90 tol_error =
sqrt(residualNorm2 / rhsNorm2);
96 template<
typename _MatrixType,
97 typename _Preconditioner = LeastSquareDiagonalPreconditioner<typename _MatrixType::Scalar> >
102 template<
typename _MatrixType,
typename _Preconditioner>
148 template<
typename _MatrixType,
typename _Preconditioner>
178 template<
typename MatrixDerived>
184 template<
typename Rhs,
typename Dest>
190 for(
Index j=0; j<
b.cols(); ++j)
205 template<
typename Rhs,
typename Dest>
216 #endif // EIGEN_LEAST_SQUARE_CONJUGATE_GRADIENT_H
const EIGEN_DEVICE_FUNC SqrtReturnType sqrt() const
MatrixType::Scalar Scalar
Map< Matrix< Scalar, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > MatrixType
NumTraits< Scalar >::Real RealScalar
void _solve_impl(const MatrixBase< Rhs > &b, Dest &x) const
void _solve_with_guess_impl(const Rhs &b, Dest &x) const
MatrixType::RealScalar RealScalar
IterativeSolverBase< LeastSquaresConjugateGradient > Base
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
_Preconditioner Preconditioner
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
LeastSquaresConjugateGradient()
Index maxIterations() const
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
Base class for linear iterative solvers.
A conjugate gradient solver for sparse (or dense) least-square problems.
_Preconditioner Preconditioner
void _solve_impl(const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
LeastSquaresConjugateGradient(const EigenBase< MatrixDerived > &A)
const ActualMatrixType & matrix() const
~LeastSquaresConjugateGradient()
Base class for all dense matrices, vectors, and expressions.
MatrixType A(a, *n, *n, *lda)
Preconditioner m_preconditioner
EIGEN_DONT_INLINE void least_square_conjugate_gradient(const MatrixType &mat, const Rhs &rhs, Dest &x, const Preconditioner &precond, Index &iters, typename Dest::RealScalar &tol_error)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
#define EIGEN_DONT_INLINE
control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:52