1 // Copyright (c) 2007 John Maddock
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_MATH_SIN_PI_HPP
7 #define BOOST_MATH_SIN_PI_HPP
13 #include <boost/config/no_tr1/cmath.hpp>
14 #include <boost/math/tools/config.hpp>
15 #include <boost/math/special_functions/trunc.hpp>
16 #include <boost/math/tools/promotion.hpp>
17 #include <boost/math/constants/constants.hpp>
19 namespace boost{ namespace math{ namespace detail{
21 template <class T, class Policy>
22 T sin_pi_imp(T x, const Policy& pol)
24 BOOST_MATH_STD_USING // ADL of std names
30 return sin(constants::pi<T>() * x);
40 if(itrunc(rem, pol) & 1)
46 return static_cast<T>(invert ? -1 : 1);
48 rem = sin(constants::pi<T>() * rem);
49 return invert ? T(-rem) : rem;
54 template <class T, class Policy>
55 inline typename tools::promote_args<T>::type sin_pi(T x, const Policy& pol)
57 typedef typename tools::promote_args<T>::type result_type;
58 return boost::math::detail::sin_pi_imp<result_type>(x, pol);
62 inline typename tools::promote_args<T>::type sin_pi(T x)
64 return boost::math::sin_pi(x, policies::policy<>());