diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:24:45 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2019-12-05 15:24:45 +0900 |
commit | 5ce1cfc2525b06c0a9e38531813781de0281c96d (patch) | |
tree | 19cc66c6cf6396db288813b2558cc350f1deede2 /boost/math/special_functions/sin_pi.hpp | |
parent | 3c1df2168531ad5580076ae08d529054689aeedd (diff) | |
download | boost-5ce1cfc2525b06c0a9e38531813781de0281c96d.tar.gz boost-5ce1cfc2525b06c0a9e38531813781de0281c96d.tar.bz2 boost-5ce1cfc2525b06c0a9e38531813781de0281c96d.zip |
Imported Upstream version 1.71.0upstream/1.71.0
Diffstat (limited to 'boost/math/special_functions/sin_pi.hpp')
-rw-r--r-- | boost/math/special_functions/sin_pi.hpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/boost/math/special_functions/sin_pi.hpp b/boost/math/special_functions/sin_pi.hpp index ae6b3e7442..de80387320 100644 --- a/boost/math/special_functions/sin_pi.hpp +++ b/boost/math/special_functions/sin_pi.hpp @@ -20,11 +20,11 @@ namespace boost{ namespace math{ namespace detail{ template <class T, class Policy> -T sin_pi_imp(T x, const Policy& pol) +inline T sin_pi_imp(T x, const Policy& pol) { BOOST_MATH_STD_USING // ADL of std names if(x < 0) - return -sin_pi(-x); + return -sin_pi_imp(T(-x), pol); // sin of pi*x: bool invert; if(x < 0.5) @@ -38,7 +38,7 @@ T sin_pi_imp(T x, const Policy& pol) invert = false; T rem = floor(x); - if(itrunc(rem, pol) & 1) + if(iconvert(rem, pol) & 1) invert = !invert; rem = x - rem; if(rem > 0.5f) @@ -62,8 +62,11 @@ inline typename tools::promote_args<T>::type sin_pi(T x, const Policy&) policies::promote_float<false>, policies::promote_double<false>, policies::discrete_quantile<>, - policies::assert_undefined<> >::type forwarding_policy; - return policies::checked_narrowing_cast<result_type, forwarding_policy>(boost::math::detail::sin_pi_imp<value_type>(x, forwarding_policy()), "cos_pi"); + policies::assert_undefined<>, + // We want to igore overflows since the result is in [-1,1] and the + // check slows the code down considerably. + policies::overflow_error<policies::ignore_error> >::type forwarding_policy; + return policies::checked_narrowing_cast<result_type, forwarding_policy>(boost::math::detail::sin_pi_imp<value_type>(x, forwarding_policy()), "sin_pi"); } template <class T> |