Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef EIGEN_ARRAYWRAPPER_H
00026 #define EIGEN_ARRAYWRAPPER_H
00027
00028 namespace Eigen {
00029
00041 namespace internal {
00042 template<typename ExpressionType>
00043 struct traits<ArrayWrapper<ExpressionType> >
00044 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00045 {
00046 typedef ArrayXpr XprKind;
00047 };
00048 }
00049
00050 template<typename ExpressionType>
00051 class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
00052 {
00053 public:
00054 typedef ArrayBase<ArrayWrapper> Base;
00055 EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
00056 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
00057
00058 typedef typename internal::conditional<
00059 internal::is_lvalue<ExpressionType>::value,
00060 Scalar,
00061 const Scalar
00062 >::type ScalarWithConstIfNotLvalue;
00063
00064 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00065
00066 inline ArrayWrapper(ExpressionType& matrix) : m_expression(matrix) {}
00067
00068 inline Index rows() const { return m_expression.rows(); }
00069 inline Index cols() const { return m_expression.cols(); }
00070 inline Index outerStride() const { return m_expression.outerStride(); }
00071 inline Index innerStride() const { return m_expression.innerStride(); }
00072
00073 inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
00074 inline const Scalar* data() const { return m_expression.data(); }
00075
00076 inline CoeffReturnType coeff(Index row, Index col) const
00077 {
00078 return m_expression.coeff(row, col);
00079 }
00080
00081 inline Scalar& coeffRef(Index row, Index col)
00082 {
00083 return m_expression.const_cast_derived().coeffRef(row, col);
00084 }
00085
00086 inline const Scalar& coeffRef(Index row, Index col) const
00087 {
00088 return m_expression.const_cast_derived().coeffRef(row, col);
00089 }
00090
00091 inline CoeffReturnType coeff(Index index) const
00092 {
00093 return m_expression.coeff(index);
00094 }
00095
00096 inline Scalar& coeffRef(Index index)
00097 {
00098 return m_expression.const_cast_derived().coeffRef(index);
00099 }
00100
00101 inline const Scalar& coeffRef(Index index) const
00102 {
00103 return m_expression.const_cast_derived().coeffRef(index);
00104 }
00105
00106 template<int LoadMode>
00107 inline const PacketScalar packet(Index row, Index col) const
00108 {
00109 return m_expression.template packet<LoadMode>(row, col);
00110 }
00111
00112 template<int LoadMode>
00113 inline void writePacket(Index row, Index col, const PacketScalar& x)
00114 {
00115 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00116 }
00117
00118 template<int LoadMode>
00119 inline const PacketScalar packet(Index index) const
00120 {
00121 return m_expression.template packet<LoadMode>(index);
00122 }
00123
00124 template<int LoadMode>
00125 inline void writePacket(Index index, const PacketScalar& x)
00126 {
00127 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00128 }
00129
00130 template<typename Dest>
00131 inline void evalTo(Dest& dst) const { dst = m_expression; }
00132
00133 const typename internal::remove_all<NestedExpressionType>::type&
00134 nestedExpression() const
00135 {
00136 return m_expression;
00137 }
00138
00139 protected:
00140 NestedExpressionType m_expression;
00141 };
00142
00154 namespace internal {
00155 template<typename ExpressionType>
00156 struct traits<MatrixWrapper<ExpressionType> >
00157 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00158 {
00159 typedef MatrixXpr XprKind;
00160 };
00161 }
00162
00163 template<typename ExpressionType>
00164 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
00165 {
00166 public:
00167 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
00168 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
00169 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
00170
00171 typedef typename internal::conditional<
00172 internal::is_lvalue<ExpressionType>::value,
00173 Scalar,
00174 const Scalar
00175 >::type ScalarWithConstIfNotLvalue;
00176
00177 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00178
00179 inline MatrixWrapper(ExpressionType& matrix) : m_expression(matrix) {}
00180
00181 inline Index rows() const { return m_expression.rows(); }
00182 inline Index cols() const { return m_expression.cols(); }
00183 inline Index outerStride() const { return m_expression.outerStride(); }
00184 inline Index innerStride() const { return m_expression.innerStride(); }
00185
00186 inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
00187 inline const Scalar* data() const { return m_expression.data(); }
00188
00189 inline CoeffReturnType coeff(Index row, Index col) const
00190 {
00191 return m_expression.coeff(row, col);
00192 }
00193
00194 inline Scalar& coeffRef(Index row, Index col)
00195 {
00196 return m_expression.const_cast_derived().coeffRef(row, col);
00197 }
00198
00199 inline const Scalar& coeffRef(Index row, Index col) const
00200 {
00201 return m_expression.derived().coeffRef(row, col);
00202 }
00203
00204 inline CoeffReturnType coeff(Index index) const
00205 {
00206 return m_expression.coeff(index);
00207 }
00208
00209 inline Scalar& coeffRef(Index index)
00210 {
00211 return m_expression.const_cast_derived().coeffRef(index);
00212 }
00213
00214 inline const Scalar& coeffRef(Index index) const
00215 {
00216 return m_expression.const_cast_derived().coeffRef(index);
00217 }
00218
00219 template<int LoadMode>
00220 inline const PacketScalar packet(Index row, Index col) const
00221 {
00222 return m_expression.template packet<LoadMode>(row, col);
00223 }
00224
00225 template<int LoadMode>
00226 inline void writePacket(Index row, Index col, const PacketScalar& x)
00227 {
00228 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00229 }
00230
00231 template<int LoadMode>
00232 inline const PacketScalar packet(Index index) const
00233 {
00234 return m_expression.template packet<LoadMode>(index);
00235 }
00236
00237 template<int LoadMode>
00238 inline void writePacket(Index index, const PacketScalar& x)
00239 {
00240 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00241 }
00242
00243 const typename internal::remove_all<NestedExpressionType>::type&
00244 nestedExpression() const
00245 {
00246 return m_expression;
00247 }
00248
00249 protected:
00250 NestedExpressionType m_expression;
00251 };
00252
00253 }
00254
00255 #endif // EIGEN_ARRAYWRAPPER_H