From 7dc0c4e8f6fdb0110fdcbb536a6146abc31dd39f Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 18 Nov 2015 23:27:18 +0100 Subject: [PATCH] make Visitor honors nesting requirements (fix prod.maxCoeff(i) and similar) --- Eigen/src/Core/Visitor.h | 7 +++++-- test/visitor.cpp | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 64867b7a2..dd94eb8f0 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -76,14 +76,17 @@ template template void DenseBase::visit(Visitor& visitor) const { + typedef typename internal::remove_all::type ThisNested; + typename Derived::Nested thisNested(derived()); + enum { unroll = SizeAtCompileTime != Dynamic && CoeffReadCost != Dynamic && (SizeAtCompileTime == 1 || internal::functor_traits::Cost != Dynamic) && SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits::Cost <= EIGEN_UNROLLING_LIMIT }; - return internal::visitor_impl::run(derived(), visitor); + >::run(thisNested, visitor); } namespace internal { diff --git a/test/visitor.cpp b/test/visitor.cpp index 39a5d6b5f..844170ec6 100644 --- a/test/visitor.cpp +++ b/test/visitor.cpp @@ -55,6 +55,11 @@ template void matrixVisitor(const MatrixType& p) VERIFY_IS_APPROX(maxc, eigen_maxc); VERIFY_IS_APPROX(minc, m.minCoeff()); VERIFY_IS_APPROX(maxc, m.maxCoeff()); + + eigen_maxc = (m.adjoint()*m).maxCoeff(&eigen_maxrow,&eigen_maxcol); + eigen_maxc = (m.adjoint()*m).eval().maxCoeff(&maxrow,&maxcol); + VERIFY(maxrow == eigen_maxrow); + VERIFY(maxcol == eigen_maxcol); } template void vectorVisitor(const VectorType& w)