diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2019-10-02 12:48:17 -0700 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2019-10-02 12:48:17 -0700 |
commit | fab4e3a753fa514a23c0c6ab78e0afab59918370 (patch) | |
tree | 295faf8cc2eb0ba00f67d6217a2aa1a849819f5b | |
parent | 6e40454a6e6cc57c07c7340148657c985ca6c928 (diff) |
Address comments on Chebyshev evaluation code:
1. Use pmadd when possible.
2. Add casts to avoid c++03 warnings.
-rw-r--r-- | Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index a354fb5fe..d3a2f4ed5 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -626,17 +626,18 @@ template <typename Packet, int N> struct pchebevl { EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Packet run(Packet x, const typename unpacket_traits<Packet>::type coef[]) { + typedef typename unpacket_traits<Packet>::type Scalar; Packet b0 = pset1<Packet>(coef[0]); - Packet b1 = pset1<Packet>(0.f); + Packet b1 = pset1<Packet>(static_cast<Scalar>(0.f)); Packet b2; for (int i = 1; i < N; i++) { b2 = b1; b1 = b0; - b0 = padd(psub(pmul(x, b1), b2), pset1<Packet>(coef[i])); + b0 = psub(pmadd(x, b1, pset1<Packet>(coef[i])), b2); } - return pmul(pset1<Packet>(0.5f), psub(b0, b2)); + return pmul(pset1<Packet>(static_cast<Scalar>(0.5f)), psub(b0, b2)); } }; |