10#ifndef EIGEN_SPARSEUTIL_H
11#define EIGEN_SPARSEUTIL_H
13#include "./InternalHeaderCheck.h"
18#define EIGEN_DBG_SPARSE(X)
20#define EIGEN_DBG_SPARSE(X) X
23#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
24template<typename OtherDerived> \
25EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) \
27 return Base::operator Op(other.derived()); \
29EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
31 return Base::operator Op(other); \
34#define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
35template<typename Other> \
36EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
38 return Base::operator Op(scalar); \
41#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
42EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)
45#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
46 EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
49const int CoherentAccessPattern = 0x1;
50const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
51const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
52const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
54template<
typename Scalar_,
int _Flags = 0,
typename StorageIndex_ =
int>
class SparseMatrix;
55template<
typename Scalar_,
int _Flags = 0,
typename StorageIndex_ =
int>
class SparseVector;
57template<
typename MatrixType,
unsigned int UpLo>
class SparseSelfAdjointView;
58template<
typename Lhs,
typename Rhs>
class SparseDiagonalProduct;
59template<
typename MatrixType>
class SparseView;
61template<
typename Lhs,
typename Rhs>
class SparseSparseProduct;
62template<
typename Lhs,
typename Rhs>
class SparseTimeDenseProduct;
63template<
typename Lhs,
typename Rhs>
class DenseTimeSparseProduct;
64template<
typename Lhs,
typename Rhs,
bool Transpose>
class SparseDenseOuterProduct;
66template<
typename Lhs,
typename Rhs>
struct SparseSparseProductReturnType;
67template<
typename Lhs,
typename Rhs,
68 int InnerSize = internal::min_size_prefer_fixed(internal::traits<Lhs>::ColsAtCompileTime, internal::traits<Rhs>::RowsAtCompileTime)>
struct DenseSparseProductReturnType;
70template<
typename Lhs,
typename Rhs,
71 int InnerSize = internal::min_size_prefer_fixed(internal::traits<Lhs>::ColsAtCompileTime, internal::traits<Rhs>::RowsAtCompileTime)>
struct SparseDenseProductReturnType;
72template<
typename MatrixType,
int UpLo>
class SparseSymmetricPermutationProduct;
76template<
typename T,
int Rows,
int Cols,
int Flags>
struct sparse_eval;
78template<
typename T>
struct eval<T,Sparse>
79 : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime,traits<T>::Flags>
82template<
typename T,
int Cols,
int Flags>
struct sparse_eval<T,1,Cols,Flags> {
83 typedef typename traits<T>::Scalar Scalar_;
84 typedef typename traits<T>::StorageIndex StorageIndex_;
86 typedef SparseVector<Scalar_, RowMajor, StorageIndex_> type;
89template<
typename T,
int Rows,
int Flags>
struct sparse_eval<T,Rows,1,Flags> {
90 typedef typename traits<T>::Scalar Scalar_;
91 typedef typename traits<T>::StorageIndex StorageIndex_;
93 typedef SparseVector<Scalar_, ColMajor, StorageIndex_> type;
97template<
typename T,
int Rows,
int Cols,
int Flags>
struct sparse_eval {
98 typedef typename traits<T>::Scalar Scalar_;
99 typedef typename traits<T>::StorageIndex StorageIndex_;
102 typedef SparseMatrix<Scalar_, Options_, StorageIndex_> type;
105template<
typename T,
int Flags>
struct sparse_eval<T,1,1,Flags> {
106 typedef typename traits<T>::Scalar Scalar_;
108 typedef Matrix<Scalar_, 1, 1> type;
111template<
typename T>
struct plain_matrix_type<T,Sparse>
113 typedef typename traits<T>::Scalar Scalar_;
114 typedef typename traits<T>::StorageIndex StorageIndex_;
117 typedef SparseMatrix<Scalar_, Options_, StorageIndex_> type;
121struct plain_object_eval<T,Sparse>
122 : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime, evaluator<T>::Flags>
125template<
typename Decomposition,
typename RhsType>
126struct solve_traits<Decomposition,RhsType,Sparse>
128 typedef typename sparse_eval<RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime,traits<RhsType>::Flags>::type PlainObject;
131template<
typename Derived>
132struct generic_xpr_base<Derived, MatrixXpr, Sparse>
134 typedef SparseMatrixBase<Derived> type;
137struct SparseTriangularShape {
static std::string debugName() {
return "SparseTriangularShape"; } };
138struct SparseSelfAdjointShape {
static std::string debugName() {
return "SparseSelfAdjointShape"; } };
140template<>
struct glue_shapes<SparseShape,SelfAdjointShape> {
typedef SparseSelfAdjointShape type; };
141template<>
struct glue_shapes<SparseShape,TriangularShape > {
typedef SparseTriangularShape type; };
144struct LowerBoundIndex {
145 LowerBoundIndex() : value(-1), found(false) {}
146 LowerBoundIndex(
Index val,
bool ok) : value(val), found(ok) {}
161template<typename Scalar, typename StorageIndex=typename SparseMatrix<Scalar>::StorageIndex >
165 Triplet() : m_row(0), m_col(0), m_value(0) {}
167 Triplet(
const StorageIndex& i,
const StorageIndex& j,
const Scalar& v = Scalar(0))
168 : m_row(i), m_col(j), m_value(v)
172 const StorageIndex&
row()
const {
return m_row; }
175 const StorageIndex&
col()
const {
return m_col; }
178 const Scalar&
value()
const {
return m_value; }
180 StorageIndex m_row, m_col;
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:163
const StorageIndex & col() const
Definition: SparseUtil.h:175
const Scalar & value() const
Definition: SparseUtil.h:178
const StorageIndex & row() const
Definition: SparseUtil.h:172
@ ColMajor
Definition: Constants.h:321
@ RowMajor
Definition: Constants.h:323
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59