Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 ///////////////////////////////////////////////////////////////////////////////
0003 //  Copyright 2018 John Maddock
0004 //  Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 //
0008 #ifndef BOOST_MATH_HYPERGEOMETRIC_1F1_CF_HPP
0009 #define BOOST_MATH_HYPERGEOMETRIC_1F1_CF_HPP
0010 
0011 #include <boost/math/tools/fraction.hpp>
0012 
0013 //
0014 // Evaluation of 1F1 by continued fraction
0015 // see http://functions.wolfram.com/HypergeometricFunctions/Hypergeometric1F1/10/0002/
0016 //
0017 // This is not terribly useful, as like the series we're adding a something to 1,
0018 // so only really useful when we know that the result will be > 1.
0019 //
0020 
0021 
0022   namespace boost { namespace math { namespace detail {
0023 
0024      template <class T>
0025      struct hypergeometric_1F1_cf_func
0026      {
0027         typedef std::pair<T, T>  result_type;
0028         hypergeometric_1F1_cf_func(T a_, T b_, T z_) : a(a_), b(b_), z(z_), k(0) {}
0029         std::pair<T, T> operator()()
0030         {
0031            ++k;
0032            return std::make_pair(-(((a + k) * z) / ((k + 1) * (b + k))), 1 + ((a + k) * z) / ((k + 1) * (b + k)));
0033         }
0034         T a, b, z;
0035         unsigned k;
0036      };
0037 
0038      template <class T, class Policy>
0039      T hypergeometric_1F1_cf(const T& a, const T& b, const T& z, const Policy& pol, const char* function)
0040      {
0041         hypergeometric_1F1_cf_func<T> func(a, b, z);
0042         std::uintmax_t max_iter = boost::math::policies::get_max_series_iterations<Policy>();
0043         T result = boost::math::tools::continued_fraction_a(func, boost::math::policies::get_epsilon<T, Policy>(), max_iter);
0044         boost::math::policies::check_series_iterations<T>(function, max_iter, pol);
0045         return 1 + a * z / (b * (1 + result));
0046      }
0047 
0048   } } } // namespaces
0049 
0050 #endif // BOOST_MATH_HYPERGEOMETRIC_1F1_BESSEL_HPP