10#ifndef EIGEN_SPARSEUTIL_H
11#define EIGEN_SPARSEUTIL_H
16#define EIGEN_DBG_SPARSE(X)
18#define EIGEN_DBG_SPARSE(X) X
21#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
22template<typename OtherDerived> \
23EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) \
25 return Base::operator Op(other.derived()); \
27EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
29 return Base::operator Op(other); \
32#define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
33template<typename Other> \
34EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
36 return Base::operator Op(scalar); \
39#define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
40EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)
43#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
44 EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
47const int CoherentAccessPattern = 0x1;
48const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
49const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
50const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
52template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class SparseMatrix;
53template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class DynamicSparseMatrix;
54template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class SparseVector;
55template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class MappedSparseMatrix;
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 = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)>
struct DenseSparseProductReturnType;
70template<
typename Lhs,
typename Rhs,
71 int InnerSize = EIGEN_SIZE_MIN_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:319
@ RowMajor
Definition: Constants.h:321
const unsigned int RowMajorBit
Definition: Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition: Core:141
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74