aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2020-10-12 12:24:08 +0100
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2021-02-10 22:45:41 +0000
commit4cb563a01e0619ea1798c7927f1909755ead2dd8 (patch)
treef1a1c213a13ad6320fa86ebb144af777568eeeea /Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h
parent7eb07da538ecc1b8937bfb5dac0d071067728397 (diff)
Fix ldexp implementations.
The previous implementations produced garbage values if the exponent did not fit within the exponent bits. See #2131 for a complete discussion, and !375 for other possible implementations. Here we implement the 4-factor version. See `pldexp_impl` in `GenericPacketMathFunctions.h` for a full description. The SSE `pcmp*` methods were moved down since `pcmp_le<Packet4i>` requires `por`. Left as a "TODO" is to delegate to a faster version if we know the exponent does fit within the exponent bits. Fixes #2131.
Diffstat (limited to 'Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h')
-rw-r--r--Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h
index a623f54cb..96c572fd3 100644
--- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h
+++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctionsFwd.h
@@ -21,14 +21,33 @@ namespace internal {
template<typename Packet, int N> EIGEN_DEVICE_FUNC inline Packet
pset(const typename unpacket_traits<Packet>::type (&a)[N] /* a */);
+/***************************************************************************
+ * Some generic implementations to be used by implementors
+***************************************************************************/
+
+/** Default implementation of pfrexp for float.
+ * It is expected to be called by implementers of template<> pfrexp.
+ */
template<typename Packet> EIGEN_STRONG_INLINE Packet
pfrexp_float(const Packet& a, Packet& exponent);
+/** Default implementation of pfrexp for double.
+ * It is expected to be called by implementers of template<> pfrexp.
+ */
template<typename Packet> EIGEN_STRONG_INLINE Packet
pfrexp_double(const Packet& a, Packet& exponent);
+/** Default implementation of pldexp for float.
+ * It is expected to be called by implementers of template<> pldexp.
+ */
+template<typename Packet> EIGEN_STRONG_INLINE Packet
+pldexp_float(const Packet& a, const Packet& exponent);
+
+/** Default implementation of pldexp for double.
+ * It is expected to be called by implementers of template<> pldexp.
+ */
template<typename Packet> EIGEN_STRONG_INLINE Packet
-pldexp_float(Packet a, Packet exponent);
+pldexp_double(const Packet& a, const Packet& exponent);
/** \internal \returns log(x) for single precision float */
template <typename Packet>