File indexing completed on 2025-01-18 09:40:05
0001
0002
0003
0004
0005
0006
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
0015
0016
0017
0018
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 } } }
0049
0050 #endif