summaryrefslogtreecommitdiff log msg author committer range
blob: 6389443ee4b1ec9b586cd54518a359a4459a5986 (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 75 76 77 78 79 80 81 82 83 84 85 86 87 ``` ``````// 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_HL_HPP #define BOOST_MATH_ELLINT_HL_HPP #ifdef _MSC_VER #pragma once #endif #include #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 heuman_lambda_imp(T phi, T k, const Policy& pol) { BOOST_MATH_STD_USING using namespace boost::math::tools; using namespace boost::math::constants; const char* function = "boost::math::heuman_lambda<%1%>(%1%, %1%)"; if(fabs(k) > 1) return policies::raise_domain_error(function, "We require |k| <= 1 but got k = %1%", k, pol); T result; T sinp = sin(phi); T cosp = cos(phi); T s2 = sinp * sinp; T k2 = k * k; T kp = 1 - k2; T delta = sqrt(1 - (kp * s2)); if(fabs(phi) <= constants::half_pi()) { result = kp * sinp * cosp / (delta * constants::half_pi()); result *= ellint_rf_imp(T(0), kp, T(1), pol) + k2 * ellint_rj(T(0), kp, T(1), T(1 - k2 / (delta * delta)), pol) / (3 * delta * delta); } else { T rkp = sqrt(kp); T ratio; if(rkp == 1) { return policies::raise_domain_error(function, "When 1-k^2 == 1 then phi must be < Pi/2, but got phi = %1%", phi, pol); } else ratio = ellint_f_imp(phi, rkp, pol) / ellint_k_imp(rkp, pol); result = ratio + ellint_k_imp(k, pol) * jacobi_zeta_imp(phi, rkp, pol) / constants::half_pi(); } return result; } } // detail template inline typename tools::promote_args::type heuman_lambda(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::heuman_lambda_imp(static_cast(phi), static_cast(k), pol), "boost::math::heuman_lambda<%1%>(%1%,%1%)"); } template inline typename tools::promote_args::type heuman_lambda(T1 k, T2 phi) { return boost::math::heuman_lambda(k, phi, policies::policy<>()); } }} // namespaces #endif // BOOST_MATH_ELLINT_D_HPP ``````