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 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 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
42 EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
43 EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
44 EIGEN_SPARSE_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
45 
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;
61 
62 #define EIGEN_SPARSE_PUBLIC_INTERFACE(Derived) \
63  _EIGEN_SPARSE_PUBLIC_INTERFACE(Derived, Eigen::SparseMatrixBase<Derived >)
64 
65 const int CoherentAccessPattern = 0x1;
68 const int RandomAccessPattern = 0x8 | OuterRandomAccessPattern | InnerRandomAccessPattern;
69 
70 template<typename Derived> class SparseMatrixBase;
71 template<typename _Scalar, int _Flags = 0, typename _Index = int> class SparseMatrix;
72 template<typename _Scalar, int _Flags = 0, typename _Index = int> class DynamicSparseMatrix;
73 template<typename _Scalar, int _Flags = 0, typename _Index = int> class SparseVector;
74 template<typename _Scalar, int _Flags = 0, typename _Index = int> class MappedSparseMatrix;
75 
76 template<typename MatrixType, int Mode> class SparseTriangularView;
77 template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView;
78 template<typename Lhs, typename Rhs> class SparseDiagonalProduct;
79 template<typename MatrixType> class SparseView;
80 
81 template<typename Lhs, typename Rhs> class SparseSparseProduct;
82 template<typename Lhs, typename Rhs> class SparseTimeDenseProduct;
83 template<typename Lhs, typename Rhs> class DenseTimeSparseProduct;
84 template<typename Lhs, typename Rhs, bool Transpose> class SparseDenseOuterProduct;
85 
86 template<typename Lhs, typename Rhs> struct SparseSparseProductReturnType;
87 template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime> struct DenseSparseProductReturnType;
88 template<typename Lhs, typename Rhs, int InnerSize = internal::traits<Lhs>::ColsAtCompileTime> struct SparseDenseProductReturnType;
89 template<typename MatrixType,int UpLo> class SparseSymmetricPermutationProduct;
90 
91 namespace internal {
92 
93 template<typename T,int Rows,int Cols> struct sparse_eval;
94 
95 template<typename T> struct eval<T,Sparse>
96  : public sparse_eval<T, traits<T>::RowsAtCompileTime,traits<T>::ColsAtCompileTime>
97 {};
98 
99 template<typename T,int Cols> struct sparse_eval<T,1,Cols> {
100  typedef typename traits<T>::Scalar _Scalar;
101  typedef typename traits<T>::Index _Index;
102  public:
104 };
105 
106 template<typename T,int Rows> struct sparse_eval<T,Rows,1> {
107  typedef typename traits<T>::Scalar _Scalar;
108  typedef typename traits<T>::Index _Index;
109  public:
111 };
112 
113 template<typename T,int Rows,int Cols> struct sparse_eval {
114  typedef typename traits<T>::Scalar _Scalar;
115  typedef typename traits<T>::Index _Index;
117  public:
119 };
120 
121 template<typename T> struct sparse_eval<T,1,1> {
122  typedef typename traits<T>::Scalar _Scalar;
123  public:
125 };
126 
127 template<typename T> struct plain_matrix_type<T,Sparse>
128 {
129  typedef typename traits<T>::Scalar _Scalar;
130  typedef typename traits<T>::Index _Index;
132  public:
134 };
135 
136 } // end namespace internal
137 
146 template<typename Scalar, typename Index=unsigned int>
147 class Triplet
148 {
149 public:
150  Triplet() : m_row(0), m_col(0), m_value(0) {}
151 
152  Triplet(const Index& i, const Index& j, const Scalar& v = Scalar(0))
153  : m_row(i), m_col(j), m_value(v)
154  {}
155 
157  const Index& row() const { return m_row; }
158 
160  const Index& col() const { return m_col; }
161 
163  const Scalar& value() const { return m_value; }
164 protected:
165  Index m_row, m_col;
166  Scalar m_value;
167 };
168 
169 } // end namespace Eigen
170 
171 #endif // EIGEN_SPARSEUTIL_H
const int OuterRandomAccessPattern
Definition: SparseUtil.h:67
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
A versatible sparse matrix representation.
Definition: SparseMatrix.h:85
const int InnerRandomAccessPattern
Definition: SparseUtil.h:66
Triplet(const Index &i, const Index &j, const Scalar &v=Scalar(0))
Definition: SparseUtil.h:152
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
SparseVector< _Scalar, ColMajor, _Index > type
Definition: SparseUtil.h:110
Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.
const unsigned int RowMajorBit
const Index & col() const
Definition: SparseUtil.h:160
SparseMatrix< _Scalar, _Options, _Index > type
Definition: SparseUtil.h:118
Base class of any sparse matrices or sparse expressions.
Scalar m_value
Definition: SparseUtil.h:166
a sparse vector class
Definition: SparseUtil.h:73
traits< T >::Index _Index
Definition: SparseUtil.h:115
A sparse matrix class designed for matrix assembly purpose.
Definition: SparseUtil.h:72
const int RandomAccessPattern
Definition: SparseUtil.h:68
#define v
A small structure to hold a non zero as a triplet (i,j,value).
Definition: SparseUtil.h:147
SparseMatrix< _Scalar, _Options, _Index > type
Definition: SparseUtil.h:133
const int CoherentAccessPattern
Definition: SparseUtil.h:65
traits< T >::Scalar _Scalar
Definition: SparseUtil.h:114
SparseVector< _Scalar, RowMajor, _Index > type
Definition: SparseUtil.h:103
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
const Index & row() const
Definition: SparseUtil.h:157
const Scalar & value() const
Definition: SparseUtil.h:163


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:35:10