mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-05 11:40:40 +08:00
make Visitor honors nesting requirements (fix prod.maxCoeff(i) and similar)
This commit is contained in:
parent
b3b9d7a14c
commit
7dc0c4e8f6
@ -76,14 +76,17 @@ template<typename Derived>
|
||||
template<typename Visitor>
|
||||
void DenseBase<Derived>::visit(Visitor& visitor) const
|
||||
{
|
||||
typedef typename internal::remove_all<typename Derived::Nested>::type ThisNested;
|
||||
typename Derived::Nested thisNested(derived());
|
||||
|
||||
enum { unroll = SizeAtCompileTime != Dynamic
|
||||
&& CoeffReadCost != Dynamic
|
||||
&& (SizeAtCompileTime == 1 || internal::functor_traits<Visitor>::Cost != Dynamic)
|
||||
&& SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits<Visitor>::Cost
|
||||
<= EIGEN_UNROLLING_LIMIT };
|
||||
return internal::visitor_impl<Visitor, Derived,
|
||||
return internal::visitor_impl<Visitor, ThisNested,
|
||||
unroll ? int(SizeAtCompileTime) : Dynamic
|
||||
>::run(derived(), visitor);
|
||||
>::run(thisNested, visitor);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
@ -55,6 +55,11 @@ template<typename MatrixType> 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<typename VectorType> void vectorVisitor(const VectorType& w)
|
||||
|
Loading…
x
Reference in New Issue
Block a user