mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
betainc edge case checks at start of calculation
libeigen/eigen!2123 Closes #2359
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
afb4380534
commit
752911927f
@@ -1844,14 +1844,15 @@ struct betainc_impl<float> {
|
||||
const float nan = NumTraits<float>::quiet_NaN();
|
||||
float ans, t;
|
||||
|
||||
if (a <= 0.0f) return nan;
|
||||
if (b <= 0.0f) return nan;
|
||||
if ((x <= 0.0f) || (x >= 1.0f)) {
|
||||
if (x == 0.0f) return 0.0f;
|
||||
if (x == 1.0f) return 1.0f;
|
||||
// mtherr("betaincf", DOMAIN);
|
||||
return nan;
|
||||
}
|
||||
if (a == 0.0f && b == 0.0f) return nan;
|
||||
if (x < 0.0f || x > 1.0f) return nan;
|
||||
if (a < 0.0f) return nan;
|
||||
if (b < 0.0f) return nan;
|
||||
if (a == 0.0f) return 1.0f;
|
||||
if (b == 0.0f) return 0.0f;
|
||||
if (x == 0.0f) return 0.0f;
|
||||
if (x == 1.0f) return 1.0f;
|
||||
// mtherr("betaincf", DOMAIN);
|
||||
|
||||
/* transformation for small aa */
|
||||
if (a <= 1.0f) {
|
||||
@@ -1914,16 +1915,15 @@ struct betainc_impl<double> {
|
||||
double a, b, t, x, xc, w, y;
|
||||
bool reversed_a_b = false;
|
||||
|
||||
if (aa <= 0.0 || bb <= 0.0) {
|
||||
return nan; // goto domerr;
|
||||
}
|
||||
|
||||
if ((xx <= 0.0) || (xx >= 1.0)) {
|
||||
if (xx == 0.0) return (0.0);
|
||||
if (xx == 1.0) return (1.0);
|
||||
// mtherr("incbet", DOMAIN);
|
||||
return nan;
|
||||
}
|
||||
if (aa == 0.0 && bb == 0.0) return nan;
|
||||
if (xx < 0.0 || xx > 1.0) return nan;
|
||||
if (aa < 0.0) return nan;
|
||||
if (bb < 0.0) return nan;
|
||||
if (aa == 0.0) return 1.0;
|
||||
if (bb == 0.0) return 0.0;
|
||||
if (xx == 0.0) return 0.0;
|
||||
if (xx == 1.0) return 1.0;
|
||||
// mtherr("incbet", DOMAIN);
|
||||
|
||||
if ((bb * xx) <= 1.0 && xx <= 0.95) {
|
||||
return betainc_helper<double>::incbps(aa, bb, xx);
|
||||
|
||||
Reference in New Issue
Block a user