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>
48 typedef typename internal::conditional<
49 internal::is_lvalue<ExpressionType>::value,
52 >::type ScalarWithConstIfNotLvalue;
54 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
58 inline Index rows()
const {
return m_expression.rows(); }
59 inline Index cols()
const {
return m_expression.cols(); }
60 inline Index outerStride()
const {
return m_expression.outerStride(); }
61 inline Index innerStride()
const {
return m_expression.innerStride(); }
63 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
64 inline const Scalar* data()
const {
return m_expression.data(); }
66 inline CoeffReturnType coeff(
Index rowId,
Index colId)
const
68 return m_expression.coeff(rowId, colId);
71 inline Scalar& coeffRef(
Index rowId,
Index colId)
73 return m_expression.const_cast_derived().coeffRef(rowId, colId);
76 inline const Scalar& coeffRef(
Index rowId,
Index colId)
const
78 return m_expression.const_cast_derived().coeffRef(rowId, colId);
81 inline CoeffReturnType coeff(
Index index)
const
83 return m_expression.coeff(index);
86 inline Scalar& coeffRef(
Index index)
88 return m_expression.const_cast_derived().coeffRef(index);
91 inline const Scalar& coeffRef(
Index index)
const
93 return m_expression.const_cast_derived().coeffRef(index);
96 template<
int LoadMode>
97 inline const PacketScalar packet(
Index rowId,
Index colId)
const
99 return m_expression.template packet<LoadMode>(rowId, colId);
102 template<
int LoadMode>
103 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
105 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
108 template<
int LoadMode>
109 inline const PacketScalar packet(
Index index)
const
111 return m_expression.template packet<LoadMode>(index);
114 template<
int LoadMode>
115 inline void writePacket(
Index index,
const PacketScalar& val)
117 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
120 template<
typename Dest>
121 inline void evalTo(Dest& dst)
const { dst = m_expression; }
123 const typename internal::remove_all<NestedExpressionType>::type&
124 nestedExpression()
const
131 void resize(
Index newSize) { m_expression.const_cast_derived().resize(newSize); }
134 void resize(
Index nbRows,
Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); }
137 NestedExpressionType m_expression;
152 template<
typename ExpressionType>
153 struct traits<MatrixWrapper<ExpressionType> >
154 :
public traits<typename remove_all<typename ExpressionType::Nested>::type >
156 typedef MatrixXpr XprKind;
159 Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
160 Flags = Flags0 & ~NestByRefBit
165 template<
typename ExpressionType>
166 class MatrixWrapper :
public MatrixBase<MatrixWrapper<ExpressionType> >
169 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
170 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
171 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
173 typedef typename internal::conditional<
174 internal::is_lvalue<ExpressionType>::
value,
177 >::type ScalarWithConstIfNotLvalue;
179 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
181 inline MatrixWrapper(ExpressionType& a_matrix) : m_expression(a_matrix) {}
183 inline Index rows()
const {
return m_expression.rows(); }
184 inline Index cols()
const {
return m_expression.cols(); }
185 inline Index outerStride()
const {
return m_expression.outerStride(); }
186 inline Index innerStride()
const {
return m_expression.innerStride(); }
188 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
189 inline const Scalar* data()
const {
return m_expression.data(); }
191 inline CoeffReturnType coeff(
Index rowId,
Index colId)
const
193 return m_expression.coeff(rowId, colId);
196 inline Scalar& coeffRef(
Index rowId,
Index colId)
198 return m_expression.const_cast_derived().coeffRef(rowId, colId);
201 inline const Scalar& coeffRef(
Index rowId,
Index colId)
const
203 return m_expression.derived().coeffRef(rowId, colId);
206 inline CoeffReturnType coeff(
Index index)
const
208 return m_expression.coeff(index);
211 inline Scalar& coeffRef(
Index index)
213 return m_expression.const_cast_derived().coeffRef(index);
216 inline const Scalar& coeffRef(
Index index)
const
218 return m_expression.const_cast_derived().coeffRef(index);
221 template<
int LoadMode>
222 inline const PacketScalar packet(
Index rowId,
Index colId)
const
224 return m_expression.template packet<LoadMode>(rowId, colId);
227 template<
int LoadMode>
228 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
230 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
233 template<
int LoadMode>
234 inline const PacketScalar packet(
Index index)
const
236 return m_expression.template packet<LoadMode>(index);
239 template<
int LoadMode>
240 inline void writePacket(
Index index,
const PacketScalar& val)
242 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
245 const typename internal::remove_all<NestedExpressionType>::type&
246 nestedExpression()
const
253 void resize(
Index newSize) { m_expression.const_cast_derived().resize(newSize); }
256 void resize(
Index nbRows,
Index nbCols) { m_expression.const_cast_derived().resize(nbRows,nbCols); }
259 NestedExpressionType m_expression;
264 #endif // EIGEN_ARRAYWRAPPER_H
Expression of a mathematical vector or matrix as an array object.
Definition: ArrayWrapper.h:41
void resize(Index newSize)
Definition: ArrayWrapper.h:131
void resize(Index nbRows, Index nbCols)
Definition: ArrayWrapper.h:256
Base class for all 1D and 2D array, and related expressions.
Definition: ArrayBase.h:39
void resize(Index newSize)
Definition: ArrayWrapper.h:253
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60
void resize(Index nbRows, Index nbCols)
Definition: ArrayWrapper.h:134
CoeffReturnType value() const
Definition: DenseBase.h:422
MatrixWrapper< ArrayWrapper< ExpressionType > > matrix()
Definition: ArrayBase.h:146