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_COS_PI_HPP
7 #define BOOST_MATH_COS_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 cos_pi_imp(T x, const Policy& pol)
24 BOOST_MATH_STD_USING // ADL of std names
28 return cos(constants::pi<T>() * x);
35 if(itrunc(rem, pol) & 1)
46 rem = cos(constants::pi<T>() * rem);
47 return invert ? T(-rem) : rem;
52 template <class T, class Policy>
53 inline typename tools::promote_args<T>::type cos_pi(T x, const Policy& pol)
55 typedef typename tools::promote_args<T>::type result_type;
56 return boost::math::detail::cos_pi_imp<result_type>(x, pol);
60 inline typename tools::promote_args<T>::type cos_pi(T x)
62 return boost::math::cos_pi(x, policies::policy<>());