diff --git a/Eigen/src/Core/Visitor.h b/Eigen/src/Core/Visitor.h index 7b29dae22..6f6a74ac5 100644 --- a/Eigen/src/Core/Visitor.h +++ b/Eigen/src/Core/Visitor.h @@ -453,8 +453,10 @@ struct minmax_compare { static EIGEN_DEVICE_FUNC inline Scalar predux(const Packet& p) { return predux_max(p); } }; -// Default imlementatio -template +// Default implementation used by non-floating types, where we do not +// need special logic for NaN handling. +template ::IsInteger> struct minmax_coeff_visitor : coeff_visitor { using Scalar = typename Derived::Scalar; using Packet = typename packet_traits::type; @@ -493,7 +495,7 @@ struct minmax_coeff_visitor : coeff_visitor { // Suppress NaN. The only case in which we return NaN is if the matrix is all NaN, // in which case, row=0, col=0 is returned for the location. template -struct minmax_coeff_visitor : coeff_visitor { +struct minmax_coeff_visitor : coeff_visitor { typedef typename Derived::Scalar Scalar; using Packet = typename packet_traits::type; using Comparator = minmax_compare; @@ -537,10 +539,10 @@ struct minmax_coeff_visitor : coeff_visitor -struct minmax_coeff_visitor : coeff_visitor { +// Propagate NaNs. If the matrix contains NaN, the location of the first NaN +// will be returned in row and col. +template + struct minmax_coeff_visitor : coeff_visitor { typedef typename Derived::Scalar Scalar; using Packet = typename packet_traits::type; using Comparator = minmax_compare; diff --git a/test/visitor.cpp b/test/visitor.cpp index 174a1bb1d..ca97c6fa6 100644 --- a/test/visitor.cpp +++ b/test/visitor.cpp @@ -112,6 +112,15 @@ template void matrixVisitor(const MatrixType& p) VERIFY(eigen_maxcol == 0); VERIFY((numext::isnan)(eigen_minc)); VERIFY((numext::isnan)(eigen_maxc)); + + eigen_minc = m.template minCoeff(&eigen_minrow, &eigen_mincol); + eigen_maxc = m.template maxCoeff(&eigen_maxrow, &eigen_maxcol); + VERIFY(eigen_minrow == 0); + VERIFY(eigen_maxrow == 0); + VERIFY(eigen_mincol == 0); + VERIFY(eigen_maxcol == 0); + VERIFY((numext::isnan)(eigen_minc)); + VERIFY((numext::isnan)(eigen_maxc)); } }