diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 9ed942135..bd41bf405 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -201,28 +201,32 @@ struct evaluator_impl > { typedef CwiseNullaryOp NullaryOpType; - evaluator_impl(const NullaryOpType& n) : m_nullaryOp(n) {} + evaluator_impl(const NullaryOpType& n) + : m_functor(n.functor()) + { } typedef typename NullaryOpType::Index Index; + typedef typename NullaryOpType::CoeffReturnType CoeffReturnType; + typedef typename NullaryOpType::PacketScalar PacketScalar; - typename NullaryOpType::CoeffReturnType coeff(Index i, Index j) const + CoeffReturnType coeff(Index row, Index col) const { - return m_nullaryOp.coeff(i, j); + return m_functor(row, col); } - typename NullaryOpType::CoeffReturnType coeff(Index index) const + CoeffReturnType coeff(Index index) const { - return m_nullaryOp.coeff(index); + return m_functor(index); } template - typename NullaryOpType::PacketScalar packet(Index index) const + PacketScalar packet(Index index) const { - return m_nullaryOp.template packet(index); + return m_functor.packetOp(index); } protected: - const NullaryOpType& m_nullaryOp; + const NullaryOp m_functor; }; // -------------------- CwiseUnaryOp -------------------- @@ -232,34 +236,39 @@ struct evaluator_impl > { typedef CwiseUnaryOp UnaryOpType; - evaluator_impl(const UnaryOpType& op) : m_unaryOp(op), m_argImpl(op.nestedExpression()) {} + evaluator_impl(const UnaryOpType& op) + : m_functor(op.functor()), + m_argImpl(op.nestedExpression()) + { } typedef typename UnaryOpType::Index Index; + typedef typename UnaryOpType::CoeffReturnType CoeffReturnType; + typedef typename UnaryOpType::PacketScalar PacketScalar; - typename UnaryOpType::CoeffReturnType coeff(Index i, Index j) const + CoeffReturnType coeff(Index row, Index col) const { - return m_unaryOp.functor()(m_argImpl.coeff(i, j)); + return m_functor(m_argImpl.coeff(row, col)); } - typename UnaryOpType::CoeffReturnType coeff(Index index) const + CoeffReturnType coeff(Index index) const { - return m_unaryOp.functor()(m_argImpl.coeff(index)); + return m_functor(m_argImpl.coeff(index)); } template - typename UnaryOpType::PacketScalar packet(Index index) const + PacketScalar packet(Index row, Index col) const { - return m_unaryOp.functor().packetOp(m_argImpl.template packet(index)); + return m_functor.packetOp(m_argImpl.template packet(row, col)); } template - typename UnaryOpType::PacketScalar packet(Index row, Index col) const + PacketScalar packet(Index index) const { - return m_unaryOp.functor().packetOp(m_argImpl.template packet(row, col)); + return m_functor.packetOp(m_argImpl.template packet(index)); } protected: - const UnaryOpType m_unaryOp; + const UnaryOp m_functor; typename evaluator::type m_argImpl; }; @@ -270,36 +279,42 @@ struct evaluator_impl > { typedef CwiseBinaryOp BinaryOpType; - evaluator_impl(const BinaryOpType& xpr) : m_binaryOp(xpr), m_lhsImpl(xpr.lhs()), m_rhsImpl(xpr.rhs()) {} + evaluator_impl(const BinaryOpType& xpr) + : m_functor(xpr.functor()), + m_lhsImpl(xpr.lhs()), + m_rhsImpl(xpr.rhs()) + { } typedef typename BinaryOpType::Index Index; + typedef typename BinaryOpType::CoeffReturnType CoeffReturnType; + typedef typename BinaryOpType::PacketScalar PacketScalar; - typename BinaryOpType::CoeffReturnType coeff(Index i, Index j) const + CoeffReturnType coeff(Index row, Index col) const { - return m_binaryOp.functor()(m_lhsImpl.coeff(i, j), m_rhsImpl.coeff(i, j)); + return m_functor(m_lhsImpl.coeff(row, col), m_rhsImpl.coeff(row, col)); } - typename BinaryOpType::CoeffReturnType coeff(Index index) const + CoeffReturnType coeff(Index index) const { - return m_binaryOp.functor()(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index)); + return m_functor(m_lhsImpl.coeff(index), m_rhsImpl.coeff(index)); } template - typename BinaryOpType::PacketScalar packet(Index index) const + PacketScalar packet(Index row, Index col) const { - return m_binaryOp.functor().packetOp(m_lhsImpl.template packet(index), - m_rhsImpl.template packet(index)); + return m_functor.packetOp(m_lhsImpl.template packet(row, col), + m_rhsImpl.template packet(row, col)); } template - typename BinaryOpType::PacketScalar packet(Index row, Index col) const + PacketScalar packet(Index index) const { - return m_binaryOp.functor().packetOp(m_lhsImpl.template packet(row, col), - m_rhsImpl.template packet(row, col)); + return m_functor.packetOp(m_lhsImpl.template packet(index), + m_rhsImpl.template packet(index)); } protected: - const BinaryOpType& m_binaryOp; + const BinaryOp m_functor; typename evaluator::type m_lhsImpl; typename evaluator::type m_rhsImpl; }; diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index a2f504985..2e840b851 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -101,6 +101,9 @@ class CwiseNullaryOp : internal::no_assignment_operator, return m_functor.packetOp(index); } + /** \returns the functor representing the nullary operation */ + const NullaryOp& functor() const { return m_functor; } + protected: const internal::variable_if_dynamic m_rows; const internal::variable_if_dynamic m_cols;