X-Git-Url: https://git.donarmstrong.com/?p=rsem.git;a=blobdiff_plain;f=boost%2Fmath%2Fspecial_functions%2Fsin_pi.hpp;fp=boost%2Fmath%2Fspecial_functions%2Fsin_pi.hpp;h=38c02bc99e7930ea4cb276b50c8b2baf68aa1bc5;hp=0000000000000000000000000000000000000000;hb=2d71eb92104693ca9baa5a2e1c23eeca776d8fd3;hpb=da57529b92adbb7ae74a89861cb39fb35ac7c62d diff --git a/boost/math/special_functions/sin_pi.hpp b/boost/math/special_functions/sin_pi.hpp new file mode 100644 index 0000000..38c02bc --- /dev/null +++ b/boost/math/special_functions/sin_pi.hpp @@ -0,0 +1,70 @@ +// Copyright (c) 2007 John Maddock +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_MATH_SIN_PI_HPP +#define BOOST_MATH_SIN_PI_HPP + +#ifdef _MSC_VER +#pragma once +#endif + +#include +#include +#include +#include +#include + +namespace boost{ namespace math{ namespace detail{ + +template +T sin_pi_imp(T x, const Policy& pol) +{ + BOOST_MATH_STD_USING // ADL of std names + if(x < 0) + return -sin_pi(-x); + // sin of pi*x: + bool invert; + if(x < 0.5) + return sin(constants::pi() * x); + if(x < 1) + { + invert = true; + x = -x; + } + else + invert = false; + + T rem = floor(x); + if(itrunc(rem, pol) & 1) + invert = !invert; + rem = x - rem; + if(rem > 0.5f) + rem = 1 - rem; + if(rem == 0.5f) + return static_cast(invert ? -1 : 1); + + rem = sin(constants::pi() * rem); + return invert ? T(-rem) : rem; +} + +} // namespace detail + +template +inline typename tools::promote_args::type sin_pi(T x, const Policy& pol) +{ + typedef typename tools::promote_args::type result_type; + return boost::math::detail::sin_pi_imp(x, pol); +} + +template +inline typename tools::promote_args::type sin_pi(T x) +{ + return boost::math::sin_pi(x, policies::policy<>()); +} + +} // namespace math +} // namespace boost +#endif +