mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-05 19:46:07 +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>
|
template<typename Visitor>
|
||||||
void DenseBase<Derived>::visit(Visitor& visitor) const
|
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
|
enum { unroll = SizeAtCompileTime != Dynamic
|
||||||
&& CoeffReadCost != Dynamic
|
&& CoeffReadCost != Dynamic
|
||||||
&& (SizeAtCompileTime == 1 || internal::functor_traits<Visitor>::Cost != Dynamic)
|
&& (SizeAtCompileTime == 1 || internal::functor_traits<Visitor>::Cost != Dynamic)
|
||||||
&& SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits<Visitor>::Cost
|
&& SizeAtCompileTime * CoeffReadCost + (SizeAtCompileTime-1) * internal::functor_traits<Visitor>::Cost
|
||||||
<= EIGEN_UNROLLING_LIMIT };
|
<= EIGEN_UNROLLING_LIMIT };
|
||||||
return internal::visitor_impl<Visitor, Derived,
|
return internal::visitor_impl<Visitor, ThisNested,
|
||||||
unroll ? int(SizeAtCompileTime) : Dynamic
|
unroll ? int(SizeAtCompileTime) : Dynamic
|
||||||
>::run(derived(), visitor);
|
>::run(thisNested, visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -55,6 +55,11 @@ template<typename MatrixType> void matrixVisitor(const MatrixType& p)
|
|||||||
VERIFY_IS_APPROX(maxc, eigen_maxc);
|
VERIFY_IS_APPROX(maxc, eigen_maxc);
|
||||||
VERIFY_IS_APPROX(minc, m.minCoeff());
|
VERIFY_IS_APPROX(minc, m.minCoeff());
|
||||||
VERIFY_IS_APPROX(maxc, m.maxCoeff());
|
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)
|
template<typename VectorType> void vectorVisitor(const VectorType& w)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user