Use a more conservative method to detect non-finite inputs to cbrt.

This commit is contained in:
Rasmus Munk Larsen 2025-04-21 20:59:46 +00:00
parent d6689a15d7
commit 66d8111ac1

View File

@ -333,12 +333,11 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet cbrt_special_cases_an
const Packet x_sign = pand(sign_mask, x); const Packet x_sign = pand(sign_mask, x);
Packet root = por(x_sign, abs_root); Packet root = por(x_sign, abs_root);
// Handle non-finite and zero values of x. // Pass non-finite and zero values of x straight through.
// constexpr Scalar kInf = NumTraits<Scalar>::infinity(); const Packet is_not_finite = por(pisinf(x), pisnan(x));
const Packet is_not_finite = psub(x,x);;
const Packet is_zero = pcmp_eq(pzero(x), x); const Packet is_zero = pcmp_eq(pzero(x), x);
const Packet use_root = por(is_not_finite, is_zero); const Packet use_x = por(is_not_finite, is_zero);
return pselect(use_root, x, root); return pselect(use_x, x, root);
} }
// Generic implementation of cbrt(x) for float. // Generic implementation of cbrt(x) for float.