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, =) \
41EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
42EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
43EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
44EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
46#define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, BaseClass) \
47 typedef BaseClass Base; \
48 typedef typename Eigen::internal::traits<Derived >::Scalar Scalar; \
49 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
50 typedef typename Eigen::internal::nested<Derived >::type Nested; \
51 typedef typename Eigen::internal::traits<Derived >::StorageKind StorageKind; \
52 typedef typename Eigen::internal::traits<Derived >::Index Index; \
53 enum { RowsAtCompileTime = Eigen::internal::traits<Derived >::RowsAtCompileTime, \
54 ColsAtCompileTime = Eigen::internal::traits<Derived >::ColsAtCompileTime, \
55 Flags = Eigen::internal::traits<Derived >::Flags, \
56 CoeffReadCost = Eigen::internal::traits<Derived >::CoeffReadCost, \
57 SizeAtCompileTime = Base::SizeAtCompileTime, \
58 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
59 using Base::derived; \
60 using Base::const_cast_derived;
62#define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
63 _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived >)
65const int CoherentAccessPattern = 0x1;
66const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
67const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
68const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
71template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class SparseMatrix;
73template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class SparseVector;
74template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class MappedSparseMatrix;
76template<
typename MatrixType,
int Size>
class SparseInnerVectorSet;
77template<
typename MatrixType,
int Mode>
class SparseTriangularView;
79template<
typename Lhs,
typename Rhs>
class SparseDiagonalProduct;
80template<
typename MatrixType>
class SparseView;
82template<
typename Lhs,
typename Rhs>
class SparseSparseProduct;
83template<
typename Lhs,
typename Rhs>
class SparseTimeDenseProduct;
84template<
typename Lhs,
typename Rhs>
class DenseTimeSparseProduct;
85template<
typename Lhs,
typename Rhs,
bool Transpose>
class SparseDenseOuterProduct;
87template<
typename Lhs,
typename Rhs>
struct SparseSparseProductReturnType;
88template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime>
struct DenseSparseProductReturnType;
89template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime>
struct SparseDenseProductReturnType;
90template<
typename MatrixType,
int UpLo>
class SparseSymmetricPermutationProduct;
94template<
typename T,
int Rows,
int Cols>
struct sparse_eval;
96template<
typename T>
struct eval<T,Sparse>
97 :
public sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime>
100template<
typename T,
int Cols>
struct sparse_eval<T,1,Cols> {
101 typedef typename traits<T>::Scalar _Scalar;
104 typedef SparseVector<_Scalar, _Flags> type;
107template<
typename T,
int Rows>
struct sparse_eval<T,Rows,1> {
108 typedef typename traits<T>::Scalar _Scalar;
109 enum { _Flags = traits<T>::Flags & (~RowMajorBit) };
111 typedef SparseVector<_Scalar, _Flags> type;
114template<
typename T,
int Rows,
int Cols>
struct sparse_eval {
115 typedef typename traits<T>::Scalar _Scalar;
116 typedef typename traits<T>::Index _Index;
119 typedef SparseMatrix<_Scalar, _Options, _Index> type;
122template<
typename T>
struct sparse_eval<T,1,1> {
123 typedef typename traits<T>::Scalar _Scalar;
125 typedef Matrix<_Scalar, 1, 1> type;
128template<
typename T>
struct plain_matrix_type<T,Sparse>
130 typedef typename traits<T>::Scalar _Scalar;
132 _Flags = traits<T>::Flags
136 typedef SparseMatrix<_Scalar, _Flags> type;
149template<
typename Scalar,
typename Index=
unsigned int>
153 Triplet() : m_row(0), m_col(0), m_value(0) {}
155 Triplet(
const Index& i,
const Index& j,
const Scalar& v = Scalar(0))
156 : m_row(i), m_col(j), m_value(v)
160 const Index&
row()
const {
return m_row; }
163 const Index&
col()
const {
return m_col; }
166 const Scalar&
value()
const {
return m_value; }
Sparse matrix.
Definition MappedSparseMatrix.h:33
Base class of any sparse matrices or sparse expressions.
Definition SparseMatrixBase.h:27
A versatible sparse matrix representation.
Definition SparseMatrix.h:87
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition SparseSelfAdjointView.h:51
a sparse vector class
Definition SparseVector.h:53
const Scalar & value() const
Definition SparseUtil.h:166
const Index & row() const
Definition SparseUtil.h:160
const Index & col() const
Definition SparseUtil.h:163
@ RowMajor
Definition Constants.h:259
@ ColMajor
Definition Constants.h:257
const unsigned int RowMajorBit
Definition Constants.h:48