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::conditional<
00057 internal::is_lvalue<ExpressionType>::value,
00058 Scalar,
00059 const Scalar
00060 >::type ScalarWithConstIfNotLvalue;
00061
00062 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00063
00064 inline ArrayWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
00065
00066 inline Index rows() const { return m_expression.rows(); }
00067 inline Index cols() const { return m_expression.cols(); }
00068 inline Index outerStride() const { return m_expression.outerStride(); }
00069 inline Index innerStride() const { return m_expression.innerStride(); }
00070
00071 inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
00072 inline const Scalar* data() const { return m_expression.data(); }
00073
00074 inline const CoeffReturnType coeff(Index row, Index col) const
00075 {
00076 return m_expression.coeff(row, col);
00077 }
00078
00079 inline Scalar& coeffRef(Index row, Index col)
00080 {
00081 return m_expression.const_cast_derived().coeffRef(row, col);
00082 }
00083
00084 inline const Scalar& coeffRef(Index row, Index col) const
00085 {
00086 return m_expression.const_cast_derived().coeffRef(row, col);
00087 }
00088
00089 inline const CoeffReturnType coeff(Index index) const
00090 {
00091 return m_expression.coeff(index);
00092 }
00093
00094 inline Scalar& coeffRef(Index index)
00095 {
00096 return m_expression.const_cast_derived().coeffRef(index);
00097 }
00098
00099 inline const Scalar& coeffRef(Index index) const
00100 {
00101 return m_expression.const_cast_derived().coeffRef(index);
00102 }
00103
00104 template<int LoadMode>
00105 inline const PacketScalar packet(Index row, Index col) const
00106 {
00107 return m_expression.template packet<LoadMode>(row, col);
00108 }
00109
00110 template<int LoadMode>
00111 inline void writePacket(Index row, Index col, const PacketScalar& x)
00112 {
00113 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00114 }
00115
00116 template<int LoadMode>
00117 inline const PacketScalar packet(Index index) const
00118 {
00119 return m_expression.template packet<LoadMode>(index);
00120 }
00121
00122 template<int LoadMode>
00123 inline void writePacket(Index index, const PacketScalar& x)
00124 {
00125 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00126 }
00127
00128 template<typename Dest>
00129 inline void evalTo(Dest& dst) const { dst = m_expression; }
00130
00131 protected:
00132 const NestedExpressionType m_expression;
00133 };
00134
00146 namespace internal {
00147 template<typename ExpressionType>
00148 struct traits<MatrixWrapper<ExpressionType> >
00149 : public traits<typename remove_all<typename ExpressionType::Nested>::type >
00150 {
00151 typedef MatrixXpr XprKind;
00152 };
00153 }
00154
00155 template<typename ExpressionType>
00156 class MatrixWrapper : public MatrixBase<MatrixWrapper<ExpressionType> >
00157 {
00158 public:
00159 typedef MatrixBase<MatrixWrapper<ExpressionType> > Base;
00160 EIGEN_DENSE_PUBLIC_INTERFACE(MatrixWrapper)
00161 EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixWrapper)
00162
00163 typedef typename internal::conditional<
00164 internal::is_lvalue<ExpressionType>::value,
00165 Scalar,
00166 const Scalar
00167 >::type ScalarWithConstIfNotLvalue;
00168
00169 typedef typename internal::nested<ExpressionType>::type NestedExpressionType;
00170
00171 inline MatrixWrapper(const ExpressionType& matrix) : m_expression(matrix) {}
00172
00173 inline Index rows() const { return m_expression.rows(); }
00174 inline Index cols() const { return m_expression.cols(); }
00175 inline Index outerStride() const { return m_expression.outerStride(); }
00176 inline Index innerStride() const { return m_expression.innerStride(); }
00177
00178 inline ScalarWithConstIfNotLvalue* data() { return m_expression.data(); }
00179 inline const Scalar* data() const { return m_expression.data(); }
00180
00181 inline const CoeffReturnType coeff(Index row, Index col) const
00182 {
00183 return m_expression.coeff(row, col);
00184 }
00185
00186 inline Scalar& coeffRef(Index row, Index col)
00187 {
00188 return m_expression.const_cast_derived().coeffRef(row, col);
00189 }
00190
00191 inline const Scalar& coeffRef(Index row, Index col) const
00192 {
00193 return m_expression.derived().coeffRef(row, col);
00194 }
00195
00196 inline const CoeffReturnType coeff(Index index) const
00197 {
00198 return m_expression.coeff(index);
00199 }
00200
00201 inline Scalar& coeffRef(Index index)
00202 {
00203 return m_expression.const_cast_derived().coeffRef(index);
00204 }
00205
00206 inline const Scalar& coeffRef(Index index) const
00207 {
00208 return m_expression.const_cast_derived().coeffRef(index);
00209 }
00210
00211 template<int LoadMode>
00212 inline const PacketScalar packet(Index row, Index col) const
00213 {
00214 return m_expression.template packet<LoadMode>(row, col);
00215 }
00216
00217 template<int LoadMode>
00218 inline void writePacket(Index row, Index col, const PacketScalar& x)
00219 {
00220 m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
00221 }
00222
00223 template<int LoadMode>
00224 inline const PacketScalar packet(Index index) const
00225 {
00226 return m_expression.template packet<LoadMode>(index);
00227 }
00228
00229 template<int LoadMode>
00230 inline void writePacket(Index index, const PacketScalar& x)
00231 {
00232 m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
00233 }
00234
00235 protected:
00236 const NestedExpressionType m_expression;
00237 };
00238
00239 #endif // EIGEN_ARRAYWRAPPER_H