Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:38:42

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