From 3717854a212a6efd9f9f116eb82063494b2e4bc8 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen Date: Thu, 15 Dec 2022 18:41:46 +0000 Subject: [PATCH] Use numext::signbit instead of std::signbit, which is not defined for bfloat16. --- test/array_cwise.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index bc721656d..af8a1ef1d 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -287,27 +287,9 @@ struct functor_traits> { } // namespace internal } // namespace Eigen -template ::IsInteger> -struct ref_signbit_func_impl { - static bool run(const T& x) { return std::signbit(x); } -}; -template -struct ref_signbit_func_impl { - // MSVC (perhaps others) does not have a std::signbit overload for integers - static bool run(const T& x) { return x < T(0); } -}; -template -bool ref_signbit_func(const T& x) { - return ref_signbit_func_impl::run(x); -} template void signbit_test() { - Scalar true_mask; - std::memset(static_cast(&true_mask), 0xff, sizeof(Scalar)); - Scalar false_mask; - std::memset(static_cast(&false_mask), 0x00, sizeof(Scalar)); - const size_t size = 100 * internal::packet_traits::size; ArrayX x(size), y(size); x.setRandom(); @@ -320,7 +302,7 @@ void signbit_test() { bool all_pass = true; for (size_t i = 0; i < size; i++) { - const Scalar ref_val = ref_signbit_func(x(i)) ? true_mask : false_mask; + const Scalar ref_val = numext::signbit(x(i)); bool not_same = internal::predux_any(internal::bitwise_helper::bitwise_xor(ref_val, y(i))); if (not_same) std::cout << "signbit(" << x(i) << ") != " << y(i) << "\n"; all_pass = all_pass && !not_same;