Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 //  Copyright 2014 Anton Bikineev
0003 //  Copyright 2014 Christopher Kormanyos
0004 //  Copyright 2014 John Maddock
0005 //  Copyright 2014 Paul Bristow
0006 //  Distributed under the Boost
0007 //  Software License, Version 1.0. (See accompanying file
0008 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 #ifndef BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP
0011 #define BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP
0012 
0013   namespace boost { namespace math { namespace detail {
0014 
0015   template <class T, class Policy>
0016   inline T hypergeometric_1F1_separated_series(const T& a, const T& b, const T& z, const Policy& pol)
0017   {
0018     BOOST_MATH_STD_USING
0019 
0020     std::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
0021     const T factor = policies::get_epsilon<T, Policy>();
0022 
0023     T denom = 1, numer = 1;
0024     T intermediate_result = 1, result = 1;
0025     T a_pochhammer = a, z_pow = z;
0026     unsigned N = 0;
0027     while (--max_iter)
0028     {
0029       ++N;
0030       const T mult = (((b + N) - 1) * N);
0031       denom *= mult; numer *= mult;
0032       numer += a_pochhammer * z_pow;
0033 
0034       result = numer / denom;
0035 
0036       if (fabs(factor * result) > fabs(result - intermediate_result))
0037         break;
0038 
0039       intermediate_result = result;
0040 
0041       a_pochhammer *= (a + N);
0042       z_pow *= z;
0043     }
0044 
0045     return result;
0046   }
0047 
0048   } } } // namespaces
0049 
0050 #endif // BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP