10 #ifndef EIGEN_ITERATIVE_SOLVER_BASE_H
11 #define EIGEN_ITERATIVE_SOLVER_BASE_H
19 template<
typename MatrixType>
20 struct is_ref_compatible_impl
23 template <
typename T0>
26 template <
typename T> any_conversion(
const volatile T&);
27 template <
typename T> any_conversion(
T&);
29 struct yes {
int a[1];};
30 struct no {
int a[2];};
33 static yes test(
const Ref<const T>&,
int);
35 static no test(any_conversion<T>, ...);
39 enum { value =
sizeof(test<MatrixType>(ms_from, 0))==
sizeof(yes) };
42 template<
typename MatrixType>
43 struct is_ref_compatible
45 enum { value = is_ref_compatible_impl<remove_all_t<MatrixType>>::value };
48 template<typename MatrixType, bool MatrixFree = !internal::is_ref_compatible<MatrixType>::value>
49 class generic_matrix_wrapper;
52 template<
typename MatrixType>
56 typedef Ref<const MatrixType> ActualMatrixType;
57 template<
int UpLo>
struct ConstSelfAdjointViewReturnType {
65 generic_matrix_wrapper()
66 : m_dummy(0,0), m_matrix(m_dummy)
69 template<
typename InputType>
70 generic_matrix_wrapper(
const InputType &
mat)
74 const ActualMatrixType& matrix()
const
79 template<
typename MatrixDerived>
80 void grab(
const EigenBase<MatrixDerived> &
mat)
86 void grab(
const Ref<const MatrixType> &
mat)
88 if(&(
mat.derived()) != &m_matrix)
97 ActualMatrixType m_matrix;
101 template<
typename MatrixType>
106 template<
int UpLo>
struct ConstSelfAdjointViewReturnType
108 typedef ActualMatrixType
Type;
115 generic_matrix_wrapper()
123 const ActualMatrixType& matrix()
const
134 const ActualMatrixType *mp_matrix;
144 template<
typename Derived>
183 template<
typename MatrixDerived>
201 template<
typename MatrixDerived>
221 template<
typename MatrixDerived>
242 template<
typename MatrixDerived>
321 template<
typename Rhs,
typename Guess>
338 template<
typename Rhs,
typename DestDerived>
345 DestDerived& dest(aDest.
derived());
346 typedef typename DestDerived::Scalar DestScalar;
351 typename DestDerived::PlainObject tmp(
cols(),rhsCols);
353 for(
Index k=0; k<rhsCols; ++k)
357 derived()._solve_vector_with_guess_impl(tb,tx);
371 template<
typename Rhs,
typename DestDerived>
372 std::enable_if_t<Rhs::ColsAtCompileTime!=1 && DestDerived::ColsAtCompileTime!=1>
378 DestDerived& dest(aDest.
derived());
380 for(
Index k=0; k<rhsCols; ++k)
382 typename DestDerived::ColXpr xk(dest,k);
383 typename Rhs::ConstColXpr bk(
b,k);
384 derived()._solve_vector_with_guess_impl(bk,xk);
396 template<
typename Rhs,
typename DestDerived>
397 std::enable_if_t<Rhs::ColsAtCompileTime==1 || DestDerived::ColsAtCompileTime==1>
404 template<
typename Rhs,
typename Dest>
429 template<
typename InputType>
Matrix< float, 1, Dynamic > MatrixType
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
internal::traits< Derived >::Scalar Scalar
Base class for linear iterative solvers.
internal::generic_matrix_wrapper< MatrixType > MatrixWrapper
ComputationInfo info() const
Derived & factorize(const EigenBase< MatrixDerived > &A)
Index maxIterations() const
IterativeSolverBase(IterativeSolverBase &&)=default
internal::traits< Derived >::MatrixType MatrixType
std::enable_if_t< Rhs::ColsAtCompileTime==1||DestDerived::ColsAtCompileTime==1 > _solve_with_guess_impl(const Rhs &b, MatrixBase< DestDerived > &dest) const
IterativeSolverBase(const EigenBase< MatrixDerived > &A)
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Derived & analyzePattern(const EigenBase< MatrixDerived > &A)
MatrixWrapper::ActualMatrixType ActualMatrixType
MatrixType::RealScalar RealScalar
void grab(const InputType &A)
Preconditioner & preconditioner()
std::enable_if_t< Rhs::ColsAtCompileTime!=1 &&DestDerived::ColsAtCompileTime!=1 > _solve_with_guess_impl(const Rhs &b, MatrixBase< DestDerived > &aDest) const
MatrixType::Scalar Scalar
MatrixWrapper m_matrixWrapper
const Preconditioner & preconditioner() const
internal::traits< Derived >::Preconditioner Preconditioner
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Derived & compute(const EigenBase< MatrixDerived > &A)
void _solve_impl(const Rhs &b, Dest &x) const
Preconditioner m_preconditioner
MatrixType::StorageIndex StorageIndex
void _solve_with_guess_impl(const Rhs &b, SparseMatrixBase< DestDerived > &aDest) const
SparseSolverBase< Derived > Base
Derived & setTolerance(const RealScalar &tolerance)
RealScalar tolerance() const
const SolveWithGuess< Derived, Rhs, Guess > solveWithGuess(const MatrixBase< Rhs > &b, const Guess &x0) const
const ActualMatrixType & matrix() const
Derived & setMaxIterations(Index maxIters)
Base class for all dense matrices, vectors, and expressions.
The matrix class, also used for vectors and row-vectors.
Pseudo expression representing a solving operation.
Base class of any sparse matrices or sparse expressions.
A base class for sparse solvers.
const SparseView< Derived > sparseView(const Scalar &m_reference=Scalar(0), const typename NumTraits< Scalar >::Real &m_epsilon=NumTraits< Scalar >::dummy_precision()) const
T * construct_at(T *p, Args &&... args)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.