Go to the documentation of this file.
10 #ifndef EIGEN_CONJUGATE_GRADIENT_H
11 #define EIGEN_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;
55 RealScalar residualNorm2 = residual.squaredNorm();
56 if (residualNorm2 < threshold)
59 tol_error =
sqrt(residualNorm2 / rhsNorm2);
64 p = precond.solve(residual);
66 VectorType z(
n), tmp(
n);
71 tmp.noalias() =
mat * p;
75 residual -=
alpha * tmp;
77 residualNorm2 = residual.squaredNorm();
78 if(residualNorm2 < threshold)
81 z = precond.solve(residual);
89 tol_error =
sqrt(residualNorm2 / rhsNorm2);
95 template<
typename _MatrixType,
int _UpLo=
Lower,
96 typename _Preconditioner = DiagonalPreconditioner<typename _MatrixType::Scalar> >
101 template<
typename _MatrixType,
int _UpLo,
typename _Preconditioner>
157 template<
typename _MatrixType,
int _UpLo,
typename _Preconditioner>
191 template<
typename MatrixDerived>
197 template<
typename Rhs,
typename Dest>
203 TransposeInput = (!MatrixWrapper::MatrixFree)
205 && (!MatrixType::IsRowMajor)
213 >::type SelfAdjointWrapper;
217 for(
Index j=0; j<
b.cols(); ++j)
223 RowMajorWrapper row_mat(
matrix());
227 m_isInitialized =
true;
233 template<
typename Rhs,
typename Dest>
246 #endif // EIGEN_CONJUGATE_GRADIENT_H
const EIGEN_DEVICE_FUNC SqrtReturnType sqrt() const
_Preconditioner Preconditioner
Map< Matrix< Scalar, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > MatrixType
MatrixType::RealScalar RealScalar
NumTraits< Scalar >::Real RealScalar
_Preconditioner Preconditioner
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
void _solve_with_guess_impl(const Rhs &b, Dest &x) const
Index maxIterations() const
A conjugate gradient solver for sparse (or dense) self-adjoint problems.
MatrixType::Scalar Scalar
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
Base class for linear iterative solvers.
void _solve_impl(const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
const ActualMatrixType & matrix() const
void _solve_impl(const MatrixBase< Rhs > &b, Dest &x) const
IterativeSolverBase< ConjugateGradient > Base
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
Base class for all dense matrices, vectors, and expressions.
#define EIGEN_IMPLIES(a, b)
MatrixType A(a, *n, *n, *lda)
Expression of an array as a mathematical vector or matrix.
MatrixWrapper::ActualMatrixType ActualMatrixType
Preconditioner m_preconditioner
EIGEN_DONT_INLINE void conjugate_gradient(const MatrixType &mat, const Rhs &rhs, Dest &x, const Preconditioner &precond, Index &iters, typename Dest::RealScalar &tol_error)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
ConjugateGradient(const EigenBase< MatrixDerived > &A)
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:40