aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src
diff options
context:
space:
mode:
authorGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2014-04-16 18:16:36 +0100
committerGravatar Jitse Niesen <jitse@maths.leeds.ac.uk>2014-04-16 18:16:36 +0100
commitffc995c9e40ef27cba672738802e989c4ee383d0 (patch)
treee22da22c5a1e788b5a09d61ca4b0f683d01ef8b8 /Eigen/src
parentb30706bd5cfb9df8ab10f7861232623373aec626 (diff)
Implement evaluator<ReturnByValue>.
All supported tests pass apart from Sparse and Geometry, except test in adjoint_4 that a = a.transpose() raises an assert.
Diffstat (limited to 'Eigen/src')
-rw-r--r--Eigen/src/Core/CoreEvaluators.h26
1 files changed, 26 insertions, 0 deletions
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<typename Derived>
+struct evaluator<ReturnByValue<Derived> >
+ : evaluator<typename ReturnByValue<Derived>::PlainObject>::type
+{
+ typedef typename ReturnByValue<Derived>::PlainObject PlainObject;
+ typedef typename evaluator<PlainObject>::type Base;
+
+ typedef evaluator type;
+ typedef evaluator nestedType;
+
+ evaluator(const ReturnByValue<Derived>& xpr)
+ : m_result(xpr.rows(), xpr.cols())
+ {
+ ::new (static_cast<Base*>(this)) Base(m_result);
+ xpr.evalTo(m_result);
+ }
+
+ PlainObject m_result;
+};
+
} // namespace internal
} // end namespace Eigen