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) \
22 template<typename OtherDerived> \
23 EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) \
25 return Base::operator Op(other.derived()); \
27 EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
29 return Base::operator Op(other); \
32 #define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
33 template<typename Other> \
34 EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
36 return Base::operator Op(scalar); \
39 #define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
40 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)
43 #define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
44 typedef typename Eigen::internal::traits<Derived >::Scalar Scalar; \
45 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
46 typedef typename Eigen::internal::ref_selector<Derived >::type Nested; \
47 typedef typename Eigen::internal::traits<Derived >::StorageKind StorageKind; \
48 typedef typename Eigen::internal::traits<Derived >::StorageIndex StorageIndex; \
49 enum { RowsAtCompileTime = Eigen::internal::traits<Derived >::RowsAtCompileTime, \
50 ColsAtCompileTime = Eigen::internal::traits<Derived >::ColsAtCompileTime, \
51 Flags = Eigen::internal::traits<Derived>::Flags, \
52 SizeAtCompileTime = Base::SizeAtCompileTime, \
53 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
54 using Base::derived; \
55 using Base::const_cast_derived; \
56 using Base::convert_index;
58 #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
59 typedef Eigen::SparseMatrixBase<Derived > Base; \
60 _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived)
62 const int CoherentAccessPattern = 0x1;
63 const int InnerRandomAccessPattern = 0x2 | CoherentAccessPattern;
64 const int OuterRandomAccessPattern = 0x4 | CoherentAccessPattern;
65 const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
67 template<
typename Derived>
class SparseMatrixBase;
68 template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class SparseMatrix;
69 template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class DynamicSparseMatrix;
70 template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class SparseVector;
71 template<
typename _Scalar,
int _Flags = 0,
typename _StorageIndex =
int>
class MappedSparseMatrix;
74 template<
typename Lhs,
typename Rhs>
class SparseDiagonalProduct;
75 template<
typename MatrixType>
class SparseView;
77 template<
typename Lhs,
typename Rhs>
class SparseSparseProduct;
78 template<
typename Lhs,
typename Rhs>
class SparseTimeDenseProduct;
79 template<
typename Lhs,
typename Rhs>
class DenseTimeSparseProduct;
80 template<
typename Lhs,
typename Rhs,
bool Transpose>
class SparseDenseOuterProduct;
82 template<
typename Lhs,
typename Rhs>
struct SparseSparseProductReturnType;
83 template<
typename Lhs,
typename Rhs,
84 int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)>
struct DenseSparseProductReturnType;
86 template<
typename Lhs,
typename Rhs,
87 int InnerSize = EIGEN_SIZE_MIN_PREFER_FIXED(internal::traits<Lhs>::ColsAtCompileTime,internal::traits<Rhs>::RowsAtCompileTime)>
struct SparseDenseProductReturnType;
88 template<
typename MatrixType,
int UpLo>
class SparseSymmetricPermutationProduct;
92 template<
typename T,
int Rows,
int Cols>
struct sparse_eval;
94 template<
typename T>
struct eval<T,
Sparse>
95 :
public sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime>
98 template<
typename T,
int Cols>
struct sparse_eval<T,1,Cols> {
99 typedef typename traits<T>::Scalar _Scalar;
100 typedef typename traits<T>::StorageIndex _StorageIndex;
105 template<
typename T,
int Rows>
struct sparse_eval<T,Rows,1> {
106 typedef typename traits<T>::Scalar _Scalar;
107 typedef typename traits<T>::StorageIndex _StorageIndex;
109 typedef SparseVector<_Scalar, ColMajor, _StorageIndex> type;
113 template<
typename T,
int Rows,
int Cols>
struct sparse_eval {
114 typedef typename traits<T>::Scalar _Scalar;
115 typedef typename traits<T>::StorageIndex _StorageIndex;
118 typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type;
121 template<
typename T>
struct sparse_eval<T,1,1> {
122 typedef typename traits<T>::Scalar _Scalar;
124 typedef Matrix<_Scalar, 1, 1> type;
127 template<
typename T>
struct plain_matrix_type<T,Sparse>
129 typedef typename traits<T>::Scalar _Scalar;
130 typedef typename traits<T>::StorageIndex _StorageIndex;
133 typedef SparseMatrix<_Scalar, _Options, _StorageIndex> type;
136 template<
typename Decomposition,
typename RhsType>
137 struct solve_traits<Decomposition,RhsType,Sparse>
139 typedef typename sparse_eval<RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime>::type PlainObject;
142 template<
typename Derived>
143 struct generic_xpr_base<Derived, MatrixXpr, Sparse>
145 typedef SparseMatrixBase<Derived> type;
148 struct SparseTriangularShape {
static std::string debugName() {
return "SparseTriangularShape"; } };
149 struct SparseSelfAdjointShape {
static std::string debugName() {
return "SparseSelfAdjointShape"; } };
151 template<>
struct glue_shapes<SparseShape,SelfAdjointShape> {
typedef SparseSelfAdjointShape type; };
152 template<>
struct glue_shapes<SparseShape,TriangularShape > {
typedef SparseTriangularShape type; };
164 template<typename Scalar, typename StorageIndex=typename SparseMatrix<Scalar>::StorageIndex >
168 Triplet() : m_row(0), m_col(0), m_value(0) {}
170 Triplet(
const StorageIndex& i,
const StorageIndex& j,
const Scalar& v = Scalar(0))
171 : m_row(i), m_col(j), m_value(v)
175 const StorageIndex&
row()
const {
return m_row; }
178 const StorageIndex&
col()
const {
return m_col; }
181 const Scalar&
value()
const {
return m_value; }
183 StorageIndex m_row, m_col;
189 #endif // EIGEN_SPARSEUTIL_H
Definition: Constants.h:314
const StorageIndex & row() const
Definition: SparseUtil.h:175
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:43
const unsigned int RowMajorBit
Definition: Constants.h:53
const StorageIndex & col() const
Definition: SparseUtil.h:178
a sparse vector class
Definition: SparseUtil.h:70
Definition: Constants.h:485
const Scalar & value() const
Definition: SparseUtil.h:181
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:165
Definition: Eigen_Colamd.h:54
Definition: Constants.h:312
Sparse matrix.
Definition: MappedSparseMatrix.h:32