From 75ce9cd2a7aefaaea8543e2db14ce4dc149eeb03 Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Fri, 12 Feb 2021 13:14:05 -0800 Subject: Augment NumTraits with min/max_exponent(). Replace usage of `std::numeric_limits<...>::min/max_exponent` in codebase. Also replaced some other `numeric_limits` usages in affected tests with the `NumTraits` equivalent. Fixes #2148 --- Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Eigen/src/Core/arch') diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 411640ee8..75de2d28f 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -36,7 +36,7 @@ template EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Packet pfrexp_generic_get_biased_exponent(const Packet& a) { typedef typename unpacket_traits::type Scalar; typedef typename unpacket_traits::integer_packet PacketI; - enum { mantissa_bits = numext::numeric_limits::digits - 1}; + enum { mantissa_bits = NumTraits::digits() - 1}; return pcast(plogical_shift_right(preinterpret(pabs(a)))); } @@ -48,7 +48,7 @@ Packet pfrexp_generic(const Packet& a, Packet& exponent) { typedef typename make_unsigned::type>::type ScalarUI; enum { TotalBits = sizeof(Scalar) * CHAR_BIT, - MantissaBits = numext::numeric_limits::digits - 1, + MantissaBits = NumTraits::digits() - 1, ExponentBits = int(TotalBits) - int(MantissaBits) - 1 }; @@ -116,7 +116,7 @@ Packet pldexp_generic(const Packet& a, const Packet& exponent) { typedef typename unpacket_traits::type ScalarI; enum { TotalBits = sizeof(Scalar) * CHAR_BIT, - MantissaBits = numext::numeric_limits::digits - 1, + MantissaBits = NumTraits::digits() - 1, ExponentBits = int(TotalBits) - int(MantissaBits) - 1 }; @@ -135,7 +135,7 @@ Packet pldexp_generic(const Packet& a, const Packet& exponent) { // Explicitly multiplies // a * (2^e) // clamping e to the range -// [numeric_limits::min_exponent-2, numeric_limits::max_exponent] +// [NumTraits::min_exponent()-2, NumTraits::max_exponent()] // // This is approx 7x faster than pldexp_impl, but will prematurely over/underflow // if 2^e doesn't fit into a normal floating-point Scalar. @@ -148,7 +148,7 @@ struct pldexp_fast_impl { typedef typename unpacket_traits::type ScalarI; enum { TotalBits = sizeof(Scalar) * CHAR_BIT, - MantissaBits = numext::numeric_limits::digits - 1, + MantissaBits = NumTraits::digits() - 1, ExponentBits = int(TotalBits) - int(MantissaBits) - 1 }; @@ -1480,8 +1480,8 @@ Packet generic_pow(const Packet& x, const Packet& y) { const Packet y_is_nan = pandnot(ptrue(y), pcmp_eq(y, y)); const Packet abs_y_is_inf = pcmp_eq(pabs(y), cst_pos_inf); EIGEN_CONSTEXPR Scalar huge_exponent = - (std::numeric_limits::max_exponent * Scalar(EIGEN_LN2)) / - std::numeric_limits::epsilon(); + (NumTraits::max_exponent() * Scalar(EIGEN_LN2)) / + NumTraits::epsilon(); const Packet abs_y_is_huge = pcmp_le(pset1(huge_exponent), pabs(y)); // Predicates for whether y is integer and/or even. -- cgit v1.2.3