2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-10 23:42:23 +00:00

1F1, asymptotic-z region: don't use logs unless we really have to.

Also don't take this branch when |a| is really small.
This commit is contained in:
jzmaddock
2019-02-16 12:11:49 +00:00
parent e21ebd56c4
commit 00dfd44470

View File

@@ -47,20 +47,27 @@
log_scaling += e;
prefix = exp(z - e);
}
T t = log(z) * (a - b);
e = itrunc(t, pol);
log_scaling += e;
prefix *= exp(t - e);
if ((fabs(a) < 10) && (fabs(b) < 10))
{
prefix *= pow(z, a) * pow(z, -b) * boost::math::tgamma(b, pol) / boost::math::tgamma(a, pol);
}
else
{
T t = log(z) * (a - b);
e = itrunc(t, pol);
log_scaling += e;
prefix *= exp(t - e);
t = boost::math::lgamma(b, &s, pol);
e = itrunc(t, pol);
log_scaling += e;
prefix *= s * exp(t - e);
t = boost::math::lgamma(b, &s, pol);
e = itrunc(t, pol);
log_scaling += e;
prefix *= s * exp(t - e);
t = boost::math::lgamma(a, &s, pol);
e = itrunc(t, pol);
log_scaling -= e;
prefix /= s * exp(t - e);
t = boost::math::lgamma(a, &s, pol);
e = itrunc(t, pol);
log_scaling -= e;
prefix /= s * exp(t - e);
}
//
// Checked 2F0:
//
@@ -105,6 +112,9 @@
int half_digits = policies::digits<T, Policy>() / 2;
bool in_region = false;
if (fabs(a) < 0.001f)
return false; // Haven't been able to make this work, why not? TODO!
//
// We use the following heuristic, if after we have had half_digits terms
// of the 2F0 series, we require terms to be decreasing in size by a factor