gamma_ratios.qbk 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. [section:gamma_ratios Ratios of Gamma Functions]
  2. ``
  3. #include <boost/math/special_functions/gamma.hpp>
  4. ``
  5. namespace boost{ namespace math{
  6. template <class T1, class T2>
  7. ``__sf_result`` tgamma_ratio(T1 a, T2 b);
  8. template <class T1, class T2, class ``__Policy``>
  9. ``__sf_result`` tgamma_ratio(T1 a, T2 b, const ``__Policy``&);
  10. template <class T1, class T2>
  11. ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta);
  12. template <class T1, class T2, class Policy>
  13. ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta, const ``__Policy``&);
  14. }} // namespaces
  15. [h4 Description]
  16. template <class T1, class T2>
  17. ``__sf_result`` tgamma_ratio(T1 a, T2 b);
  18. template <class T1, class T2, class ``__Policy``>
  19. ``__sf_result`` tgamma_ratio(T1 a, T2 b, const ``__Policy``&);
  20. Returns the ratio of gamma functions:
  21. [equation gamma_ratio0]
  22. [optional_policy]
  23. Internally this just calls `tgamma_delta_ratio(a, b-a)`.
  24. template <class T1, class T2>
  25. ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta);
  26. template <class T1, class T2, class ``__Policy``>
  27. ``__sf_result`` tgamma_delta_ratio(T1 a, T2 delta, const ``__Policy``&);
  28. Returns the ratio of gamma functions:
  29. [equation gamma_ratio1]
  30. [optional_policy]
  31. Note that the result is calculated accurately even when /delta/ is
  32. small compared to /a/: indeed even if /a+delta ~ a/. The function is
  33. typically used when /a/ is large and /delta/ is very small.
  34. The return type of these functions is computed using the __arg_promotion_rules
  35. when T1 and T2 are different types, otherwise the result type is simple T1.
  36. [graph tgamma_delta_ratio]
  37. [h4 Accuracy]
  38. The following table shows the peak errors (in units of epsilon)
  39. found on various platforms with various floating point types.
  40. Unless otherwise specified any floating point type that is narrower
  41. than the one shown will have __zero_error.
  42. [table_tgamma_delta_ratio]
  43. [table_tgamma_ratio]
  44. [h4 Testing]
  45. Accuracy tests use data generated at very high precision
  46. (with [@http://shoup.net/ntl/doc/RR.txt NTL RR class]
  47. set at 1000-bit precision: about 300 decimal digits)
  48. and a deliberately naive calculation of [Gamma](x)/[Gamma](y).
  49. [h4 Implementation]
  50. The implementation of these functions is very similar to that of
  51. __beta, and is based on combining similar power terms
  52. to improve accuracy and avoid spurious overflow/underflow.
  53. In addition there are optimisations for the situation where /delta/
  54. is a small integer: in which case this function is basically
  55. the reciprocal of a rising factorial, or where both arguments
  56. are smallish integers: in which case table lookup of factorials
  57. can be used to calculate the ratio.
  58. [endsect] [/section:gamma_ratios Ratios of Gamma Functions]
  59. [/
  60. Copyright 2006 John Maddock and Paul A. Bristow.
  61. Distributed under the Boost Software License, Version 1.0.
  62. (See accompanying file LICENSE_1_0.txt or copy at
  63. http://www.boost.org/LICENSE_1_0.txt).
  64. ]