1 // Copyright (c) 2013 Anton Bikineev
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // This is a partial header, do not include on it's own!!!
9 // Linear combination for bessel derivatives are defined here
10 #ifndef BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP
11 #define BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP
17 namespace boost{ namespace math{ namespace detail{
19 template <class T, class Tag, class Policy>
20 inline T bessel_j_derivative_linear(T v, T x, Tag tag, Policy pol)
22 return (boost::math::detail::cyl_bessel_j_imp<T>(v-1, x, tag, pol) - boost::math::detail::cyl_bessel_j_imp<T>(v+1, x, tag, pol)) / 2;
25 template <class T, class Policy>
26 inline T bessel_j_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
28 return (boost::math::detail::cyl_bessel_j_imp<T>(itrunc(v-1), x, tag, pol) - boost::math::detail::cyl_bessel_j_imp<T>(itrunc(v+1), x, tag, pol)) / 2;
31 template <class T, class Policy>
32 inline T sph_bessel_j_derivative_linear(unsigned v, T x, Policy pol)
34 return (v / x) * boost::math::detail::sph_bessel_j_imp<T>(v, x, pol) - boost::math::detail::sph_bessel_j_imp<T>(v+1, x, pol);
37 template <class T, class Policy>
38 inline T bessel_i_derivative_linear(T v, T x, Policy pol)
40 T result = boost::math::detail::cyl_bessel_i_imp<T>(v - 1, x, pol);
41 if(result >= tools::max_value<T>())
42 return result; // result is infinite
43 T result2 = boost::math::detail::cyl_bessel_i_imp<T>(v + 1, x, pol);
44 if(result2 >= tools::max_value<T>() - result)
45 return result2; // result is infinite
46 return (result + result2) / 2;
49 template <class T, class Tag, class Policy>
50 inline T bessel_k_derivative_linear(T v, T x, Tag tag, Policy pol)
52 T result = boost::math::detail::cyl_bessel_k_imp<T>(v - 1, x, tag, pol);
53 if(result >= tools::max_value<T>())
54 return -result; // result is infinite
55 T result2 = boost::math::detail::cyl_bessel_k_imp<T>(v + 1, x, tag, pol);
56 if(result2 >= tools::max_value<T>() - result)
57 return -result2; // result is infinite
58 return (result + result2) / -2;
61 template <class T, class Policy>
62 inline T bessel_k_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
64 return (boost::math::detail::cyl_bessel_k_imp<T>(itrunc(v-1), x, tag, pol) + boost::math::detail::cyl_bessel_k_imp<T>(itrunc(v+1), x, tag, pol)) / -2;
67 template <class T, class Tag, class Policy>
68 inline T bessel_y_derivative_linear(T v, T x, Tag tag, Policy pol)
70 return (boost::math::detail::cyl_neumann_imp<T>(v-1, x, tag, pol) - boost::math::detail::cyl_neumann_imp<T>(v+1, x, tag, pol)) / 2;
73 template <class T, class Policy>
74 inline T bessel_y_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
76 return (boost::math::detail::cyl_neumann_imp<T>(itrunc(v-1), x, tag, pol) - boost::math::detail::cyl_neumann_imp<T>(itrunc(v+1), x, tag, pol)) / 2;
79 template <class T, class Policy>
80 inline T sph_neumann_derivative_linear(unsigned v, T x, Policy pol)
82 return (v / x) * boost::math::detail::sph_neumann_imp<T>(v, x, pol) - boost::math::detail::sph_neumann_imp<T>(v+1, x, pol);
87 #endif // BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP