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;
35 template<
typename ExpressionType>
43 typedef typename internal::conditional<
44 internal::is_lvalue<ExpressionType>::value,
47 >::type ScalarWithConstIfNotLvalue;
49 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
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(); }
58 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
59 inline const Scalar* data()
const {
return m_expression.data(); }
61 inline CoeffReturnType coeff(
Index rowId,
Index colId)
const
63 return m_expression.coeff(rowId, colId);
66 inline Scalar& coeffRef(
Index rowId,
Index colId)
68 return m_expression.const_cast_derived().coeffRef(rowId, colId);
71 inline const Scalar& coeffRef(
Index rowId,
Index colId)
const
73 return m_expression.const_cast_derived().coeffRef(rowId, colId);
76 inline CoeffReturnType coeff(
Index index)
const
78 return m_expression.coeff(index);
81 inline Scalar& coeffRef(
Index index)
83 return m_expression.const_cast_derived().coeffRef(index);
86 inline const Scalar& coeffRef(
Index index)
const
88 return m_expression.const_cast_derived().coeffRef(index);
91 template<
int LoadMode>
92 inline const PacketScalar packet(
Index rowId,
Index colId)
const
94 return m_expression.template packet<LoadMode>(rowId, colId);
97 template<
int LoadMode>
98 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
100 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
103 template<
int LoadMode>
104 inline const PacketScalar packet(
Index index)
const
106 return m_expression.template packet<LoadMode>(index);
109 template<
int LoadMode>
110 inline void writePacket(
Index index,
const PacketScalar& val)
112 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
115 template<
typename Dest>
116 inline void evalTo(Dest& dst)
const { dst = m_expression; }
118 const typename internal::remove_all<NestedExpressionType>::type&
119 nestedExpression()
const
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); }
132 NestedExpressionType m_expression;
147 template<
typename ExpressionType>
148 struct traits<MatrixWrapper<ExpressionType> >
149 :
public traits<typename remove_all<typename ExpressionType::Nested>::type >
151 typedef MatrixXpr XprKind;
155 template<
typename ExpressionType>
156 class MatrixWrapper :
public MatrixBase<MatrixWrapper<ExpressionType> >
159 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
160 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
161 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
163 typedef typename internal::conditional<
164 internal::is_lvalue<ExpressionType>::
value,
167 >::type ScalarWithConstIfNotLvalue;
169 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
171 inline MatrixWrapper(ExpressionType& a_matrix) : m_expression(a_matrix) {}
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(); }
178 inline ScalarWithConstIfNotLvalue* data() {
return m_expression.const_cast_derived().data(); }
179 inline const Scalar* data()
const {
return m_expression.data(); }
181 inline CoeffReturnType coeff(
Index rowId,
Index colId)
const
183 return m_expression.coeff(rowId, colId);
186 inline Scalar& coeffRef(
Index rowId,
Index colId)
188 return m_expression.const_cast_derived().coeffRef(rowId, colId);
191 inline const Scalar& coeffRef(
Index rowId,
Index colId)
const
193 return m_expression.derived().coeffRef(rowId, colId);
196 inline CoeffReturnType coeff(
Index index)
const
198 return m_expression.coeff(index);
201 inline Scalar& coeffRef(
Index index)
203 return m_expression.const_cast_derived().coeffRef(index);
206 inline const Scalar& coeffRef(
Index index)
const
208 return m_expression.const_cast_derived().coeffRef(index);
211 template<
int LoadMode>
212 inline const PacketScalar packet(
Index rowId,
Index colId)
const
214 return m_expression.template packet<LoadMode>(rowId, colId);
217 template<
int LoadMode>
218 inline void writePacket(
Index rowId,
Index colId,
const PacketScalar& val)
220 m_expression.const_cast_derived().template writePacket<LoadMode>(rowId, colId, val);
223 template<
int LoadMode>
224 inline const PacketScalar packet(
Index index)
const
226 return m_expression.template packet<LoadMode>(index);
229 template<
int LoadMode>
230 inline void writePacket(
Index index,
const PacketScalar& val)
232 m_expression.const_cast_derived().template writePacket<LoadMode>(index, val);
235 const typename internal::remove_all<NestedExpressionType>::type&
236 nestedExpression()
const
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); }
249 NestedExpressionType m_expression;
254 #endif // EIGEN_ARRAYWRAPPER_H