ArrayWrapper.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) 2009-2010 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_ARRAYWRAPPER_H
11 #define EIGEN_ARRAYWRAPPER_H
12 
13 namespace Eigen {
14 
26 namespace internal {
27 template<typename ExpressionType>
29  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
30 {
31  typedef ArrayXpr XprKind;
32 };
33 }
34 
35 template<typename ExpressionType>
36 class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
37 {
38  public:
42 
43  typedef typename internal::conditional<
44  internal::is_lvalue<ExpressionType>::value,
45  Scalar,
46  const Scalar
48 
49  typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
50 
51  inline ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}
52 
53  inline Index rows() const { return m_expression.rows(); }
54  inline Index cols() const { return m_expression.cols(); }
55  inline Index outerStride() const { return m_expression.outerStride(); }
56  inline Index innerStride() const { return m_expression.innerStride(); }
57 
58  inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
59  inline const Scalar* data() const { return m_expression.data(); }
60 
61  inline CoeffReturnType coeff(Index rowId, Index colId) const
62  {
63  return m_expression.coeff(rowId, colId);
64  }
65 
66  inline Scalar& coeffRef(Index rowId, Index colId)
67  {
68  return m_expression.const_cast_derived().coeffRef(rowId, colId);
69  }
70 
71  inline const Scalar& coeffRef(Index rowId, Index colId) const
72  {
73  return m_expression.const_cast_derived().coeffRef(rowId, colId);
74  }
75 
76  inline CoeffReturnType coeff(Index index) const
77  {
78  return m_expression.coeff(index);
79  }
80 
81  inline Scalar& coeffRef(Index index)
82  {
83  return m_expression.const_cast_derived().coeffRef(index);
84  }
85 
86  inline const Scalar& coeffRef(Index index) const
87  {
88  return m_expression.const_cast_derived().coeffRef(index);
89  }
90 
91  template<int LoadMode>
92  inline const PacketScalar packet(Index rowId, Index colId) const
93  {
94  return m_expression.template packet<LoadMode>(rowId, colId);
95  }
96 
97  template<int LoadMode>
98  inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
99  {
100  m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
101  }
102 
103  template<int LoadMode>
104  inline const PacketScalar packet(Index index) const
105  {
106  return m_expression.template packet<LoadMode>(index);
107  }
108 
109  template<int LoadMode>
110  inline void writePacket(Index index, const PacketScalar& val)
111  {
112  m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
113  }
114 
115  template<typename Dest>
116  inline void evalTo(Dest& dst) const { dst = m_expression; }
117 
120  {
121  return m_expression;
122  }
123 
126  void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); }
129  void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); }
130 
131  protected:
133 };
134 
146 namespace internal {
147 template<typename ExpressionType>
149  : public traits<typename remove_all<typename ExpressionType::Nested>::type >
150 {
152 };
153 }
154 
155 template<typename ExpressionType>
156 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
157 {
158  public:
162 
163  typedef typename internal::conditional<
164  internal::is_lvalue<ExpressionType>::value,
165  Scalar,
166  const Scalar
168 
169  typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
170 
171  inline MatrixWrapper(ExpressionType& a_matrix) : m_expression(a_matrix) {}
172 
173  inline Index rows() const { return m_expression.rows(); }
174  inline Index cols() const { return m_expression.cols(); }
175  inline Index outerStride() const { return m_expression.outerStride(); }
176  inline Index innerStride() const { return m_expression.innerStride(); }
177 
178  inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
179  inline const Scalar* data() const { return m_expression.data(); }
180 
181  inline CoeffReturnType coeff(Index rowId, Index colId) const
182  {
183  return m_expression.coeff(rowId, colId);
184  }
185 
186  inline Scalar& coeffRef(Index rowId, Index colId)
187  {
188  return m_expression.const_cast_derived().coeffRef(rowId, colId);
189  }
190 
191  inline const Scalar& coeffRef(Index rowId, Index colId) const
192  {
193  return m_expression.derived().coeffRef(rowId, colId);
194  }
195 
196  inline CoeffReturnType coeff(Index index) const
197  {
198  return m_expression.coeff(index);
199  }
200 
201  inline Scalar& coeffRef(Index index)
202  {
203  return m_expression.const_cast_derived().coeffRef(index);
204  }
205 
206  inline const Scalar& coeffRef(Index index) const
207  {
208  return m_expression.const_cast_derived().coeffRef(index);
209  }
210 
211  template<int LoadMode>
212  inline const PacketScalar packet(Index rowId, Index colId) const
213  {
214  return m_expression.template packet<LoadMode>(rowId, colId);
215  }
216 
217  template<int LoadMode>
218  inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
219  {
220  m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
221  }
222 
223  template<int LoadMode>
224  inline const PacketScalar packet(Index index) const
225  {
226  return m_expression.template packet<LoadMode>(index);
227  }
228 
229  template<int LoadMode>
230  inline void writePacket(Index index, const PacketScalar& val)
231  {
232  m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
233  }
234 
237  {
238  return m_expression;
239  }
240 
243  void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); }
246  void resize(Index nbRows, Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); }
247 
248  protected:
250 };
251 
252 } // end namespace Eigen
253 
254 #endif // EIGEN_ARRAYWRAPPER_H
const Scalar * data() const
Definition: ArrayWrapper.h:59
NestedExpressionType m_expression
Definition: ArrayWrapper.h:249
void resize(Index newSize)
Definition: ArrayWrapper.h:243
Index rows() const
Definition: ArrayWrapper.h:53
Scalar & coeffRef(Index rowId, Index colId)
Definition: ArrayWrapper.h:186
internal::packet_traits< Scalar >::type PacketScalar
Definition: DenseBase.h:64
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:63
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:36
Base::CoeffReturnType CoeffReturnType
Definition: DenseBase.h:98
Scalar & coeffRef(Index rowId, Index colId)
Definition: ArrayWrapper.h:66
void resize(Index nbRows, Index nbCols)
Definition: ArrayWrapper.h:129
#define inline
Definition: Types.h:109
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:61
const PacketScalar packet(Index index) const
Definition: ArrayWrapper.h:224
const internal::remove_all< NestedExpressionType >::type & nestedExpression() const
Definition: ArrayWrapper.h:119
const Scalar & coeffRef(Index rowId, Index colId) const
Definition: ArrayWrapper.h:71
Index cols() const
Definition: ArrayWrapper.h:54
CoeffReturnType coeff(Index rowId, Index colId) const
Definition: ArrayWrapper.h:61
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: matrix.hpp:471
const PacketScalar packet(Index rowId, Index colId) const
Definition: ArrayWrapper.h:212
const Scalar & coeffRef(Index rowId, Index colId) const
Definition: ArrayWrapper.h:191
CoeffReturnType coeff(Index index) const
Definition: ArrayWrapper.h:76
Scalar & coeffRef(Index index)
Definition: ArrayWrapper.h:201
const Scalar & coeffRef(Index index) const
Definition: ArrayWrapper.h:86
MatrixBase< MatrixWrapper< ExpressionType > > Base
Definition: ArrayWrapper.h:159
void evalTo(Dest &dst) const
Definition: ArrayWrapper.h:116
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
Scalar & coeffRef(Index index)
Definition: ArrayWrapper.h:81
Expression of an array as a mathematical vector or matrix.
Definition: ArrayBase.h:15
NestedExpressionType m_expression
Definition: ArrayWrapper.h:132
const PacketScalar packet(Index rowId, Index colId) const
Definition: ArrayWrapper.h:92
void writePacket(Index rowId, Index colId, const PacketScalar &val)
Definition: ArrayWrapper.h:98
void writePacket(Index index, const PacketScalar &val)
Definition: ArrayWrapper.h:110
void resize(Index nbRows, Index nbCols)
Definition: ArrayWrapper.h:246
ArrayBase< ArrayWrapper > Base
Definition: ArrayWrapper.h:39
const Scalar * data() const
Definition: ArrayWrapper.h:179
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
CoeffReturnType coeff(Index rowId, Index colId) const
Definition: ArrayWrapper.h:181
Index rows() const
Definition: ArrayWrapper.h:173
void writePacket(Index index, const PacketScalar &val)
Definition: ArrayWrapper.h:230
Index innerStride() const
Definition: ArrayWrapper.h:176
const PacketScalar packet(Index index) const
Definition: ArrayWrapper.h:104
CoeffReturnType coeff(Index index) const
Definition: ArrayWrapper.h:196
#define EIGEN_DENSE_PUBLIC_INTERFACE(Derived)
void resize(Index newSize)
Definition: ArrayWrapper.h:126
Index outerStride() const
Definition: ArrayWrapper.h:175
Index innerStride() const
Definition: ArrayWrapper.h:56
ScalarWithConstIfNotLvalue * data()
Definition: ArrayWrapper.h:178
const internal::remove_all< NestedExpressionType >::type & nestedExpression() const
Definition: ArrayWrapper.h:236
ScalarWithConstIfNotLvalue * data()
Definition: ArrayWrapper.h:58
Index cols() const
Definition: ArrayWrapper.h:174
Index outerStride() const
Definition: ArrayWrapper.h:55
const Scalar & coeffRef(Index index) const
Definition: ArrayWrapper.h:206
void writePacket(Index rowId, Index colId, const PacketScalar &val)
Definition: ArrayWrapper.h:218
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48


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