From 3b6c37d48c6ffd7a196fbf96f39dcd62e1781fe0 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 7 Jul 2005 23:46:51 +0000 Subject: [PATCH] * sysdeps/generic/s_ctan.c (__ctan): Likewise. * sysdeps/generic/s_ctanf.c (__ctanf): Likewise. * sysdeps/generic/s_ctanl.c (__ctanl): Likewise. --- ChangeLog | 3 +++ sysdeps/generic/s_ctan.c | 16 +++++++++++++--- sysdeps/generic/s_ctanf.c | 17 ++++++++++++++--- sysdeps/generic/s_ctanl.c | 17 ++++++++++++++--- 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c5daee..6f7ec2d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * sysdeps/generic/s_ctanh.c (__ctanh): Handle case of zero den better. * sysdeps/generic/s_ctanhf.c (__ctanhf): Likewise. * sysdeps/generic/s_ctanhl.c (__ctanhl): Likewise. + * sysdeps/generic/s_ctan.c (__ctan): Likewise. + * sysdeps/generic/s_ctanf.c (__ctanf): Likewise. + * sysdeps/generic/s_ctanl.c (__ctanl): Likewise. 2005-04-13 H.J. Lu diff --git a/sysdeps/generic/s_ctan.c b/sysdeps/generic/s_ctan.c index 6a09fe4..0464ab8 100644 --- a/sysdeps/generic/s_ctan.c +++ b/sysdeps/generic/s_ctan.c @@ -1,5 +1,5 @@ /* Complex tangent function for double. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -61,8 +61,18 @@ __ctan (__complex__ double x) den = cos2rx + __ieee754_cosh (2.0 * __imag__ x); - __real__ res = sin2rx / den; - __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den; + if (den == 0.0) + { + __complex__ double ez = __cexp (1.0i * x); + __complex__ double emz = __cexp (-1.0i * x); + + res = (ez - emz) / (ez + emz) * -1.0i; + } + else + { + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinh (2.0 * __imag__ x) / den; + } } return res; diff --git a/sysdeps/generic/s_ctanf.c b/sysdeps/generic/s_ctanf.c index e02971d..58d9d13 100644 --- a/sysdeps/generic/s_ctanf.c +++ b/sysdeps/generic/s_ctanf.c @@ -1,5 +1,5 @@ /* Complex tangent function for float. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -61,8 +61,19 @@ __ctanf (__complex__ float x) den = cos2rx + __ieee754_coshf (2.0 * __imag__ x); - __real__ res = sin2rx / den; - __imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den; + + if (den == 0.0) + { + __complex__ float ez = __cexpf (1.0i * x); + __complex__ float emz = __cexpf (-1.0i * x); + + res = (ez - emz) / (ez + emz) * -1.0i; + } + else + { + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinhf (2.0 * __imag__ x) / den; + } } return res; diff --git a/sysdeps/generic/s_ctanl.c b/sysdeps/generic/s_ctanl.c index fa153e9..89379a5 100644 --- a/sysdeps/generic/s_ctanl.c +++ b/sysdeps/generic/s_ctanl.c @@ -1,5 +1,5 @@ /* Complex tangent function for long double. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -61,8 +61,19 @@ __ctanl (__complex__ long double x) den = cos2rx + __ieee754_coshl (2.0 * __imag__ x); - __real__ res = sin2rx / den; - __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den; + + if (den == 0.0) + { + __complex__ long double ez = __cexpl (1.0i * x); + __complex__ long double emz = __cexpl (-1.0i * x); + + res = (ez - emz) / (ez + emz) * -1.0i; + } + else + { + __real__ res = sin2rx / den; + __imag__ res = __ieee754_sinhl (2.0 * __imag__ x) / den; + } } return res; -- 2.7.4