summaryrefslogtreecommitdiff
path: root/libquadmath/math/clogq.c
diff options
context:
space:
mode:
Diffstat (limited to 'libquadmath/math/clogq.c')
-rw-r--r--libquadmath/math/clogq.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/libquadmath/math/clogq.c b/libquadmath/math/clogq.c
index 1a772cd434d..b20da52dd28 100644
--- a/libquadmath/math/clogq.c
+++ b/libquadmath/math/clogq.c
@@ -1,5 +1,5 @@
-/* Compute complex natural logarithm for complex __float128.
- Copyright (C) 1997-2012 Free Software Foundation, Inc.
+/* Compute complex natural logarithm.
+ Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -19,7 +19,6 @@
#include "quadmath-imp.h"
-
__complex128
clogq (__complex128 x)
{
@@ -27,15 +26,15 @@ clogq (__complex128 x)
int rcls = fpclassifyq (__real__ x);
int icls = fpclassifyq (__imag__ x);
- if (__builtin_expect (rcls == QUADFP_ZERO && icls == QUADFP_ZERO, 0))
+ if (__glibc_unlikely (rcls == QUADFP_ZERO && icls == QUADFP_ZERO))
{
/* Real and imaginary part are 0.0. */
- __imag__ result = signbitq (__real__ x) ? M_PIq : 0.0Q;
+ __imag__ result = signbitq (__real__ x) ? (__float128) M_PIq : 0;
__imag__ result = copysignq (__imag__ result, __imag__ x);
/* Yes, the following line raises an exception. */
- __real__ result = -1.0Q / fabsq (__real__ x);
+ __real__ result = -1 / fabsq (__real__ x);
}
- else if (__builtin_expect (rcls != QUADFP_NAN && icls != QUADFP_NAN, 1))
+ else if (__glibc_likely (rcls != QUADFP_NAN && icls != QUADFP_NAN))
{
/* Neither real nor imaginary part is NaN. */
__float128 absx = fabsq (__real__ x), absy = fabsq (__imag__ x);
@@ -48,11 +47,11 @@ clogq (__complex128 x)
absy = t;
}
- if (absx > FLT128_MAX / 2.0)
+ if (absx > FLT128_MAX / 2)
{
scale = -1;
absx = scalbnq (absx, scale);
- absy = (absy >= FLT128_MIN * 2.0Q ? scalbnq (absy, scale) : 0.0Q);
+ absy = (absy >= FLT128_MIN * 2 ? scalbnq (absy, scale) : 0);
}
else if (absx < FLT128_MIN && absy < FLT128_MIN)
{
@@ -61,38 +60,38 @@ clogq (__complex128 x)
absy = scalbnq (absy, scale);
}
- if (absx == 1.0Q && scale == 0)
+ if (absx == 1 && scale == 0)
{
- __float128 absy2 = absy * absy;
- if (absy2 <= FLT128_MIN * 2.0Q)
- __real__ result = absy2 / 2.0Q - absy2 * absy2 / 4.0Q;
- else
- __real__ result = log1pq (absy2) / 2.0Q;
+ __real__ result = log1pq (absy * absy) / 2;
+ math_check_force_underflow_nonneg (__real__ result);
}
- else if (absx > 1.0Q && absx < 2.0Q && absy < 1.0Q && scale == 0)
+ else if (absx > 1 && absx < 2 && absy < 1 && scale == 0)
{
- __float128 d2m1 = (absx - 1.0Q) * (absx + 1.0Q);
+ __float128 d2m1 = (absx - 1) * (absx + 1);
if (absy >= FLT128_EPSILON)
d2m1 += absy * absy;
- __real__ result = log1pq (d2m1) / 2.0Q;
+ __real__ result = log1pq (d2m1) / 2;
}
- else if (absx < 1.0Q
- && absx >= 0.75Q
- && absy < FLT128_EPSILON / 2.0Q
+ else if (absx < 1
+ && absx >= 0.5Q
+ && absy < FLT128_EPSILON / 2
&& scale == 0)
{
- __float128 d2m1 = (absx - 1.0Q) * (absx + 1.0Q);
- __real__ result = log1pq (d2m1) / 2.0Q;
+ __float128 d2m1 = (absx - 1) * (absx + 1);
+ __real__ result = log1pq (d2m1) / 2;
}
- else if (absx < 1.0 && (absx >= 0.75Q || absy >= 0.5Q) && scale == 0)
+ else if (absx < 1
+ && absx >= 0.5Q
+ && scale == 0
+ && absx * absx + absy * absy >= 0.5Q)
{
__float128 d2m1 = __quadmath_x2y2m1q (absx, absy);
- __real__ result = log1pq (d2m1) / 2.0Q;
+ __real__ result = log1pq (d2m1) / 2;
}
else
{
__float128 d = hypotq (absx, absy);
- __real__ result = logq (d) - scale * M_LN2q;
+ __real__ result = logq (d) - scale * (__float128) M_LN2q;
}
__imag__ result = atan2q (__imag__ x, __real__ x);