Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:40:14

0001 //  Copyright (c) 2015 John Maddock
0002 //  Use, modification and distribution are subject to the
0003 //  Boost Software License, Version 1.0. (See accompanying file
0004 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_MATH_ELLINT_HL_HPP
0007 #define BOOST_MATH_ELLINT_HL_HPP
0008 
0009 #ifdef _MSC_VER
0010 #pragma once
0011 #endif
0012 
0013 #include <boost/math/special_functions/math_fwd.hpp>
0014 #include <boost/math/special_functions/ellint_rj.hpp>
0015 #include <boost/math/special_functions/ellint_1.hpp>
0016 #include <boost/math/special_functions/jacobi_zeta.hpp>
0017 #include <boost/math/constants/constants.hpp>
0018 #include <boost/math/policies/error_handling.hpp>
0019 #include <boost/math/tools/workaround.hpp>
0020 
0021 // Elliptic integral the Jacobi Zeta function.
0022 
0023 namespace boost { namespace math { 
0024    
0025 namespace detail{
0026 
0027 // Elliptic integral - Jacobi Zeta
0028 template <typename T, typename Policy>
0029 T heuman_lambda_imp(T phi, T k, const Policy& pol)
0030 {
0031     BOOST_MATH_STD_USING
0032     using namespace boost::math::tools;
0033     using namespace boost::math::constants;
0034 
0035     const char* function = "boost::math::heuman_lambda<%1%>(%1%, %1%)";
0036 
0037     if(fabs(k) > 1)
0038        return policies::raise_domain_error<T>(function, "We require |k| <= 1 but got k = %1%", k, pol);
0039 
0040     T result;
0041     T sinp = sin(phi);
0042     T cosp = cos(phi);
0043     T s2 = sinp * sinp;
0044     T k2 = k * k;
0045     T kp = 1 - k2;
0046     T delta = sqrt(1 - (kp * s2));
0047     if(fabs(phi) <= constants::half_pi<T>())
0048     {
0049        result = kp * sinp * cosp / (delta * constants::half_pi<T>());
0050        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);
0051     }
0052     else
0053     {
0054           typedef std::integral_constant<int,
0055              std::is_floating_point<T>::value&& std::numeric_limits<T>::digits && (std::numeric_limits<T>::digits <= 54) ? 0 :
0056              std::is_floating_point<T>::value && std::numeric_limits<T>::digits && (std::numeric_limits<T>::digits <= 64) ? 1 : 2
0057           > precision_tag_type;
0058 
0059        T rkp = sqrt(kp);
0060        T ratio;
0061        if(rkp == 1)
0062        {
0063           return policies::raise_domain_error<T>(function, "When 1-k^2 == 1 then phi must be < Pi/2, but got phi = %1%", phi, pol);
0064        }
0065        else
0066           ratio = ellint_f_imp(phi, rkp, pol) / ellint_k_imp(rkp, pol, precision_tag_type());
0067        result = ratio + ellint_k_imp(k, pol, precision_tag_type()) * jacobi_zeta_imp(phi, rkp, pol) / constants::half_pi<T>();
0068     }
0069     return result;
0070 }
0071 
0072 } // detail
0073 
0074 template <class T1, class T2, class Policy>
0075 inline typename tools::promote_args<T1, T2>::type heuman_lambda(T1 k, T2 phi, const Policy& pol)
0076 {
0077    typedef typename tools::promote_args<T1, T2>::type result_type;
0078    typedef typename policies::evaluation<result_type, Policy>::type value_type;
0079    return policies::checked_narrowing_cast<result_type, Policy>(detail::heuman_lambda_imp(static_cast<value_type>(phi), static_cast<value_type>(k), pol), "boost::math::heuman_lambda<%1%>(%1%,%1%)");
0080 }
0081 
0082 template <class T1, class T2>
0083 inline typename tools::promote_args<T1, T2>::type heuman_lambda(T1 k, T2 phi)
0084 {
0085    return boost::math::heuman_lambda(k, phi, policies::policy<>());
0086 }
0087 
0088 }} // namespaces
0089 
0090 #endif // BOOST_MATH_ELLINT_D_HPP
0091