1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2014 Anton Bikineev
3 // Copyright 2014 Christopher Kormanyos
4 // Copyright 2014 John Maddock
5 // Copyright 2014 Paul Bristow
6 // Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP
11 #define BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP
13 #include <boost/math/special_functions/bessel.hpp>
14 #include <boost/math/special_functions/gamma.hpp>
16 namespace boost { namespace math { namespace detail {
18 template <class T, class Policy>
19 inline T hypergeometric_0F1_bessel(const T& b, const T& z, const Policy& pol)
23 const bool is_z_nonpositive = z <= 0;
25 const T sqrt_z = is_z_nonpositive ? T(sqrt(-z)) : T(sqrt(z));
26 const T bessel_mult = is_z_nonpositive ?
27 boost::math::cyl_bessel_j(b - 1, 2 * sqrt_z, pol) :
28 boost::math::cyl_bessel_i(b - 1, 2 * sqrt_z, pol) ;
30 if (b > boost::math::max_factorial<T>::value)
32 const T lsqrt_z = log(sqrt_z);
33 const T lsqrt_z_pow_b = (b - 1) * lsqrt_z;
34 T lg = (boost::math::lgamma(b, pol) - lsqrt_z_pow_b);
36 return lg * bessel_mult;
40 const T sqrt_z_pow_b = pow(sqrt_z, b - 1);
41 return (boost::math::tgamma(b, pol) / sqrt_z_pow_b) * bessel_mult;
47 #endif // BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP