Debian Codegraph @

third-party/boost-math/include/boost/math/special_functions/detail/hypergeometric_0F1_bessel.hpp

raw
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)
9 //
10 #ifndef BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP
11 #define BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP
12
13 #include <boost/math/special_functions/bessel.hpp>
14 #include <boost/math/special_functions/gamma.hpp>
15
16 namespace boost { namespace math { namespace detail {
17
18 template <class T, class Policy>
19 inline T hypergeometric_0F1_bessel(const T& b, const T& z, const Policy& pol)
20 {
21 BOOST_MATH_STD_USING
22
23 //const bool is_z_nonpositive = z <= 0;
24 BOOST_MATH_ASSERT(z < 0); // condition used at call site
25
26 const T sqrt_z = sqrt(-z);
27 const T bessel_mult = boost::math::cyl_bessel_j(b - 1, 2 * sqrt_z, pol);
28
29 if (b > boost::math::max_factorial<T>::value)
30 {
31 const T lsqrt_z = log(sqrt_z);
32 const T lsqrt_z_pow_b = (b - 1) * lsqrt_z;
33 T lg = (boost::math::lgamma(b, pol) - lsqrt_z_pow_b);
34 lg = exp(lg);
35 return lg * bessel_mult;
36 }
37 else
38 {
39 const T sqrt_z_pow_b = pow(sqrt_z, b - 1);
40 return (boost::math::tgamma(b, pol) / sqrt_z_pow_b) * bessel_mult;
41 }
42 }
43
44 } } } // namespaces
45
46 #endif // BOOST_MATH_HYPERGEOMETRIC_0F1_BESSEL_HPP