From fc6ecebc69dcd11221233216d70746d495b1f29b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 27 Nov 2013 11:32:07 +0100 Subject: [PATCH] Simplify evaluator of EvalToTemp --- Eigen/src/Core/CoreEvaluators.h | 78 +++++++++------------------------ 1 file changed, 20 insertions(+), 58 deletions(-) diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 3568cb85f..57960fcf6 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -105,7 +105,14 @@ struct evaluator_impl > RowsAtCompileTime = PlainObjectType::RowsAtCompileTime, ColsAtCompileTime = PlainObjectType::ColsAtCompileTime }; - + + evaluator_impl() + : m_data(0), + m_outerStride(IsVectorAtCompileTime ? 0 + : int(IsRowMajor) ? ColsAtCompileTime + : RowsAtCompileTime) + {} + evaluator_impl(const PlainObjectType& m) : m_data(m.data()), m_outerStride(IsVectorAtCompileTime ? 0 : m.outerStride()) { } @@ -188,6 +195,8 @@ struct evaluator_impl > : evaluator_impl > > { typedef Matrix XprType; + + evaluator_impl() {} evaluator_impl(const XprType& m) : evaluator_impl >(m) @@ -200,6 +209,8 @@ struct evaluator_impl > { typedef Array XprType; + evaluator_impl() {} + evaluator_impl(const XprType& m) : evaluator_impl >(m) { } @@ -246,80 +257,31 @@ class EvalToTemp template struct evaluator_impl > + : public evaluator::type { - typedef EvalToTemp XprType; - typedef typename ArgType::PlainObject PlainObject; + typedef EvalToTemp XprType; + typedef typename ArgType::PlainObject PlainObject; + typedef typename evaluator::type Base; evaluator_impl(const XprType& xpr) - : m_result(xpr.rows(), xpr.cols()), m_resultImpl(m_result) + : m_result(xpr.rows(), xpr.cols()) { + ::new (static_cast(this)) Base(m_result); // TODO we should simply do m_result(xpr.arg()); call_dense_assignment_loop(m_result, xpr.arg()); } // This constructor is used when nesting an EvalTo evaluator in another evaluator evaluator_impl(const ArgType& arg) - : m_result(arg.rows(), arg.cols()), m_resultImpl(m_result) + : m_result(arg.rows(), arg.cols()) { + ::new (static_cast(this)) Base(m_result); // TODO we should simply do m_result(xpr.arg()); call_dense_assignment_loop(m_result, arg); } - typedef typename PlainObject::Index Index; - typedef typename PlainObject::Scalar Scalar; - typedef typename PlainObject::CoeffReturnType CoeffReturnType; - typedef typename PlainObject::PacketScalar PacketScalar; - typedef typename PlainObject::PacketReturnType PacketReturnType; - - // All other functions are forwarded to m_resultImpl - - CoeffReturnType coeff(Index row, Index col) const - { - return m_resultImpl.coeff(row, col); - } - - CoeffReturnType coeff(Index index) const - { - return m_resultImpl.coeff(index); - } - - Scalar& coeffRef(Index row, Index col) - { - return m_resultImpl.coeffRef(row, col); - } - - Scalar& coeffRef(Index index) - { - return m_resultImpl.coeffRef(index); - } - - template - PacketReturnType packet(Index row, Index col) const - { - return m_resultImpl.template packet(row, col); - } - - template - PacketReturnType packet(Index index) const - { - return m_resultImpl.packet(index); - } - - template - void writePacket(Index row, Index col, const PacketScalar& x) - { - m_resultImpl.template writePacket(row, col, x); - } - - template - void writePacket(Index index, const PacketScalar& x) - { - m_resultImpl.template writePacket(index, x); - } - protected: PlainObject m_result; - typename evaluator::nestedType m_resultImpl; }; // -------------------- Transpose --------------------