From 11ea81858ae113ae11ee79dbb3a338172507a1bc Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Tue, 5 Apr 2011 18:20:43 +0100 Subject: Implement evaluator for CwiseUnaryView --- Eigen/src/Core/CoreEvaluators.h | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'Eigen') diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 3060ca982..9ed942135 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -259,7 +259,7 @@ struct evaluator_impl > } protected: - const UnaryOpType& m_unaryOp; + const UnaryOpType m_unaryOp; typename evaluator::type m_argImpl; }; @@ -304,6 +304,47 @@ protected: typename evaluator::type m_rhsImpl; }; +// -------------------- CwiseUnaryView -------------------- + +template +struct evaluator_impl > +{ + typedef CwiseUnaryView CwiseUnaryViewType; + + evaluator_impl(const CwiseUnaryViewType& op) + : m_unaryOp(op.functor()), + m_argImpl(op.nestedExpression()) + { } + + typedef typename CwiseUnaryViewType::Index Index; + typedef typename CwiseUnaryViewType::Scalar Scalar; + typedef typename CwiseUnaryViewType::CoeffReturnType CoeffReturnType; + + CoeffReturnType coeff(Index row, Index col) const + { + return m_unaryOp(m_argImpl.coeff(row, col)); + } + + CoeffReturnType coeff(Index index) const + { + return m_unaryOp(m_argImpl.coeff(index)); + } + + Scalar& coeffRef(Index row, Index col) + { + return m_unaryOp(m_argImpl.coeffRef(row, col)); + } + + Scalar& coeffRef(Index index) + { + return m_unaryOp(m_argImpl.coeffRef(index)); + } + +protected: + const UnaryOp& m_unaryOp; + typename evaluator::type m_argImpl; +}; + // -------------------- Product -------------------- template -- cgit v1.2.3