From ffc995c9e40ef27cba672738802e989c4ee383d0 Mon Sep 17 00:00:00 2001 From: Jitse Niesen Date: Wed, 16 Apr 2014 18:16:36 +0100 Subject: Implement evaluator. All supported tests pass apart from Sparse and Geometry, except test in adjoint_4 that a = a.transpose() raises an assert. --- Eigen/src/Core/CoreEvaluators.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Eigen/src') diff --git a/Eigen/src/Core/CoreEvaluators.h b/Eigen/src/Core/CoreEvaluators.h index 47f50d548..8df1b706d 100644 --- a/Eigen/src/Core/CoreEvaluators.h +++ b/Eigen/src/Core/CoreEvaluators.h @@ -1292,6 +1292,32 @@ private: EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value() > 0 ? m_index.value() : 0; } }; +// -------------------- ReturnByValue -------------------- + +// Expression is evaluated in a temporary; default implementation of Assignment is bypassed so that +// when a ReturnByValue expression is assigned, the evaluator is not constructed. +// TODO: Finalize port to new regime; ReturnByValue should not exist in the expression world + +template +struct evaluator > + : evaluator::PlainObject>::type +{ + typedef typename ReturnByValue::PlainObject PlainObject; + typedef typename evaluator::type Base; + + typedef evaluator type; + typedef evaluator nestedType; + + evaluator(const ReturnByValue& xpr) + : m_result(xpr.rows(), xpr.cols()) + { + ::new (static_cast(this)) Base(m_result); + xpr.evalTo(m_result); + } + + PlainObject m_result; +}; + } // namespace internal } // end namespace Eigen -- cgit v1.2.3