10#ifndef EIGEN_SPARSEUTIL_H
11#define EIGEN_SPARSEUTIL_H
14#include "./InternalHeaderCheck.h"
19#define EIGEN_DBG_SPARSE(X)
21#define EIGEN_DBG_SPARSE(X) X
24#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
25 template <typename OtherDerived> \
26 EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) { \
27 return Base::operator Op(other.derived()); \
29 EIGEN_STRONG_INLINE Derived& operator Op(const Derived & other) { return Base::operator Op(other); }
31#define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
32 template <typename Other> \
33 EIGEN_STRONG_INLINE Derived& operator Op(const Other & scalar) { \
34 return Base::operator Op(scalar); \
37#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)
39#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
41const int CoherentAccessPattern = 0x1;
42const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
43const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
44const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
46template <
typename Scalar_,
int Flags_ = 0,
typename StorageIndex_ =
int>
48template <
typename Scalar_,
int Flags_ = 0,
typename StorageIndex_ =
int>
51template <
typename MatrixType,
unsigned int UpLo>
53template <
typename Lhs,
typename Rhs>
54class SparseDiagonalProduct;
55template <
typename MatrixType>
58template <
typename Lhs,
typename Rhs>
59class SparseSparseProduct;
60template <
typename Lhs,
typename Rhs>
61class SparseTimeDenseProduct;
62template <
typename Lhs,
typename Rhs>
63class DenseTimeSparseProduct;
64template <
typename Lhs,
typename Rhs,
bool Transpose>
65class SparseDenseOuterProduct;
67template <
typename Lhs,
typename Rhs>
68struct SparseSparseProductReturnType;
69template <
typename Lhs,
typename Rhs,
70 int InnerSize = internal::min_size_prefer_fixed(internal::traits<Lhs>::ColsAtCompileTime,
71 internal::traits<Rhs>::RowsAtCompileTime)>
72struct DenseSparseProductReturnType;
74template <
typename Lhs,
typename Rhs,
75 int InnerSize = internal::min_size_prefer_fixed(internal::traits<Lhs>::ColsAtCompileTime,
76 internal::traits<Rhs>::RowsAtCompileTime)>
77struct SparseDenseProductReturnType;
78template <
typename MatrixType,
int UpLo>
79class SparseSymmetricPermutationProduct;
83template <
typename T,
int Rows,
int Cols,
int Flags>
87struct eval<T,
Sparse> : sparse_eval<T, traits<T>::RowsAtCompileTime, traits<T>::ColsAtCompileTime, traits<T>::Flags> {
90template <
typename T,
int Cols,
int Flags>
91struct sparse_eval<T, 1, Cols, Flags> {
92 typedef typename traits<T>::Scalar Scalar_;
93 typedef typename traits<T>::StorageIndex StorageIndex_;
99template <
typename T,
int Rows,
int Flags>
100struct sparse_eval<T, Rows, 1, Flags> {
101 typedef typename traits<T>::Scalar Scalar_;
102 typedef typename traits<T>::StorageIndex StorageIndex_;
105 typedef SparseVector<Scalar_, ColMajor, StorageIndex_> type;
109template <
typename T,
int Rows,
int Cols,
int Flags>
111 typedef typename traits<T>::Scalar Scalar_;
112 typedef typename traits<T>::StorageIndex StorageIndex_;
116 typedef SparseMatrix<Scalar_, Options_, StorageIndex_> type;
119template <
typename T,
int Flags>
120struct sparse_eval<T, 1, 1, Flags> {
121 typedef typename traits<T>::Scalar Scalar_;
124 typedef Matrix<Scalar_, 1, 1> type;
128struct plain_matrix_type<T, Sparse> {
129 typedef typename traits<T>::Scalar Scalar_;
130 typedef typename traits<T>::StorageIndex StorageIndex_;
134 typedef SparseMatrix<Scalar_, Options_, StorageIndex_> type;
138struct plain_object_eval<T, Sparse>
139 : sparse_eval<T, traits<T>::RowsAtCompileTime, traits<T>::ColsAtCompileTime, evaluator<T>::Flags> {};
141template <
typename Decomposition,
typename RhsType>
142struct solve_traits<Decomposition, RhsType, Sparse> {
143 typedef typename sparse_eval<RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime,
144 traits<RhsType>::Flags>::type PlainObject;
147template <
typename Derived>
148struct generic_xpr_base<Derived, MatrixXpr, Sparse> {
149 typedef SparseMatrixBase<Derived> type;
152struct SparseTriangularShape {
153 static std::string debugName() {
return "SparseTriangularShape"; }
155struct SparseSelfAdjointShape {
156 static std::string debugName() {
return "SparseSelfAdjointShape"; }
160struct glue_shapes<SparseShape, SelfAdjointShape> {
161 typedef SparseSelfAdjointShape type;
164struct glue_shapes<SparseShape, TriangularShape> {
165 typedef SparseTriangularShape type;
169struct LowerBoundIndex {
170 LowerBoundIndex() : value(-1), found(false) {}
171 LowerBoundIndex(Index val,
bool ok) : value(val), found(ok) {}
186template <typename Scalar, typename StorageIndex = typename SparseMatrix<Scalar>::StorageIndex>
189 Triplet() : m_row(0), m_col(0), m_value(0) {}
191 Triplet(
const StorageIndex& i,
const StorageIndex& j,
const Scalar& v = Scalar(0)) : m_row(i), m_col(j), m_value(v) {}
194 const StorageIndex&
row()
const {
return m_row; }
197 const StorageIndex&
col()
const {
return m_col; }
200 const Scalar&
value()
const {
return m_value; }
203 StorageIndex m_row, m_col;
A versatible sparse matrix representation.
Definition SparseUtil.h:47
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition SparseUtil.h:52
a sparse vector class
Definition SparseVector.h:62
Expression of a dense or sparse matrix with zero or too small values removed.
Definition SparseView.h:45
A small structure to hold a non zero as a triplet (i,j,value).
Definition SparseUtil.h:187
const StorageIndex & col() const
Definition SparseUtil.h:197
const Scalar & value() const
Definition SparseUtil.h:200
const StorageIndex & row() const
Definition SparseUtil.h:194
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition Core:137
Definition Constants.h:519