SparseUtil.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008-2014 Gael Guennebaud <gael.guennebaud@inria.fr>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_SPARSEUTIL_H
11 #define EIGEN_SPARSEUTIL_H
12 
13 namespace Eigen {
14 
15 #ifdef NDEBUG
16 #define EIGEN_DBG_SPARSE(X)
17 #else
18 #define EIGEN_DBG_SPARSE(X) X
19 #endif
20 
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) \
24 { \
25  return Base::operator Op(other.derived()); \
26 } \
27 EIGEN_STRONG_INLINE Derived& operator Op(const Derived& other) \
28 { \
29  return Base::operator Op(other); \
30 }
31 
32 #define EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
33 template<typename Other> \
34 EIGEN_STRONG_INLINE Derived& operator Op(const Other& scalar) \
35 { \
36  return Base::operator Op(scalar); \
37 }
38 
39 #define EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
40 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, =)
41 
42 
43 #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
44  EIGEN_GENERIC_PUBLIC_INTERFACE(Derived)
45 
46 
47 const int CoherentAccessPattern = 0x1;
51 
52 template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class SparseMatrix;
53 template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class DynamicSparseMatrix;
54 template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class SparseVector;
55 template<typename _Scalar, int _Flags = 0, typename _StorageIndex = int> class MappedSparseMatrix;
56 
57 template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView;
58 template<typename Lhs, typename Rhs> class SparseDiagonalProduct;
59 template<typename MatrixType> class SparseView;
60 
61 template<typename Lhs, typename Rhs> class SparseSparseProduct;
62 template<typename Lhs, typename Rhs> class SparseTimeDenseProduct;
63 template<typename Lhs, typename Rhs> class DenseTimeSparseProduct;
64 template<typename Lhs, typename Rhs, bool Transpose> class SparseDenseOuterProduct;
65 
66 template<typename Lhs, typename Rhs> struct SparseSparseProductReturnType;
67 template<typename Lhs, typename Rhs,
69 
70 template<typename Lhs, typename Rhs,
72 template<typename MatrixType,int UpLo> class SparseSymmetricPermutationProduct;
73 
74 namespace internal {
75 
76 template<typename T,int Rows,int Cols,int Flags> struct sparse_eval;
77 
78 template<typename T> struct eval<T,Sparse>
79  : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime,traits<T>::Flags>
80 {};
81 
82 template<typename T,int Cols,int Flags> struct sparse_eval<T,1,Cols,Flags> {
83  typedef typename traits<T>::Scalar _Scalar;
85  public:
87 };
88 
89 template<typename T,int Rows,int Flags> struct sparse_eval<T,Rows,1,Flags> {
90  typedef typename traits<T>::Scalar _Scalar;
92  public:
94 };
95 
96 // TODO this seems almost identical to plain_matrix_type<T, Sparse>
97 template<typename T,int Rows,int Cols,int Flags> struct sparse_eval {
98  typedef typename traits<T>::Scalar _Scalar;
100  enum { _Options = ((Flags&RowMajorBit)==RowMajorBit) ? RowMajor : ColMajor };
101  public:
103 };
104 
105 template<typename T,int Flags> struct sparse_eval<T,1,1,Flags> {
106  typedef typename traits<T>::Scalar _Scalar;
107  public:
109 };
110 
111 template<typename T> struct plain_matrix_type<T,Sparse>
112 {
113  typedef typename traits<T>::Scalar _Scalar;
116  public:
118 };
119 
120 template<typename T>
122  : sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime, evaluator<T>::Flags>
123 {};
124 
125 template<typename Decomposition, typename RhsType>
126 struct solve_traits<Decomposition,RhsType,Sparse>
127 {
129 };
130 
131 template<typename Derived>
133 {
135 };
136 
137 struct SparseTriangularShape { static std::string debugName() { return "SparseTriangularShape"; } };
138 struct SparseSelfAdjointShape { static std::string debugName() { return "SparseSelfAdjointShape"; } };
139 
142 
143 // return type of SparseCompressedBase::lower_bound;
145  LowerBoundIndex() : value(-1), found(false) {}
146  LowerBoundIndex(Index val, bool ok) : value(val), found(ok) {}
148  bool found;
149 };
150 
151 } // end namespace internal
152 
161 template<typename Scalar, typename StorageIndex=typename SparseMatrix<Scalar>::StorageIndex >
162 class Triplet
163 {
164 public:
165  Triplet() : m_row(0), m_col(0), m_value(0) {}
166 
167  Triplet(const StorageIndex& i, const StorageIndex& j, const Scalar& v = Scalar(0))
168  : m_row(i), m_col(j), m_value(v)
169  {}
170 
172  const StorageIndex& row() const { return m_row; }
173 
175  const StorageIndex& col() const { return m_col; }
176 
178  const Scalar& value() const { return m_value; }
179 protected:
180  StorageIndex m_row, m_col;
182 };
183 
184 } // end namespace Eigen
185 
186 #endif // EIGEN_SPARSEUTIL_H
Eigen::internal::glue_shapes< SparseShape, TriangularShape >::type
SparseTriangularShape type
Definition: SparseUtil.h:141
Eigen::DynamicSparseMatrix
A sparse matrix class designed for matrix assembly purpose.
Definition: SparseUtil.h:53
Eigen::internal::Lhs
@ Lhs
Definition: TensorContractionMapper.h:19
Eigen::MatrixXpr
Definition: Constants.h:522
Eigen::internal::sparse_eval::_Scalar
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:98
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::Triplet::m_col
StorageIndex m_col
Definition: SparseUtil.h:180
Eigen::SparseMatrix
A versatible sparse matrix representation.
Definition: SparseMatrix.h:96
Eigen::internal::SparseSelfAdjointShape::debugName
static std::string debugName()
Definition: SparseUtil.h:138
Eigen::internal::solve_traits< Decomposition, RhsType, Sparse >::PlainObject
sparse_eval< RhsType, RhsType::RowsAtCompileTime, RhsType::ColsAtCompileTime, traits< RhsType >::Flags >::type PlainObject
Definition: SparseUtil.h:128
Eigen::internal::sparse_eval< T, Rows, 1, Flags >::type
SparseVector< _Scalar, ColMajor, _StorageIndex > type
Definition: SparseUtil.h:93
Eigen::internal::SparseSelfAdjointShape
Definition: SparseUtil.h:138
Eigen::internal::SparseTriangularShape
Definition: SparseUtil.h:137
Eigen::internal::sparse_eval< T, 1, Cols, Flags >::_Scalar
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:83
Eigen::Sparse
Definition: Constants.h:510
Eigen::internal::sparse_eval< T, 1, 1, Flags >::_Scalar
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:106
Eigen::internal::sparse_eval< T, 1, Cols, Flags >::type
SparseVector< _Scalar, RowMajor, _StorageIndex > type
Definition: SparseUtil.h:86
Eigen::internal::sparse_eval< T, Rows, 1, Flags >::_StorageIndex
traits< T >::StorageIndex _StorageIndex
Definition: SparseUtil.h:91
Eigen::internal::sparse_eval::_Options
@ _Options
Definition: SparseUtil.h:100
Eigen::internal::plain_matrix_type< T, Sparse >::type
SparseMatrix< _Scalar, _Options, _StorageIndex > type
Definition: SparseUtil.h:117
Eigen::internal::generic_xpr_base< Derived, MatrixXpr, Sparse >::type
SparseMatrixBase< Derived > type
Definition: SparseUtil.h:134
Eigen::RowMajorBit
const unsigned int RowMajorBit
Definition: Constants.h:66
Eigen::internal::LowerBoundIndex::LowerBoundIndex
LowerBoundIndex(Index val, bool ok)
Definition: SparseUtil.h:146
Eigen::SparseDenseOuterProduct
Definition: SparseUtil.h:64
Eigen::DenseSparseProductReturnType
Definition: SparseUtil.h:68
Eigen::internal::plain_object_eval
Definition: XprHelper.h:367
type
Definition: pytypes.h:1525
Eigen::internal::glue_shapes
Definition: XprHelper.h:685
Eigen::RowMajor
@ RowMajor
Definition: Constants.h:321
Eigen::internal::LowerBoundIndex::found
bool found
Definition: SparseUtil.h:148
Eigen::internal::sparse_eval< T, Rows, 1, Flags >::_Scalar
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:90
Eigen::internal::plain_matrix_type
Definition: XprHelper.h:295
Eigen::internal::sparse_eval
Definition: SparseUtil.h:76
Eigen::Triplet::Triplet
Triplet()
Definition: SparseUtil.h:165
Eigen::Triplet::value
const Scalar & value() const
Definition: SparseUtil.h:178
Eigen::SparseSparseProductReturnType
Definition: SparseUtil.h:66
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
Eigen::internal::glue_shapes< SparseShape, SelfAdjointShape >::type
SparseSelfAdjointShape type
Definition: SparseUtil.h:140
Eigen::Triplet::m_row
StorageIndex m_row
Definition: SparseUtil.h:180
Eigen::internal::LowerBoundIndex::value
Index value
Definition: SparseUtil.h:147
Eigen::SparseShape
Definition: Constants.h:537
Eigen::internal::generic_xpr_base
Definition: XprHelper.h:501
Eigen::CoherentAccessPattern
const int CoherentAccessPattern
Definition: SparseUtil.h:47
Eigen::internal::plain_matrix_type< T, Sparse >::_Scalar
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:113
Eigen::internal::solve_traits
Definition: Solve.h:32
Eigen::Triplet::col
const StorageIndex & col() const
Definition: SparseUtil.h:175
Eigen::SparseSparseProduct
Definition: SparseUtil.h:61
Eigen::SparseDenseProductReturnType
Definition: SparseUtil.h:71
Eigen::Triplet< double >
Eigen::Triplet::Triplet
Triplet(const StorageIndex &i, const StorageIndex &j, const Scalar &v=Scalar(0))
Definition: SparseUtil.h:167
Eigen::internal::evaluator
Definition: CoreEvaluators.h:90
Eigen::SparseSymmetricPermutationProduct
Definition: SparseSelfAdjointView.h:599
Eigen::internal::sparse_eval< T, 1, 1, Flags >::type
Matrix< _Scalar, 1, 1 > type
Definition: SparseUtil.h:108
Eigen::internal::sparse_eval::_StorageIndex
traits< T >::StorageIndex _StorageIndex
Definition: SparseUtil.h:99
Eigen::Triplet::m_value
Scalar m_value
Definition: SparseUtil.h:181
Eigen::internal::sparse_eval< T, 1, Cols, Flags >::_StorageIndex
traits< T >::StorageIndex _StorageIndex
Definition: SparseUtil.h:84
Eigen::internal::LowerBoundIndex::LowerBoundIndex
LowerBoundIndex()
Definition: SparseUtil.h:145
Eigen::internal::traits
Definition: ForwardDeclarations.h:17
Eigen::DenseTimeSparseProduct
Definition: SparseUtil.h:63
Eigen::internal::Rhs
@ Rhs
Definition: TensorContractionMapper.h:18
Eigen::SparseDiagonalProduct
Definition: SparseUtil.h:58
Eigen::SparseTimeDenseProduct
Definition: SparseUtil.h:62
Eigen::SparseVector
a sparse vector class
Definition: SparseUtil.h:54
Eigen::TriangularShape
Definition: Constants.h:533
Eigen::internal::plain_matrix_type< T, Sparse >::_StorageIndex
traits< T >::StorageIndex _StorageIndex
Definition: SparseUtil.h:114
Eigen::SelfAdjointShape
Definition: Constants.h:534
Eigen::SparseView
Expression of a dense or sparse matrix with zero or too small values removed.
Definition: ForwardDeclarations.h:124
Eigen::internal::LowerBoundIndex
Definition: SparseUtil.h:144
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
Eigen::SparseMatrixBase
Base class of any sparse matrices or sparse expressions.
Definition: ForwardDeclarations.h:301
Eigen::SparseSelfAdjointView
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
Definition: SparseSelfAdjointView.h:43
Eigen::Triplet::row
const StorageIndex & row() const
Definition: SparseUtil.h:172
Eigen::Matrix
The matrix class, also used for vectors and row-vectors.
Definition: 3rdparty/Eigen/Eigen/src/Core/Matrix.h:178
Eigen::OuterRandomAccessPattern
const int OuterRandomAccessPattern
Definition: SparseUtil.h:49
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::sparse_eval::type
SparseMatrix< _Scalar, _Options, _StorageIndex > type
Definition: SparseUtil.h:102
Eigen::ColMajor
@ ColMajor
Definition: Constants.h:319
Eigen::RandomAccessPattern
const int RandomAccessPattern
Definition: SparseUtil.h:50
Eigen::InnerRandomAccessPattern
const int InnerRandomAccessPattern
Definition: SparseUtil.h:48
Eigen::internal::eval
Definition: XprHelper.h:332
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
EIGEN_SIZE_MIN_PREFER_FIXED
#define EIGEN_SIZE_MIN_PREFER_FIXED(a, b)
Definition: Macros.h:1302
Eigen::MappedSparseMatrix
Sparse matrix.
Definition: MappedSparseMatrix.h:32
Eigen::internal::SparseTriangularShape::debugName
static std::string debugName()
Definition: SparseUtil.h:137
Scalar
SCALAR Scalar
Definition: bench_gemm.cpp:46
Eigen::Index
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Cols
static const int Cols
Definition: testCallRecord.cpp:32


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:03:46