From 5297b7162a0630e2e5b1459fa665c9f3b1eb532a Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Wed, 24 Feb 2021 17:49:20 -0800 Subject: Make it possible to specify NaN propagation strategy for maxCoeff/minCoeff reductions. --- test/array_cwise.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index 7f7e44f89..92abf6968 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -610,6 +610,20 @@ template void min_max(const ArrayType& m) VERIFY_IS_APPROX(ArrayType::Constant(rows,cols, maxM1), (m1.max)( maxM1)); VERIFY_IS_APPROX(m1, (m1.max)( minM1)); + + // min/max with various NaN propagation options. + if (m1.size() > 1 && !NumTraits::IsInteger) { + m1(0,0) = std::numeric_limits::quiet_NaN(); + maxM1 = m1.template maxCoeff(); + minM1 = m1.template minCoeff(); + VERIFY((numext::isnan)(maxM1)); + VERIFY((numext::isnan)(minM1)); + + maxM1 = m1.template maxCoeff(); + minM1 = m1.template minCoeff(); + VERIFY(!(numext::isnan)(maxM1)); + VERIFY(!(numext::isnan)(minM1)); + } } EIGEN_DECLARE_TEST(array_cwise) -- cgit v1.2.3