File indexing completed on 2025-01-18 09:40:15
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_MATH_ELLINT_JZ_HPP
0008 #define BOOST_MATH_ELLINT_JZ_HPP
0009
0010 #ifdef _MSC_VER
0011 #pragma once
0012 #endif
0013
0014 #include <boost/math/special_functions/math_fwd.hpp>
0015 #include <boost/math/special_functions/ellint_1.hpp>
0016 #include <boost/math/special_functions/ellint_rj.hpp>
0017 #include <boost/math/special_functions/sign.hpp>
0018 #include <boost/math/constants/constants.hpp>
0019 #include <boost/math/policies/error_handling.hpp>
0020 #include <boost/math/tools/workaround.hpp>
0021
0022
0023
0024 namespace boost { namespace math {
0025
0026 namespace detail{
0027
0028
0029 template <typename T, typename Policy>
0030 T jacobi_zeta_imp(T phi, T k, const Policy& pol)
0031 {
0032 BOOST_MATH_STD_USING
0033 using namespace boost::math::tools;
0034 using namespace boost::math::constants;
0035
0036 bool invert = false;
0037 if(phi < 0)
0038 {
0039 phi = fabs(phi);
0040 invert = true;
0041 }
0042
0043 T result;
0044 T sinp = sin(phi);
0045 T cosp = cos(phi);
0046 T s2 = sinp * sinp;
0047 T k2 = k * k;
0048 T kp = 1 - k2;
0049 if(k == 1)
0050 result = sinp * (boost::math::sign)(cosp);
0051 else
0052 {
0053 typedef std::integral_constant<int,
0054 std::is_floating_point<T>::value&& std::numeric_limits<T>::digits && (std::numeric_limits<T>::digits <= 54) ? 0 :
0055 std::is_floating_point<T>::value && std::numeric_limits<T>::digits && (std::numeric_limits<T>::digits <= 64) ? 1 : 2
0056 > precision_tag_type;
0057 result = k2 * sinp * cosp * sqrt(1 - k2 * s2) * ellint_rj_imp(T(0), kp, T(1), T(1 - k2 * s2), pol) / (3 * ellint_k_imp(k, pol, precision_tag_type()));
0058 }
0059 return invert ? T(-result) : result;
0060 }
0061
0062 }
0063
0064 template <class T1, class T2, class Policy>
0065 inline typename tools::promote_args<T1, T2>::type jacobi_zeta(T1 k, T2 phi, const Policy& pol)
0066 {
0067 typedef typename tools::promote_args<T1, T2>::type result_type;
0068 typedef typename policies::evaluation<result_type, Policy>::type value_type;
0069 return policies::checked_narrowing_cast<result_type, Policy>(detail::jacobi_zeta_imp(static_cast<value_type>(phi), static_cast<value_type>(k), pol), "boost::math::jacobi_zeta<%1%>(%1%,%1%)");
0070 }
0071
0072 template <class T1, class T2>
0073 inline typename tools::promote_args<T1, T2>::type jacobi_zeta(T1 k, T2 phi)
0074 {
0075 return boost::math::jacobi_zeta(k, phi, policies::policy<>());
0076 }
0077
0078 }}
0079
0080 #endif
0081