diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-12-23 16:13:24 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-12-23 16:13:24 +0100 |
commit | 38d704def8b6799b14c319d6a67c671374daccc3 (patch) | |
tree | 6b65c80fdd49d89b5b2b669a5c879195346bc54b /Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | |
parent | 5713fb7febf24140bfe748d8b868391f01828992 (diff) |
Make sure that psin/pcos return number in [-1,1] for large inputs (though sin/cos on large entries is quite useless because it's inaccurate)
Diffstat (limited to 'Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h')
-rw-r--r-- | Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 83fed95de..80bcc077d 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -289,9 +289,15 @@ Packet psincos_float(const Packet& _x) const Packet cst_coscof_p1 = pset1<Packet>(-1.388731625493765E-003f); const Packet cst_coscof_p2 = pset1<Packet>( 4.166664568298827E-002f); const Packet cst_cephes_FOPI = pset1<Packet>( 1.27323954473516f); // 4 / M_PI + const Packet cst_sincos_max_arg = pset1<Packet>( 13176795.0f); // Approx. (2**24) / (4/Pi). Packet x = pabs(_x); + // Prevent sin/cos from generating values larger than 1.0 in magnitude + // for very large arguments by setting x to 0.0. + Packet small_or_nan_mask = pcmp_lt_or_nan(x, cst_sincos_max_arg); + x = pand(x, small_or_nan_mask); + // Scale x by 4/Pi to find x's octant. Packet y = pmul(x, cst_cephes_FOPI); |