Medial Code Documentation
Loading...
Searching...
No Matches
ArrayWrapper.h
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
13namespace Eigen {
14
26namespace internal {
27template<typename ExpressionType>
28struct traits<ArrayWrapper<ExpressionType> >
29 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
30{
31 typedef ArrayXpr XprKind;
32 // Let's remove NestByRefBit
33 enum {
35 Flags = Flags0 & ~NestByRefBit
36 };
37};
38}
39
40template<typename ExpressionType>
41class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
42{
43 public:
45 EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
46 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
47 typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
48
49 typedef typename internal::conditional<
51 Scalar,
52 const Scalar
54
56
58 explicit EIGEN_STRONG_INLINE ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}
59
61 inline Index rows() const { return m_expression.rows(); }
63 inline Index cols() const { return m_expression.cols(); }
65 inline Index outerStride() const { return m_expression.outerStride(); }
67 inline Index innerStride() const { return m_expression.innerStride(); }
68
70 inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
72 inline const Scalar* data() const { return m_expression.data(); }
73
75 inline CoeffReturnType coeff(Index rowId, Index colId) const
76 {
77 return m_expression.coeff(rowId, colId);
78 }
79
81 inline Scalar& coeffRef(Index rowId, Index colId)
82 {
83 return m_expression.const_cast_derived().coeffRef(rowId, colId);
84 }
85
87 inline const Scalar& coeffRef(Index rowId, Index colId) const
88 {
89 return m_expression.const_cast_derived().coeffRef(rowId, colId);
90 }
91
93 inline CoeffReturnType coeff(Index index) const
94 {
95 return m_expression.coeff(index);
96 }
97
99 inline Scalar& coeffRef(Index index)
100 {
101 return m_expression.const_cast_derived().coeffRef(index);
102 }
103
105 inline const Scalar& coeffRef(Index index) const
106 {
107 return m_expression.const_cast_derived().coeffRef(index);
108 }
109
110 template<int LoadMode>
111 inline const PacketScalar packet(Index rowId, Index colId) const
112 {
113 return m_expression.template packet<LoadMode>(rowId, colId);
114 }
115
116 template<int LoadMode>
117 inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
118 {
119 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
120 }
121
122 template<int LoadMode>
123 inline const PacketScalar packet(Index index) const
124 {
125 return m_expression.template packet<LoadMode>(index);
126 }
127
128 template<int LoadMode>
129 inline void writePacket(Index index, const PacketScalar& val)
130 {
131 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
132 }
133
134 template<typename Dest>
136 inline void evalTo(Dest& dst) const { dst = m_expression; }
137
138 const typename internal::remove_all<NestedExpressionType>::type&
140 nestedExpression() const
141 {
142 return m_expression;
143 }
144
148 void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); }
152 void resize(Index rows, Index cols) { m_expression.const_cast_derived().resize(rows,cols); }
153
154 protected:
155 NestedExpressionType m_expression;
156};
157
169namespace internal {
170template<typename ExpressionType>
171struct traits<MatrixWrapper<ExpressionType> >
172 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
173{
174 typedef MatrixXpr XprKind;
175 // Let's remove NestByRefBit
176 enum {
178 Flags = Flags0 & ~NestByRefBit
179 };
180};
181}
182
183template<typename ExpressionType>
184class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
185{
186 public:
188 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
189 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
190 typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
191
192 typedef typename internal::conditional<
194 Scalar,
195 const Scalar
197
199
201 explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
202
204 inline Index rows() const { return m_expression.rows(); }
206 inline Index cols() const { return m_expression.cols(); }
208 inline Index outerStride() const { return m_expression.outerStride(); }
210 inline Index innerStride() const { return m_expression.innerStride(); }
211
213 inline ScalarWithConstIfNotLvalue* data() { return m_expression.const_cast_derived().data(); }
215 inline const Scalar* data() const { return m_expression.data(); }
216
218 inline CoeffReturnType coeff(Index rowId, Index colId) const
219 {
220 return m_expression.coeff(rowId, colId);
221 }
222
224 inline Scalar& coeffRef(Index rowId, Index colId)
225 {
226 return m_expression.const_cast_derived().coeffRef(rowId, colId);
227 }
228
230 inline const Scalar& coeffRef(Index rowId, Index colId) const
231 {
232 return m_expression.derived().coeffRef(rowId, colId);
233 }
234
236 inline CoeffReturnType coeff(Index index) const
237 {
238 return m_expression.coeff(index);
239 }
240
242 inline Scalar& coeffRef(Index index)
243 {
244 return m_expression.const_cast_derived().coeffRef(index);
245 }
246
248 inline const Scalar& coeffRef(Index index) const
249 {
250 return m_expression.const_cast_derived().coeffRef(index);
251 }
252
253 template<int LoadMode>
254 inline const PacketScalar packet(Index rowId, Index colId) const
255 {
256 return m_expression.template packet<LoadMode>(rowId, colId);
257 }
258
259 template<int LoadMode>
260 inline void writePacket(Index rowId, Index colId, const PacketScalar& val)
261 {
262 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
263 }
264
265 template<int LoadMode>
266 inline const PacketScalar packet(Index index) const
267 {
268 return m_expression.template packet<LoadMode>(index);
269 }
270
271 template<int LoadMode>
272 inline void writePacket(Index index, const PacketScalar& val)
273 {
274 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
275 }
276
278 const typename internal::remove_all<NestedExpressionType>::type&
279 nestedExpression() const
280 {
281 return m_expression;
282 }
283
287 void resize(Index newSize) { m_expression.const_cast_derived().resize(newSize); }
291 void resize(Index rows, Index cols) { m_expression.const_cast_derived().resize(rows,cols); }
292
293 protected:
294 NestedExpressionType m_expression;
295};
296
297} // end namespace Eigen
298
299#endif // EIGEN_ARRAYWRAPPER_H
Base class for all 1D and 2D array, and related expressions.
Definition ArrayBase.h:41
EIGEN_DEVICE_FUNC MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition ArrayBase.h:148
Expression of a mathematical vector or matrix as an array object.
Definition ArrayWrapper.h:42
EIGEN_DEVICE_FUNC void resize(Index newSize)
Forwards the resizing request to the nested expression.
Definition ArrayWrapper.h:148
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols)
Forwards the resizing request to the nested expression.
Definition ArrayWrapper.h:152
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
Expression of an array as a mathematical vector or matrix.
Definition ArrayWrapper.h:185
EIGEN_DEVICE_FUNC void resize(Index newSize)
Forwards the resizing request to the nested expression.
Definition ArrayWrapper.h:287
EIGEN_DEVICE_FUNC void resize(Index rows, Index cols)
Forwards the resizing request to the nested expression.
Definition ArrayWrapper.h:291
Pseudo expression representing a solving operation.
Definition Solve.h:63
The type used to identify an array expression.
Definition Constants.h:508
The type used to identify a matrix expression.
Definition Constants.h:505
Definition Meta.h:34
Definition XprHelper.h:628
Definition ForwardDeclarations.h:17
Definition Meta.h:30