25 #ifndef EIGEN_SPARSEUTIL_H
26 #define EIGEN_SPARSEUTIL_H
31 #define EIGEN_DBG_SPARSE(X)
33 #define EIGEN_DBG_SPARSE(X) X
36 #define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
37 template<typename OtherDerived> \
38 EIGEN_STRONG_INLINE Derived& operator Op(const Eigen::SparseMatrixBase<OtherDerived>& other) \
40 return Base::operator Op(other.derived()); \
42 EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
44 return Base::operator Op(other); \
47 #define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
48 template<typename Other> \
49 EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
51 return Base::operator Op(scalar); \
54 #define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
55 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
56 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
57 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
58 EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
59 EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
61 #define _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, BaseClass) \
62 typedef BaseClass Base; \
63 typedef typename Eigen::internal::traits<Derived >::Scalar Scalar; \
64 typedef typename Eigen::NumTraits<Scalar>::Real RealScalar; \
65 typedef typename Eigen::internal::nested<Derived >::type Nested; \
66 typedef typename Eigen::internal::traits<Derived >::StorageKind StorageKind; \
67 typedef typename Eigen::internal::traits<Derived >::Index Index; \
68 enum { RowsAtCompileTime = Eigen::internal::traits<Derived >::RowsAtCompileTime, \
69 ColsAtCompileTime = Eigen::internal::traits<Derived >::ColsAtCompileTime, \
70 Flags = Eigen::internal::traits<Derived >::Flags, \
71 CoeffReadCost = Eigen::internal::traits<Derived >::CoeffReadCost, \
72 SizeAtCompileTime = Base::SizeAtCompileTime, \
73 IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; \
74 using Base::derived; \
75 using Base::const_cast_derived;
77 #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
78 _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived >)
86 template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class SparseMatrix;
87 template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class DynamicSparseMatrix;
88 template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class SparseVector;
89 template<
typename _Scalar,
int _Flags = 0,
typename _Index =
int>
class MappedSparseMatrix;
95 template<
typename MatrixType>
class SparseView;
109 template<
typename T,
int Rows,
int Cols>
struct sparse_eval;
111 template<
typename T>
struct eval<T,
Sparse>
112 :
public sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime>
115 template<
typename T,
int Cols>
struct sparse_eval<T,1,Cols> {
119 typedef SparseVector<_Scalar, _Flags> type;
122 template<
typename T,
int Rows>
struct sparse_eval<T,Rows,1> {
126 typedef SparseVector<_Scalar, _Flags> type;
129 template<
typename T,
int Rows,
int Cols>
struct sparse_eval {
133 typedef SparseMatrix<_Scalar, _Flags> type;
136 template<
typename T>
struct sparse_eval<T,1,1> {
139 typedef Matrix<_Scalar, 1, 1> type;
142 template<
typename T>
struct plain_matrix_type<T,Sparse>
150 typedef SparseMatrix<_Scalar, _Flags> type;
163 template<
typename Scalar,
typename Index=
unsigned int>
169 Triplet(
const Index& i,
const Index& j,
const Scalar& v = Scalar(0))
170 : m_row(i), m_col(j), m_value(v)
174 const Index&
row()
const {
return m_row; }
177 const Index&
col()
const {
return m_col; }
180 const Scalar&
value()
const {
return m_value; }
188 #endif // EIGEN_SPARSEUTIL_H