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