// 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) { 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 s2 = sinp * sinp; T k2 = k * k; T kp = 1 - k2; 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 { typedef std::integral_constant::value&& std::numeric_limits::digits && (std::numeric_limits::digits <= 54) ? 0 : std::is_floating_point::value && std::numeric_limits::digits && (std::numeric_limits::digits <= 64) ? 1 : 2 > precision_tag_type; 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())); } return invert ? T(-result) : result; } } // 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