summaryrefslogtreecommitdiff log msg author committer range
blob: a3fa54746e42a13aa0b0146159583993de37f97b (plain)
 ```1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 ``` ``````// 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 // 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 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)); 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 ``````