10 #ifndef EIGEN_ARRAYWRAPPER_H
11 #define EIGEN_ARRAYWRAPPER_H
27 template<
typename ExpressionType>
28 struct traits<ArrayWrapper<ExpressionType> >
29 :
public traits<typename remove_all<typename ExpressionType::Nested>::type >
31 typedef ArrayXpr XprKind;
34 Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
35 Flags = Flags0 & ~NestByRefBit
40 template<
typename ExpressionType>
47 typedef typename internal::remove_all<ExpressionType>::type NestedExpression;
49 typedef typename internal::conditional<
50 internal::is_lvalue<ExpressionType>::value,
53 >::type ScalarWithConstIfNotLvalue;
55 typedef typename internal::ref_selector<ExpressionType>::type NestedExpressionType;
58 explicit EIGEN_STRONG_INLINE
ArrayWrapper(ExpressionType&
matrix) : m_expression(matrix) {}
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(); }
70 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
72 inline const Scalar* data()
const {
return m_expression.data(); }
75 inline CoeffReturnType coeff(Index rowId, Index colId)
const
77 return m_expression.coeff(rowId, colId);
81 inline Scalar& coeffRef(Index rowId, Index colId)
83 return m_expression.const_cast_derived().coeffRef(rowId, colId);
87 inline const Scalar& coeffRef(Index rowId, Index colId)
const
89 return m_expression.const_cast_derived().coeffRef(rowId, colId);
93 inline CoeffReturnType coeff(Index index)
const
95 return m_expression.coeff(index);
99 inline Scalar& coeffRef(Index index)
101 return m_expression.const_cast_derived().coeffRef(index);
105 inline const Scalar& coeffRef(Index index)
const
107 return m_expression.const_cast_derived().coeffRef(index);
110 template<
int LoadMode>
111 inline const PacketScalar packet(Index rowId, Index colId)
const
113 return m_expression.template packet<LoadMode>(rowId, colId);
116 template<
int LoadMode>
117 inline void writePacket(Index rowId, Index colId,
const PacketScalar& val)
119 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
122 template<
int LoadMode>
123 inline const PacketScalar packet(Index index)
const
125 return m_expression.template packet<LoadMode>(index);
128 template<
int LoadMode>
129 inline void writePacket(Index index,
const PacketScalar& val)
131 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
134 template<
typename Dest>
136 inline void evalTo(Dest& dst)
const { dst = m_expression; }
138 const typename internal::remove_all<NestedExpressionType>::type&
140 nestedExpression()
const
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); }
155 NestedExpressionType m_expression;
170 template<
typename ExpressionType>
171 struct traits<MatrixWrapper<ExpressionType> >
172 :
public traits<typename remove_all<typename ExpressionType::Nested>::type >
174 typedef MatrixXpr XprKind;
177 Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
178 Flags = Flags0 & ~NestByRefBit
183 template<
typename ExpressionType>
184 class MatrixWrapper :
public MatrixBase<MatrixWrapper<ExpressionType> >
187 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
188 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
189 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
190 typedef typename
internal::remove_all<ExpressionType>::type NestedExpression;
192 typedef typename
internal::conditional<
196 >::type ScalarWithConstIfNotLvalue;
198 typedef typename
internal::ref_selector<ExpressionType>::type NestedExpressionType;
201 explicit inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
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(); }
213 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
215 inline const Scalar* data()
const {
return m_expression.data(); }
218 inline CoeffReturnType coeff(Index rowId, Index colId)
const
220 return m_expression.coeff(rowId, colId);
224 inline Scalar& coeffRef(Index rowId, Index colId)
226 return m_expression.const_cast_derived().coeffRef(rowId, colId);
230 inline const Scalar& coeffRef(Index rowId, Index colId)
const
232 return m_expression.derived().coeffRef(rowId, colId);
236 inline CoeffReturnType coeff(Index index)
const
238 return m_expression.coeff(index);
242 inline Scalar& coeffRef(Index index)
244 return m_expression.const_cast_derived().coeffRef(index);
248 inline const Scalar& coeffRef(Index index)
const
250 return m_expression.const_cast_derived().coeffRef(index);
253 template<
int LoadMode>
254 inline const PacketScalar packet(Index rowId, Index colId)
const
256 return m_expression.template packet<LoadMode>(rowId, colId);
259 template<
int LoadMode>
260 inline void writePacket(Index rowId, Index colId,
const PacketScalar& val)
262 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
265 template<
int LoadMode>
266 inline const PacketScalar packet(Index index)
const
268 return m_expression.template packet<LoadMode>(index);
271 template<
int LoadMode>
272 inline void writePacket(Index index,
const PacketScalar& val)
274 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
278 const typename internal::remove_all<NestedExpressionType>::type&
279 nestedExpression()
const
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); }
294 NestedExpressionType m_expression;
299 #endif // EIGEN_ARRAYWRAPPER_H
void resize(Index newSize)
Definition: ArrayWrapper.h:287
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:72
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:41
void resize(Index rows, Index cols)
Definition: ArrayWrapper.h:291
CoeffReturnType value() const
Definition: DenseBase.h:481
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
void resize(Index rows, Index cols)
Definition: ArrayWrapper.h:152
Definition: Eigen_Colamd.h:54
void resize(Index newSize)
Definition: ArrayWrapper.h:148
MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition: ArrayBase.h:149