From 446001ef51be920649cb4f3c07848967b6788532 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 24 Sep 2014 09:39:09 +0200 Subject: [PATCH] Fix nested_eval > which wrongly returned a Product<> expression --- Eigen/src/Core/Inverse.h | 3 +-- Eigen/src/Core/ProductEvaluators.h | 10 +++++++--- test/geo_orthomethods.cpp | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Eigen/src/Core/Inverse.h b/Eigen/src/Core/Inverse.h index 706796b78..f3b0dff87 100644 --- a/Eigen/src/Core/Inverse.h +++ b/Eigen/src/Core/Inverse.h @@ -25,8 +25,7 @@ struct traits > typedef typename XprType::PlainObject PlainObject; typedef traits BaseTraits; enum { - Flags = BaseTraits::Flags & RowMajorBit, - CoeffReadCost = Dynamic + Flags = BaseTraits::Flags & RowMajorBit }; }; diff --git a/Eigen/src/Core/ProductEvaluators.h b/Eigen/src/Core/ProductEvaluators.h index 69e569908..c944ec9fc 100644 --- a/Eigen/src/Core/ProductEvaluators.h +++ b/Eigen/src/Core/ProductEvaluators.h @@ -97,11 +97,12 @@ struct product_evaluator, ProductTag, LhsShape : public evaluator::PlainObject>::type { typedef Product XprType; -// enum { -// CoeffReadCost = 0 // FIXME why is it needed? (this was already the case before the evaluators, see traits) -// }; typedef typename XprType::PlainObject PlainObject; typedef typename evaluator::type Base; + enum { + Flags = Base::Flags | EvalBeforeNestingBit +// CoeffReadCost = 0 // FIXME why is it needed? (this was already the case before the evaluators, see traits) + }; explicit product_evaluator(const XprType& xpr) : m_result(xpr.rows(), xpr.cols()) @@ -508,6 +509,9 @@ struct product_evaluator, LazyCoeffBasedProduc typedef Product XprType; typedef Product BaseProduct; typedef product_evaluator Base; + enum { + Flags = Base::Flags | EvalBeforeNestingBit + }; explicit product_evaluator(const XprType& xpr) : Base(BaseProduct(xpr.lhs(),xpr.rhs())) {} diff --git a/test/geo_orthomethods.cpp b/test/geo_orthomethods.cpp index 7f8beb205..e178df257 100644 --- a/test/geo_orthomethods.cpp +++ b/test/geo_orthomethods.cpp @@ -39,7 +39,10 @@ template void orthomethods_3() (v0.cross(v1)).normalized(), (v0.cross(v1).cross(v0)).normalized(); VERIFY(mat3.isUnitary()); - + + mat3.setRandom(); + VERIFY_IS_APPROX(v0.cross(mat3*v1), -(mat3*v1).cross(v0)); + VERIFY_IS_APPROX(v0.cross(mat3.lazyProduct(v1)), -(mat3.lazyProduct(v1)).cross(v0)); // colwise/rowwise cross product mat3.setRandom();