10 #ifndef EIGEN_ITERATIVE_SOLVER_BASE_H 11 #define EIGEN_ITERATIVE_SOLVER_BASE_H 17 template<
typename MatrixType>
21 template <
typename T0>
28 struct no {
int a[2];};
40 template<
typename MatrixType>
50 template<
typename MatrixType>
55 template<
int UpLo>
struct ConstSelfAdjointViewReturnType {
64 : m_dummy(0,0), m_matrix(m_dummy)
67 template<
typename InputType>
72 const ActualMatrixType&
matrix()
const 77 template<
typename MatrixDerived>
86 if(&(mat.derived()) != &m_matrix)
99 template<
typename MatrixType>
104 template<
int UpLo>
struct ConstSelfAdjointViewReturnType
142 template<
typename Derived>
147 using Base::m_isInitialized;
157 ColsAtCompileTime = MatrixType::ColsAtCompileTime,
158 MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
181 template<
typename MatrixDerived>
183 : m_matrixWrapper(A.derived())
196 template<
typename MatrixDerived>
200 m_preconditioner.analyzePattern(
matrix());
201 m_isInitialized =
true;
202 m_analysisIsOk =
true;
203 m_info = m_preconditioner.info();
216 template<
typename MatrixDerived>
219 eigen_assert(m_analysisIsOk &&
"You must first call analyzePattern()");
221 m_preconditioner.factorize(
matrix());
222 m_factorizationIsOk =
true;
223 m_info = m_preconditioner.info();
237 template<
typename MatrixDerived>
241 m_preconditioner.compute(
matrix());
242 m_isInitialized =
true;
243 m_analysisIsOk =
true;
244 m_factorizationIsOk =
true;
245 m_info = m_preconditioner.info();
267 m_tolerance = tolerance;
283 return (m_maxIterations<0) ? 2*
matrix().cols() : m_maxIterations;
291 m_maxIterations = maxIters;
298 eigen_assert(m_isInitialized &&
"ConjugateGradient is not initialized.");
307 eigen_assert(m_isInitialized &&
"ConjugateGradient is not initialized.");
316 template<
typename Rhs,
typename Guess>
320 eigen_assert(m_isInitialized &&
"Solver is not initialized.");
321 eigen_assert(derived().
rows()==b.rows() &&
"solve(): invalid number of rows of the right hand side matrix b");
328 eigen_assert(m_isInitialized &&
"IterativeSolverBase is not initialized.");
333 template<
typename Rhs,
typename DestDerived>
338 Index rhsCols = b.cols();
340 DestDerived& dest(aDest.
derived());
346 typename DestDerived::PlainObject tmp(
cols(),rhsCols);
348 for(
Index k=0; k<rhsCols; ++k)
352 derived()._solve_vector_with_guess_impl(tb,tx);
353 tmp.col(k) = tx.sparseView(0);
362 m_info = global_info;
366 template<
typename Rhs,
typename DestDerived>
372 Index rhsCols = b.cols();
373 DestDerived& dest(aDest.derived());
375 for(
Index k=0; k<rhsCols; ++k)
379 derived()._solve_vector_with_guess_impl(bk,xk);
388 m_info = global_info;
391 template<
typename Rhs,
typename DestDerived>
395 derived()._solve_vector_with_guess_impl(b,dest.derived());
399 template<
typename Rhs,
typename Dest>
403 derived()._solve_with_guess_impl(b,x);
409 m_isInitialized =
false;
410 m_analysisIsOk =
false;
411 m_factorizationIsOk =
false;
412 m_maxIterations = -1;
421 return m_matrixWrapper.matrix();
424 template<
typename InputType>
427 m_matrixWrapper.grab(A);
444 #endif // EIGEN_ITERATIVE_SOLVER_BASE_H
generic_matrix_wrapper(const InputType &mat)
const ActualMatrixType & matrix() const
Pseudo expression representing a solving operation.
Derived & setTolerance(const RealScalar &tolerance)
void grab(const MatrixType &mat)
const Block< const Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ConstColXpr
static yes test(const Ref< const T > &, int)
ComputationInfo info() const
IterativeSolverBase(const EigenBase< MatrixDerived > &A)
static MatrixType ms_from
A base class for sparse solvers.
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
any_conversion(const volatile T &)
internal::generic_matrix_wrapper< MatrixType > MatrixWrapper
Namespace containing all symbols from the Eigen library.
Block< Derived, internal::traits< Derived >::RowsAtCompileTime, 1, !IsRowMajor > ColXpr
internal::traits< Derived >::Preconditioner Preconditioner
const Preconditioner & preconditioner() const
void grab(const EigenBase< MatrixDerived > &mat)
generic_matrix_wrapper(const MatrixType &mat)
Derived & factorize(const EigenBase< MatrixDerived > &A)
MatrixType::StorageIndex StorageIndex
SparseSolverBase< Derived > Base
RealScalar tolerance() const
MatrixType ActualMatrixType
void _solve_with_guess_impl(const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
const ActualMatrixType & matrix() const
MatrixType::Scalar Scalar
Base class of any sparse matrices or sparse expressions.
MatrixWrapper::ActualMatrixType ActualMatrixType
Derived & analyzePattern(const EigenBase< MatrixDerived > &A)
Preconditioner m_preconditioner
Derived & compute(const EigenBase< MatrixDerived > &A)
internal::enable_if< Rhs::ColsAtCompileTime==1||DestDerived::ColsAtCompileTime==1 >::type _solve_with_guess_impl(const Rhs &b, MatrixBase< DestDerived > &dest) const
ActualMatrixType m_matrix
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
const ActualMatrixType & matrix() const
const SolveWithGuess< Derived, Rhs, Guess > solveWithGuess(const MatrixBase< Rhs > &b, const Guess &x0) const
NumTraits< Scalar >::Real RealScalar
Ref< const MatrixType > ActualMatrixType
Derived & setMaxIterations(Index maxIters)
A matrix or vector expression mapping an existing expression.
EIGEN_CONSTEXPR Index size(const T &x)
ActualMatrixType::template ConstSelfAdjointViewReturnType< UpLo >::Type Type
detail::initimpl::constructor< Args... > init()
Binds an existing constructor taking arguments Args...
internal::enable_if< Rhs::ColsAtCompileTime!=1 &&DestDerived::ColsAtCompileTime!=1 >::type _solve_with_guess_impl(const Rhs &b, MatrixBase< DestDerived > &aDest) const
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
const Derived & derived() const
void _solve_impl(const Rhs &b, Dest &x) const
MatrixType::RealScalar RealScalar
Preconditioner & preconditioner()
void grab(const Ref< const MatrixType > &mat)
EIGEN_DONT_INLINE void compute(Solver &solver, const MatrixType &A)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
The matrix class, also used for vectors and row-vectors.
internal::traits< Derived >::MatrixType MatrixType
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
const ActualMatrixType * mp_matrix
Base class for linear iterative solvers.
MatrixWrapper m_matrixWrapper
EIGEN_DEVICE_FUNC Derived & derived()
Base class for all dense matrices, vectors, and expressions.
Index maxIterations() const
void grab(const InputType &A)