// Copyright (c) 2015 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_ELLINT_JZ_HPP #define BOOST_MATH_ELLINT_JZ_HPP #ifdef _MSC_VER #pragma once #endif #include #include #include #include #include #include #include // Elliptic integral the Jacobi Zeta function. namespace boost { namespace math { namespace detail{ // Elliptic integral - Jacobi Zeta template T jacobi_zeta_imp(T phi, T k, const Policy& pol, T kp) { BOOST_MATH_STD_USING using namespace boost::math::tools; using namespace boost::math::constants; bool invert = false; if(phi < 0) { phi = fabs(phi); invert = true; } T result; T sinp = sin(phi); T cosp = cos(phi); T c2 = cosp * cosp; T one_minus_ks2 = kp + c2 - kp * c2; T k2 = k * k; if(k == 1) result = sinp * (boost::math::sign)(cosp); // We get here by simplifying JacobiZeta[w, 1] in Mathematica, and the fact that 0 <= phi. else { result = k2 * sinp * cosp * sqrt(one_minus_ks2) * ellint_rj_imp(T(0), kp, T(1), one_minus_ks2, pol) / (3 * ellint_k_imp(k, pol, kp)); } return invert ? T(-result) : result; } template inline T jacobi_zeta_imp(T phi, T k, const Policy& pol) { return jacobi_zeta_imp(phi, k, pol, T(1 - k * k)); } } // detail template inline typename tools::promote_args::type jacobi_zeta(T1 k, T2 phi, const Policy& pol) { typedef typename tools::promote_args::type result_type; typedef typename policies::evaluation::type value_type; return policies::checked_narrowing_cast(detail::jacobi_zeta_imp(static_cast(phi), static_cast(k), pol), "boost::math::jacobi_zeta<%1%>(%1%,%1%)"); } template inline typename tools::promote_args::type jacobi_zeta(T1 k, T2 phi) { return boost::math::jacobi_zeta(k, phi, policies::policy<>()); } }} // namespaces #endif // BOOST_MATH_ELLINT_D_HPP