From 9aba527405b40132a308f5f782dacadf6ef50acd Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Tue, 27 Aug 2019 15:35:29 -0700 Subject: [PATCH] Revert changes to std_falback::log1p that broke handling of arguments less than -1. Fix packet op accordingly. --- Eigen/src/Core/MathFunctions.h | 3 +-- Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 4 +--- test/packetmath.cpp | 2 -- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 1eeb2752b..fcf62011e 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -550,9 +550,8 @@ namespace std_fallback { EIGEN_USING_STD_MATH(log); Scalar x1p = RealScalar(1) + x; Scalar log_1p = log(x1p); - const bool is_inf = numext::equal_strict(x1p, log_1p); const bool is_small = numext::equal_strict(x1p, Scalar(1)); - return (is_inf || is_small) ? x : x * (log_1p / (x1p - RealScalar(1))); + return is_small ? x : x * (log_1p / (x1p - RealScalar(1))); } } diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 640aae05a..505a0eec8 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -137,10 +137,8 @@ Packet generic_plog1p(const Packet& x) Packet xp1 = padd(x, one); Packet small_mask = pcmp_eq(xp1, one); Packet log1 = plog(xp1); - // Add a check to handle x == +inf. - Packet pos_inf_mask = pcmp_eq(x, log1); Packet log_large = pmul(x, pdiv(log1, psub(xp1, one))); - return pselect(por(small_mask, pos_inf_mask), x, log_large); + return pselect(small_mask, x, log_large); } /** \internal \returns exp(x)-1 computed using W. Kahan's formula. diff --git a/test/packetmath.cpp b/test/packetmath.cpp index 41000a842..28768b18d 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -607,8 +607,6 @@ template void packetmath_real() CHECK_CWISE1_IF(internal::packet_traits::HasLGamma, std::lgamma, internal::plgamma); CHECK_CWISE1_IF(internal::packet_traits::HasErf, std::erf, internal::perf); CHECK_CWISE1_IF(internal::packet_traits::HasErfc, std::erfc, internal::perfc); - data1[0] = std::numeric_limits::infinity(); - data1[1] = std::numeric_limits::denorm_min(); CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1); CHECK_CWISE1_IF(PacketTraits::HasLog1p, std::log1p, internal::plog1p); #endif