From 17f3bf8985021c242eedc9fa26c5c66d43a300f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=C3=A1nchez?= Date: Thu, 7 Mar 2024 00:19:57 +0000 Subject: [PATCH] Fix pexp test for ARM. --- test/packetmath.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/packetmath.cpp b/test/packetmath.cpp index 116663d96..db8c9b5c5 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -1346,13 +1346,25 @@ struct exp_complex_test_impl { static Scalar cis(const RealScalar& x) { return Scalar(numext::cos(x), numext::sin(x)); } // Verify equality with signed zero. - static bool is_exactly_equal(const RealScalar& a, const RealScalar& b) { + static bool is_exactly_equal(RealScalar a, RealScalar b) { // NaNs are always unsigned, and always compare not equal directly. if ((numext::isnan)(a)) { return (numext::isnan)(b); } - // Signed zero. + RealScalar zero(0); +#ifdef EIGEN_ARCH_ARM + // ARM automatically flushes denormals to zero. + // Preserve sign by multiplying by +0. + if (numext::abs(a) < (std::numeric_limits::min)()) { + a = a * zero; + } + if (numext::abs(b) < (std::numeric_limits::min)()) { + b = b * zero; + } +#endif + + // Signed zero. if (a == zero) { // Signs are either 0 or NaN, so verify that their comparisons to zero are equal. return (a == b) && ((numext::signbit(a) == zero) == (numext::signbit(b) == zero));