aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/CoreEvaluators.h
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-04-22 22:36:45 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2011-04-22 22:36:45 +0100
commitbb2d70d211a8fc8184b690b75d29ba484edace0e (patch)
tree2325d715f307dc558f32e560951939d91aa37f11 /Eigen/src/Core/CoreEvaluators.h
parent6441e8727b32c6cbb194c0ce1bbd784c2a24a2b2 (diff)
Implement evaluators for ArrayWrapper and MatrixWrapper.
Diffstat (limited to 'Eigen/src/Core/CoreEvaluators.h')
-rw-r--r--Eigen/src/Core/CoreEvaluators.h85
1 files changed, 84 insertions, 1 deletions
diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h
index 6b08c78a0..47835f576 100644
--- a/Eigen/src/Core/CoreEvaluators.h
+++ b/Eigen/src/Core/CoreEvaluators.h
@@ -106,7 +106,7 @@ protected:
typename evaluator<ExpressionType>::type m_argImpl;
};
-// -------------------- Matrix and Array--------------------
+// -------------------- Matrix and Array --------------------
//
// evaluator_impl<PlainObjectBase> is a common base class for the
// Matrix and Array evaluators.
@@ -704,6 +704,89 @@ protected:
};
+// -------------------- MatrixWrapper and ArrayWrapper --------------------
+//
+// evaluator_impl_wrapper_base<T> is a common base class for the
+// MatrixWrapper and ArrayWrapper evaluators.
+
+template<typename ArgType>
+struct evaluator_impl_wrapper_base
+{
+ evaluator_impl_wrapper_base(const ArgType& arg) : m_argImpl(arg) {}
+
+ typedef typename ArgType::Index Index;
+ typedef typename ArgType::Scalar Scalar;
+ typedef typename ArgType::CoeffReturnType CoeffReturnType;
+ typedef typename ArgType::PacketScalar PacketScalar;
+ typedef typename ArgType::PacketReturnType PacketReturnType;
+
+ CoeffReturnType coeff(Index row, Index col) const
+ {
+ return m_argImpl.coeff(row, col);
+ }
+
+ CoeffReturnType coeff(Index index) const
+ {
+ return m_argImpl.coeff(index);
+ }
+
+ Scalar& coeffRef(Index row, Index col)
+ {
+ return m_argImpl.coeffRef(row, col);
+ }
+
+ Scalar& coeffRef(Index index)
+ {
+ return m_argImpl.coeffRef(index);
+ }
+
+ template<int LoadMode>
+ PacketReturnType packet(Index row, Index col) const
+ {
+ return m_argImpl.template packet<LoadMode>(row, col);
+ }
+
+ template<int LoadMode>
+ PacketReturnType packet(Index index) const
+ {
+ return m_argImpl.template packet<LoadMode>(index);
+ }
+
+ template<int StoreMode>
+ void writePacket(Index row, Index col, const PacketScalar& x)
+ {
+ m_argImpl.template writePacket<StoreMode>(row, col, x);
+ }
+
+ template<int StoreMode>
+ void writePacket(Index index, const PacketScalar& x)
+ {
+ m_argImpl.template writePacket<StoreMode>(index, x);
+ }
+
+protected:
+ typename evaluator<ArgType>::type m_argImpl;
+};
+
+template<typename ArgType>
+struct evaluator_impl<MatrixWrapper<ArgType> >
+ : evaluator_impl_wrapper_base<ArgType>
+{
+ evaluator_impl(const MatrixWrapper<ArgType>& wrapper)
+ : evaluator_impl_wrapper_base<ArgType>(wrapper.nestedExpression())
+ { }
+};
+
+template<typename ArgType>
+struct evaluator_impl<ArrayWrapper<ArgType> >
+ : evaluator_impl_wrapper_base<ArgType>
+{
+ evaluator_impl(const ArrayWrapper<ArgType>& wrapper)
+ : evaluator_impl_wrapper_base<ArgType>(wrapper.nestedExpression())
+ { }
+};
+
+
} // namespace internal
#endif // EIGEN_COREEVALUATORS_H