bessel_derivatives_linear.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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)
  5. //
  6. // This is a partial header, do not include on it's own!!!
  7. //
  8. // Linear combination for bessel derivatives are defined here
  9. #ifndef BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP
  10. #define BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP
  11. #ifdef _MSC_VER
  12. #pragma once
  13. #endif
  14. namespace boost{ namespace math{ namespace detail{
  15. template <class T, class Tag, class Policy>
  16. inline T bessel_j_derivative_linear(T v, T x, Tag tag, Policy pol)
  17. {
  18. 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;
  19. }
  20. template <class T, class Policy>
  21. inline T bessel_j_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
  22. {
  23. 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;
  24. }
  25. template <class T, class Policy>
  26. inline T sph_bessel_j_derivative_linear(unsigned v, T x, Policy pol)
  27. {
  28. 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);
  29. }
  30. template <class T, class Policy>
  31. inline T bessel_i_derivative_linear(T v, T x, Policy pol)
  32. {
  33. T result = boost::math::detail::cyl_bessel_i_imp<T>(v - 1, x, pol);
  34. if(result >= tools::max_value<T>())
  35. return result; // result is infinite
  36. T result2 = boost::math::detail::cyl_bessel_i_imp<T>(v + 1, x, pol);
  37. if(result2 >= tools::max_value<T>() - result)
  38. return result2; // result is infinite
  39. return (result + result2) / 2;
  40. }
  41. template <class T, class Tag, class Policy>
  42. inline T bessel_k_derivative_linear(T v, T x, Tag tag, Policy pol)
  43. {
  44. T result = boost::math::detail::cyl_bessel_k_imp<T>(v - 1, x, tag, pol);
  45. if(result >= tools::max_value<T>())
  46. return -result; // result is infinite
  47. T result2 = boost::math::detail::cyl_bessel_k_imp<T>(v + 1, x, tag, pol);
  48. if(result2 >= tools::max_value<T>() - result)
  49. return -result2; // result is infinite
  50. return (result + result2) / -2;
  51. }
  52. template <class T, class Policy>
  53. inline T bessel_k_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
  54. {
  55. 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;
  56. }
  57. template <class T, class Tag, class Policy>
  58. inline T bessel_y_derivative_linear(T v, T x, Tag tag, Policy pol)
  59. {
  60. 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;
  61. }
  62. template <class T, class Policy>
  63. inline T bessel_y_derivative_linear(T v, T x, const bessel_int_tag& tag, Policy pol)
  64. {
  65. 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;
  66. }
  67. template <class T, class Policy>
  68. inline T sph_neumann_derivative_linear(unsigned v, T x, Policy pol)
  69. {
  70. return (v / x) * boost::math::detail::sph_neumann_imp<T>(v, x, pol) - boost::math::detail::sph_neumann_imp<T>(v+1, x, pol);
  71. }
  72. }}} // namespaces
  73. #endif // BOOST_MATH_SF_DETAIL_BESSEL_DERIVATIVES_LINEAR_HPP