10 #ifndef EIGEN_SPARSESOLVERBASE_H
11 #define EIGEN_SPARSESOLVERBASE_H
13 #include "./InternalHeaderCheck.h"
23 template<
typename Decomposition,
typename Rhs,
typename Dest>
24 std::enable_if_t<Rhs::ColsAtCompileTime!=1 && Dest::ColsAtCompileTime!=1>
25 solve_sparse_through_dense_panels(
const Decomposition &dec,
const Rhs& rhs, Dest &dest)
27 EIGEN_STATIC_ASSERT((Dest::Flags&
RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
28 typedef typename Dest::Scalar DestScalar;
30 static const Index NbColsAtOnce = 4;
31 Index rhsCols = rhs.cols();
32 Index size = rhs.rows();
34 Index tmpCols = (std::min)(rhsCols, NbColsAtOnce);
37 for(
Index k=0; k<rhsCols; k+=NbColsAtOnce)
39 Index actualCols = std::min<Index>(rhsCols-k, NbColsAtOnce);
40 tmp.leftCols(actualCols) = rhs.middleCols(k,actualCols);
41 tmpX.leftCols(actualCols) = dec.solve(tmp.leftCols(actualCols));
42 dest.middleCols(k,actualCols) = tmpX.leftCols(actualCols).sparseView();
47 template<
typename Decomposition,
typename Rhs,
typename Dest>
48 std::enable_if_t<Rhs::ColsAtCompileTime==1 || Dest::ColsAtCompileTime==1>
49 solve_sparse_through_dense_panels(
const Decomposition &dec,
const Rhs& rhs, Dest &dest)
51 typedef typename Dest::Scalar DestScalar;
52 Index size = rhs.rows();
55 dest_dense = dec.solve(rhs_dense);
56 dest = dest_dense.sparseView();
68 template<
typename Derived>
75 : m_isInitialized(false)
83 Derived& derived() {
return *
static_cast<Derived*
>(
this); }
84 const Derived& derived()
const {
return *
static_cast<const Derived*
>(
this); }
90 template<
typename Rhs>
91 inline const Solve<Derived, Rhs>
94 eigen_assert(m_isInitialized &&
"Solver is not initialized.");
95 eigen_assert(derived().rows()==b.
rows() &&
"solve(): invalid number of rows of the right hand side matrix b");
103 template<
typename Rhs>
107 eigen_assert(m_isInitialized &&
"Solver is not initialized.");
108 eigen_assert(derived().rows()==b.
rows() &&
"solve(): invalid number of rows of the right hand side matrix b");
112 #ifndef EIGEN_PARSED_BY_DOXYGEN
114 template<
typename Rhs,
typename Dest>
117 internal::solve_sparse_through_dense_panels(derived(), b.
derived(), dest.
derived());
123 mutable bool m_isInitialized;
Derived & derived()
Definition: EigenBase.h:48
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Pseudo expression representing a solving operation.
Definition: Solve.h:65
Base class of any sparse matrices or sparse expressions.
Definition: SparseMatrixBase.h:30
Index rows() const
Definition: SparseMatrixBase.h:176
A base class for sparse solvers.
Definition: SparseSolverBase.h:70
const Solve< Derived, Rhs > solve(const SparseMatrixBase< Rhs > &b) const
Definition: SparseSolverBase.h:105
const Solve< Derived, Rhs > solve(const MatrixBase< Rhs > &b) const
Definition: SparseSolverBase.h:92
SparseSolverBase()
Definition: SparseSolverBase.h:74
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
Derived & derived()
Definition: EigenBase.h:48