1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-30 22:43:12 +03:00

Fix catan, catanh inaccuracy from atan2 denominators near 0 (bug 15416).

This commit is contained in:
Joseph Myers
2013-04-30 11:27:35 +00:00
parent 6dbe713d85
commit caf84319c1
10 changed files with 909 additions and 14 deletions

View File

@ -85,14 +85,30 @@ __catanl (__complex__ long double x)
}
else
{
long double r2, num, den, f;
long double r2, num, den, f, absx, absy;
r2 = __real__ x * __real__ x;
absx = fabsl (__real__ x);
absy = fabsl (__imag__ x);
if (absx < absy)
{
long double t = absx;
absx = absy;
absy = t;
}
den = 1 - r2 - __imag__ x * __imag__ x;
if (absx >= 1.0L)
den = (1.0L - absx) * (1.0L + absx) - absy * absy;
else if (absx >= 0.75L && absy < LDBL_EPSILON / 2.0L)
den = (1.0L - absx) * (1.0L + absx);
else if (absx >= 0.75L || absy >= 0.5L)
den = -__x2y2m1l (absx, absy);
else
den = (1.0L - absx) * (1.0L + absx) - absy * absy;
__real__ res = 0.5L * __ieee754_atan2l (2.0L * __real__ x, den);
r2 = __real__ x * __real__ x;
num = __imag__ x + 1.0L;
num = r2 + num * num;