26#include <ql/math/incompletegamma.hpp>
27#include <ql/math/distributions/gammadistribution.hpp>
35 QL_REQUIRE(a>0.0,
"non-positive a is not allowed");
37 QL_REQUIRE(x>=0.0,
"negative x non allowed");
42 accuracy, maxIteration);
46 accuracy, maxIteration);
55 if (x==0.0)
return 0.0;
61 for (
Integer n=1; n<=maxIteration; n++) {
65 if (std::fabs(del) < std::fabs(sum)*accuracy) {
66 return sum*std::exp(-x+a*std::log(x)-gln);
69 QL_FAIL(
"accuracy not reached");
77 Real an, b, c, d, del, h;
83 for (i=1; i<=maxIteration; i++) {
93 if (std::fabs(del-1.0) < accuracy) {
94 return std::exp(-x+a*std::log(x)-gln)*h;
98 QL_FAIL(
"accuracy not reached");
Real logValue(Real x) const
QL_INTEGER Integer
integer number
Real incompleteGammaFunctionSeriesRepr(Real a, Real x, Real accuracy, Integer maxIteration)
Real incompleteGammaFunction(Real a, Real x, Real accuracy, Integer maxIteration)
Incomplete Gamma function.
Real incompleteGammaFunctionContinuedFractionRepr(Real a, Real x, Real accuracy, Integer maxIteration)