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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
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 CoeffReturnType coeff(Index index) const
00076 {
00077 return m_expression.coeff(index);
00078 }
00079
00080 inline Scalar& coeffRef(Index index)
00081 {
00082 return m_expression.const_cast_derived().coeffRef(index);
00083 }
00084
00085 template<int LoadMode>
00086 inline const PacketScalar packet(Index row, Index col) const
00087 {
00088 return m_expression.template packet<LoadMode>(row, col);
00089 }
00090
00091 template<int LoadMode>
00092 inline void writePacket(Index row, Index col, const PacketScalar& x)
00093 {
00094 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00095 }
00096
00097 template<int LoadMode>
00098 inline const PacketScalar packet(Index index) const
00099 {
00100 return m_expression.template packet<LoadMode>(index);
00101 }
00102
00103 template<int LoadMode>
00104 inline void writePacket(Index index, const PacketScalar& x)
00105 {
00106 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00107 }
00108
00109 template<typename Dest>
00110 inline void evalTo(Dest& dst) const { dst = m_expression; }
00111
00112 protected:
00113 const NestedExpressionType m_expression;
00114 };
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 namespace internal {
00128 template<typename ExpressionType>
00129 struct traits<MatrixWrapper<ExpressionType> >
00130 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00131 {
00132 typedef MatrixXpr XprKind;
00133 };
00134 }
00135
00136 template<typename ExpressionType>
00137 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
00138 {
00139 public:
00140 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
00141 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
00142 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
00143
00144 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00145
00146 inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
00147
00148 inline Index rows() const { return m_expression.rows(); }
00149 inline Index cols() const { return m_expression.cols(); }
00150 inline Index outerStride() const { return m_expression.outerStride(); }
00151 inline Index innerStride() const { return m_expression.innerStride(); }
00152
00153 inline const CoeffReturnType coeff(Index row, Index col) const
00154 {
00155 return m_expression.coeff(row, col);
00156 }
00157
00158 inline Scalar& coeffRef(Index row, Index col)
00159 {
00160 return m_expression.const_cast_derived().coeffRef(row, col);
00161 }
00162
00163 inline const Scalar& coeffRef(Index row, Index col) const
00164 {
00165 return m_expression.derived().coeffRef(row, col);
00166 }
00167
00168 inline const CoeffReturnType coeff(Index index) const
00169 {
00170 return m_expression.coeff(index);
00171 }
00172
00173 inline Scalar& coeffRef(Index index)
00174 {
00175 return m_expression.const_cast_derived().coeffRef(index);
00176 }
00177
00178 template<int LoadMode>
00179 inline const PacketScalar packet(Index row, Index col) const
00180 {
00181 return m_expression.template packet<LoadMode>(row, col);
00182 }
00183
00184 template<int LoadMode>
00185 inline void writePacket(Index row, Index col, const PacketScalar& x)
00186 {
00187 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00188 }
00189
00190 template<int LoadMode>
00191 inline const PacketScalar packet(Index index) const
00192 {
00193 return m_expression.template packet<LoadMode>(index);
00194 }
00195
00196 template<int LoadMode>
00197 inline void writePacket(Index index, const PacketScalar& x)
00198 {
00199 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00200 }
00201
00202 protected:
00203 const NestedExpressionType m_expression;
00204 };
00205
00206 #endif // EIGEN_ARRAYWRAPPER_H