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
00039 namespace internal {
00040 template<typename ExpressionType>
00041 struct traits<ArrayWrapper<ExpressionType> >
00042 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00043 {
00044 typedef ArrayXpr XprKind;
00045 };
00046 }
00047
00048 template<typename ExpressionType>
00049 class ArrayWrapper : public ArrayBase<ArrayWrapper<ExpressionType> >
00050 {
00051 public:
00052 typedef ArrayBase<ArrayWrapper> Base;
00053 EIGEN_DENSE_PUBLIC_INTERFACE(ArrayWrapper)
00054 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ArrayWrapper)
00055
00056 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00057
00058 inline ArrayWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
00059
00060 inline Index rows() const { return m_expression.rows(); }
00061 inline Index cols() const { return m_expression.cols(); }
00062 inline Index outerStride() const { return m_expression.outerStride(); }
00063 inline Index innerStride() const { return m_expression.innerStride(); }
00064
00065 inline const CoeffReturnType coeff(Index row, Index col) const
00066 {
00067 return m_expression.coeff(row, col);
00068 }
00069
00070 inline Scalar& coeffRef(Index row, Index col)
00071 {
00072 return m_expression.const_cast_derived().coeffRef(row, col);
00073 }
00074
00075 inline const Scalar& coeffRef(Index row, Index col) const
00076 {
00077 return m_expression.const_cast_derived().coeffRef(row, col);
00078 }
00079
00080 inline const CoeffReturnType coeff(Index index) const
00081 {
00082 return m_expression.coeff(index);
00083 }
00084
00085 inline Scalar& coeffRef(Index index)
00086 {
00087 return m_expression.const_cast_derived().coeffRef(index);
00088 }
00089
00090 inline const Scalar& coeffRef(Index index) const
00091 {
00092 return m_expression.const_cast_derived().coeffRef(index);
00093 }
00094
00095 template<int LoadMode>
00096 inline const PacketScalar packet(Index row, Index col) const
00097 {
00098 return m_expression.template packet<LoadMode>(row, col);
00099 }
00100
00101 template<int LoadMode>
00102 inline void writePacket(Index row, Index col, const PacketScalar& x)
00103 {
00104 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00105 }
00106
00107 template<int LoadMode>
00108 inline const PacketScalar packet(Index index) const
00109 {
00110 return m_expression.template packet<LoadMode>(index);
00111 }
00112
00113 template<int LoadMode>
00114 inline void writePacket(Index index, const PacketScalar& x)
00115 {
00116 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00117 }
00118
00119 template<typename Dest>
00120 inline void evalTo(Dest& dst) const { dst = m_expression; }
00121
00122 protected:
00123 const NestedExpressionType m_expression;
00124 };
00125
00137 namespace internal {
00138 template<typename ExpressionType>
00139 struct traits<MatrixWrapper<ExpressionType> >
00140 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00141 {
00142 typedef MatrixXpr XprKind;
00143 };
00144 }
00145
00146 template<typename ExpressionType>
00147 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
00148 {
00149 public:
00150 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
00151 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
00152 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
00153
00154 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00155
00156 inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
00157
00158 inline Index rows() const { return m_expression.rows(); }
00159 inline Index cols() const { return m_expression.cols(); }
00160 inline Index outerStride() const { return m_expression.outerStride(); }
00161 inline Index innerStride() const { return m_expression.innerStride(); }
00162
00163 inline const CoeffReturnType coeff(Index row, Index col) const
00164 {
00165 return m_expression.coeff(row, col);
00166 }
00167
00168 inline Scalar& coeffRef(Index row, Index col)
00169 {
00170 return m_expression.const_cast_derived().coeffRef(row, col);
00171 }
00172
00173 inline const Scalar& coeffRef(Index row, Index col) const
00174 {
00175 return m_expression.derived().coeffRef(row, col);
00176 }
00177
00178 inline const CoeffReturnType coeff(Index index) const
00179 {
00180 return m_expression.coeff(index);
00181 }
00182
00183 inline Scalar& coeffRef(Index index)
00184 {
00185 return m_expression.const_cast_derived().coeffRef(index);
00186 }
00187
00188 inline const Scalar& coeffRef(Index index) const
00189 {
00190 return m_expression.const_cast_derived().coeffRef(index);
00191 }
00192
00193 template<int LoadMode>
00194 inline const PacketScalar packet(Index row, Index col) const
00195 {
00196 return m_expression.template packet<LoadMode>(row, col);
00197 }
00198
00199 template<int LoadMode>
00200 inline void writePacket(Index row, Index col, const PacketScalar& x)
00201 {
00202 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00203 }
00204
00205 template<int LoadMode>
00206 inline const PacketScalar packet(Index index) const
00207 {
00208 return m_expression.template packet<LoadMode>(index);
00209 }
00210
00211 template<int LoadMode>
00212 inline void writePacket(Index index, const PacketScalar& x)
00213 {
00214 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00215 }
00216
00217 protected:
00218 const NestedExpressionType m_expression;
00219 };
00220
00221 #endif // EIGEN_ARRAYWRAPPER_H