From 66d8111ac108c7142dfdd51f095f570901778891 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Mon, 21 Apr 2025 20:59:46 +0000 Subject: [PATCH] Use a more conservative method to detect non-finite inputs to cbrt. --- Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 56744aa93..e9f564b53 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -333,12 +333,11 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet cbrt_special_cases_an const Packet x_sign = pand(sign_mask, x); Packet root = por(x_sign, abs_root); - // Handle non-finite and zero values of x. - // constexpr Scalar kInf = NumTraits::infinity(); - const Packet is_not_finite = psub(x,x);; + // Pass non-finite and zero values of x straight through. + const Packet is_not_finite = por(pisinf(x), pisnan(x)); const Packet is_zero = pcmp_eq(pzero(x), x); - const Packet use_root = por(is_not_finite, is_zero); - return pselect(use_root, x, root); + const Packet use_x = por(is_not_finite, is_zero); + return pselect(use_x, x, root); } // Generic implementation of cbrt(x) for float.