diff options
30 files changed, 246 insertions, 1860 deletions
diff --git a/ChangeLog b/ChangeLog index 4ae38e36f6..75840baef9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,41 @@ 2016-08-19 Paul E. Murphy <murphyp@linux.vnet.ibm.com> + * math/Makefile (libm-gen-calls): Add + catan, catanh, ctan, ctanh. + (libm-calls): Remove the above. + + * math/s_catan_template.c: Update using type-generic macros. + * math/s_catanh_template.c: Likewise. + * math/s_ctan_template.c: Likewise. + * math/s_ctanh_template.c: Likewise. + + * math/s_catanf.c: Removed. + * math/s_catan.c: Removed. + * math/s_catanl.c: Removed. + * math/s_catanhf.c: Removed. + * math/s_catanh.c: Removed. + * math/s_catanhl.c: Removed. + * math/s_ctanf.c: Removed. + * math/s_ctan.c: Removed. + * math/s_ctanl.c: Removed. + * math/s_ctanhf.c: Removed. + * math/s_ctanh.c: Removed. + * math/s_ctanhl.c: Removed. + + * sysdeps/ieee754/ldbl-opt/s_catanhl.c: Removed. + * sysdeps/ieee754/ldbl-opt/s_catanl.c: Removed. + * sysdeps/ieee754/ldbl-opt/s_ctan.c: Removed. + * sysdeps/ieee754/ldbl-opt/s_ctanh.c: Removed. + * sysdeps/ieee754/ldbl-opt/s_ctanhl.c: Removed. + * sysdeps/ieee754/ldbl-opt/s_ctanl.c: Removed. + + * sysdeps/alpha/fpu/s_catanf.c: Update to use template file. + * sysdeps/alpha/fpu/s_catanhf.c: Likewise. + * sysdeps/alpha/fpu/s_ctanf.c: Likewise. + * sysdeps/alpha/fpu/s_ctanhf.c: Likewise. + +2016-08-19 Paul E. Murphy <murphyp@linux.vnet.ibm.com> + * s_catan_template.c: Copy of s_catan.c. * s_catanh_template.c: Copy of s_catanh.c. * s_ctan_template.c: Copy of s_ctan.c. diff --git a/math/Makefile b/math/Makefile index 8873a9eeab..03cbd1d4a9 100644 --- a/math/Makefile +++ b/math/Makefile @@ -47,7 +47,8 @@ libm-support = s_lib_version s_matherr s_signgam \ # <func>_template.c and the appropriate math-type-macros-<TYPE>.h. gen-libm-calls = cargF conjF cimagF crealF cabsF s_cacosF \ s_cacoshF s_ccosF s_ccoshF s_casinF s_csinF s_casinhF \ - k_casinhF s_csinhF + k_casinhF s_csinhF k_casinhF s_csinhF s_catanhF s_catanF \ + s_ctanF s_ctanhF libm-calls = \ e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \ @@ -66,8 +67,7 @@ libm-calls = \ s_fpclassifyF s_fmaxF s_fminF s_fdimF s_nanF s_truncF \ s_remquoF e_log2F e_exp2F s_roundF s_nearbyintF s_sincosF \ s_cexpF s_clogF \ - s_catanF s_ctanF s_ctanhF \ - s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F \ + s_csqrtF s_cpowF s_cprojF s_clog10F \ s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F \ s_issignalingF $(calls:s_%=m_%) x2y2m1F \ gamma_productF lgamma_negF lgamma_productF \ diff --git a/math/s_catan.c b/math/s_catan.c deleted file mode 100644 index 5ab4c0d635..0000000000 --- a/math/s_catan.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Return arc tangent of complex double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ double -__catan (__complex__ double x) -{ - __complex__ double res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (rcls == FP_INFINITE) - { - __real__ res = __copysign (M_PI_2, __real__ x); - __imag__ res = __copysign (0.0, __imag__ x); - } - else if (icls == FP_INFINITE) - { - if (rcls >= FP_ZERO) - __real__ res = __copysign (M_PI_2, __real__ x); - else - __real__ res = __nan (""); - __imag__ res = __copysign (0.0, __imag__ x); - } - else if (icls == FP_ZERO || icls == FP_INFINITE) - { - __real__ res = __nan (""); - __imag__ res = __copysign (0.0, __imag__ x); - } - else - { - __real__ res = __nan (""); - __imag__ res = __nan (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabs (__real__ x) >= 16.0 / DBL_EPSILON - || fabs (__imag__ x) >= 16.0 / DBL_EPSILON) - { - __real__ res = __copysign (M_PI_2, __real__ x); - if (fabs (__real__ x) <= 1.0) - __imag__ res = 1.0 / __imag__ x; - else if (fabs (__imag__ x) <= 1.0) - __imag__ res = __imag__ x / __real__ x / __real__ x; - else - { - double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0); - __imag__ res = __imag__ x / h / h / 4.0; - } - } - else - { - double den, absx, absy; - - absx = fabs (__real__ x); - absy = fabs (__imag__ x); - if (absx < absy) - { - double t = absx; - absx = absy; - absy = t; - } - - if (absy < DBL_EPSILON / 2.0) - { - den = (1.0 - absx) * (1.0 + absx); - if (den == -0.0) - den = 0.0; - } - else if (absx >= 1.0) - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - else if (absx >= 0.75 || absy >= 0.5) - den = -__x2y2m1 (absx, absy); - else - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - - __real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den); - - if (fabs (__imag__ x) == 1.0 - && fabs (__real__ x) < DBL_EPSILON * DBL_EPSILON) - __imag__ res = (__copysign (0.5, __imag__ x) - * (M_LN2 - __ieee754_log (fabs (__real__ x)))); - else - { - double r2 = 0.0, num, f; - - if (fabs (__real__ x) >= DBL_EPSILON * DBL_EPSILON) - r2 = __real__ x * __real__ x; - - num = __imag__ x + 1.0; - num = r2 + num * num; - - den = __imag__ x - 1.0; - den = r2 + den * den; - - f = num / den; - if (f < 0.5) - __imag__ res = 0.25 * __ieee754_log (f); - else - { - num = 4.0 * __imag__ x; - __imag__ res = 0.25 * __log1p (num / den); - } - } - } - - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__catan, catan) -#ifdef NO_LONG_DOUBLE -strong_alias (__catan, __catanl) -weak_alias (__catan, catanl) -#endif diff --git a/math/s_catan_template.c b/math/s_catan_template.c index 5ab4c0d635..d8db96d46b 100644 --- a/math/s_catan_template.c +++ b/math/s_catan_template.c @@ -1,4 +1,4 @@ -/* Return arc tangent of complex double value. +/* Return arc tangent of complex float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -22,10 +22,10 @@ #include <math_private.h> #include <float.h> -__complex__ double -__catan (__complex__ double x) +CFLOAT +M_DECL_FUNC (__catan) (CFLOAT x) { - __complex__ double res; + CFLOAT res; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); @@ -33,26 +33,26 @@ __catan (__complex__ double x) { if (rcls == FP_INFINITE) { - __real__ res = __copysign (M_PI_2, __real__ x); - __imag__ res = __copysign (0.0, __imag__ x); + __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x); + __imag__ res = M_COPYSIGN (0, __imag__ x); } else if (icls == FP_INFINITE) { if (rcls >= FP_ZERO) - __real__ res = __copysign (M_PI_2, __real__ x); + __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x); else - __real__ res = __nan (""); - __imag__ res = __copysign (0.0, __imag__ x); + __real__ res = M_NAN; + __imag__ res = M_COPYSIGN (0, __imag__ x); } else if (icls == FP_ZERO || icls == FP_INFINITE) { - __real__ res = __nan (""); - __imag__ res = __copysign (0.0, __imag__ x); + __real__ res = M_NAN; + __imag__ res = M_COPYSIGN (0, __imag__ x); } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + __real__ res = M_NAN; + __imag__ res = M_NAN; } } else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) @@ -61,72 +61,73 @@ __catan (__complex__ double x) } else { - if (fabs (__real__ x) >= 16.0 / DBL_EPSILON - || fabs (__imag__ x) >= 16.0 / DBL_EPSILON) + if (M_FABS (__real__ x) >= 16 / M_EPSILON + || M_FABS (__imag__ x) >= 16 / M_EPSILON) { - __real__ res = __copysign (M_PI_2, __real__ x); - if (fabs (__real__ x) <= 1.0) - __imag__ res = 1.0 / __imag__ x; - else if (fabs (__imag__ x) <= 1.0) + __real__ res = M_COPYSIGN (M_MLIT (M_PI_2), __real__ x); + if (M_FABS (__real__ x) <= 1) + __imag__ res = 1 / __imag__ x; + else if (M_FABS (__imag__ x) <= 1) __imag__ res = __imag__ x / __real__ x / __real__ x; else { - double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0); - __imag__ res = __imag__ x / h / h / 4.0; + FLOAT h = M_HYPOT (__real__ x / 2, __imag__ x / 2); + __imag__ res = __imag__ x / h / h / 4; } } else { - double den, absx, absy; + FLOAT den, absx, absy; - absx = fabs (__real__ x); - absy = fabs (__imag__ x); + absx = M_FABS (__real__ x); + absy = M_FABS (__imag__ x); if (absx < absy) { - double t = absx; + FLOAT t = absx; absx = absy; absy = t; } - if (absy < DBL_EPSILON / 2.0) + if (absy < M_EPSILON / 2) { - den = (1.0 - absx) * (1.0 + absx); - if (den == -0.0) - den = 0.0; + den = (1 - absx) * (1 + absx); + if (den == 0) + den = 0; } - else if (absx >= 1.0) - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - else if (absx >= 0.75 || absy >= 0.5) - den = -__x2y2m1 (absx, absy); + else if (absx >= 1) + den = (1 - absx) * (1 + absx) - absy * absy; + else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5)) + den = -M_SUF (__x2y2m1) (absx, absy); else - den = (1.0 - absx) * (1.0 + absx) - absy * absy; + den = (1 - absx) * (1 + absx) - absy * absy; - __real__ res = 0.5 * __ieee754_atan2 (2.0 * __real__ x, den); + __real__ res = M_LIT (0.5) * M_ATAN2 (2 * __real__ x, den); - if (fabs (__imag__ x) == 1.0 - && fabs (__real__ x) < DBL_EPSILON * DBL_EPSILON) - __imag__ res = (__copysign (0.5, __imag__ x) - * (M_LN2 - __ieee754_log (fabs (__real__ x)))); + if (M_FABS (__imag__ x) == 1 + && M_FABS (__real__ x) < M_EPSILON * M_EPSILON) + __imag__ res = (M_COPYSIGN (M_LIT (0.5), __imag__ x) + * ((FLOAT) M_MLIT (M_LN2) + - M_LOG (M_FABS (__real__ x)))); else { - double r2 = 0.0, num, f; + FLOAT r2 = 0, num, f; - if (fabs (__real__ x) >= DBL_EPSILON * DBL_EPSILON) + if (M_FABS (__real__ x) >= M_EPSILON * M_EPSILON) r2 = __real__ x * __real__ x; - num = __imag__ x + 1.0; + num = __imag__ x + 1; num = r2 + num * num; - den = __imag__ x - 1.0; + den = __imag__ x - 1; den = r2 + den * den; f = num / den; - if (f < 0.5) - __imag__ res = 0.25 * __ieee754_log (f); + if (f < M_LIT (0.5)) + __imag__ res = M_LIT (0.25) * M_LOG (f); else { - num = 4.0 * __imag__ x; - __imag__ res = 0.25 * __log1p (num / den); + num = 4 * __imag__ x; + __imag__ res = M_LIT (0.25) * M_LOG1P (num / den); } } } @@ -136,8 +137,9 @@ __catan (__complex__ double x) return res; } -weak_alias (__catan, catan) -#ifdef NO_LONG_DOUBLE -strong_alias (__catan, __catanl) -weak_alias (__catan, catanl) + +declare_mgen_alias (__catan, catan) + +#if M_LIBM_NEED_COMPAT (catan) +declare_mgen_libm_compat (__catan, catan) #endif diff --git a/math/s_catanf.c b/math/s_catanf.c deleted file mode 100644 index 63e6b6e703..0000000000 --- a/math/s_catanf.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Return arc tangent of complex float value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ float -__catanf (__complex__ float x) -{ - __complex__ float res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (rcls == FP_INFINITE) - { - __real__ res = __copysignf (M_PI_2, __real__ x); - __imag__ res = __copysignf (0.0, __imag__ x); - } - else if (icls == FP_INFINITE) - { - if (rcls >= FP_ZERO) - __real__ res = __copysignf (M_PI_2, __real__ x); - else - __real__ res = __nanf (""); - __imag__ res = __copysignf (0.0, __imag__ x); - } - else if (icls == FP_ZERO || icls == FP_INFINITE) - { - __real__ res = __nanf (""); - __imag__ res = __copysignf (0.0, __imag__ x); - } - else - { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabsf (__real__ x) >= 16.0f / FLT_EPSILON - || fabsf (__imag__ x) >= 16.0f / FLT_EPSILON) - { - __real__ res = __copysignf ((float) M_PI_2, __real__ x); - if (fabsf (__real__ x) <= 1.0f) - __imag__ res = 1.0f / __imag__ x; - else if (fabsf (__imag__ x) <= 1.0f) - __imag__ res = __imag__ x / __real__ x / __real__ x; - else - { - float h = __ieee754_hypotf (__real__ x / 2.0f, - __imag__ x / 2.0f); - __imag__ res = __imag__ x / h / h / 4.0f; - } - } - else - { - float den, absx, absy; - - absx = fabsf (__real__ x); - absy = fabsf (__imag__ x); - if (absx < absy) - { - float t = absx; - absx = absy; - absy = t; - } - - if (absy < FLT_EPSILON / 2.0f) - { - den = (1.0f - absx) * (1.0f + absx); - if (den == -0.0f) - den = 0.0f; - } - else if (absx >= 1.0f) - den = (1.0f - absx) * (1.0f + absx) - absy * absy; - else if (absx >= 0.75f || absy >= 0.5f) - den = -__x2y2m1f (absx, absy); - else - den = (1.0f - absx) * (1.0f + absx) - absy * absy; - - __real__ res = 0.5f * __ieee754_atan2f (2.0f * __real__ x, den); - - if (fabsf (__imag__ x) == 1.0f - && fabsf (__real__ x) < FLT_EPSILON * FLT_EPSILON) - __imag__ res = (__copysignf (0.5f, __imag__ x) - * ((float) M_LN2 - - __ieee754_logf (fabsf (__real__ x)))); - else - { - float r2 = 0.0f, num, f; - - if (fabsf (__real__ x) >= FLT_EPSILON * FLT_EPSILON) - r2 = __real__ x * __real__ x; - - num = __imag__ x + 1.0f; - num = r2 + num * num; - - den = __imag__ x - 1.0f; - den = r2 + den * den; - - f = num / den; - if (f < 0.5f) - __imag__ res = 0.25f * __ieee754_logf (f); - else - { - num = 4.0f * __imag__ x; - __imag__ res = 0.25f * __log1pf (num / den); - } - } - } - - math_check_force_underflow_complex (res); - } - - return res; -} -#ifndef __catanf -weak_alias (__catanf, catanf) -#endif diff --git a/math/s_catanh.c b/math/s_catanh.c deleted file mode 100644 index 11ea06246e..0000000000 --- a/math/s_catanh.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Return arc hyperbole tangent for double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ double -__catanh (__complex__ double x) -{ - __complex__ double res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (icls == FP_INFINITE) - { - __real__ res = __copysign (0.0, __real__ x); - __imag__ res = __copysign (M_PI_2, __imag__ x); - } - else if (rcls == FP_INFINITE || rcls == FP_ZERO) - { - __real__ res = __copysign (0.0, __real__ x); - if (icls >= FP_ZERO) - __imag__ res = __copysign (M_PI_2, __imag__ x); - else - __imag__ res = __nan (""); - } - else - { - __real__ res = __nan (""); - __imag__ res = __nan (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabs (__real__ x) >= 16.0 / DBL_EPSILON - || fabs (__imag__ x) >= 16.0 / DBL_EPSILON) - { - __imag__ res = __copysign (M_PI_2, __imag__ x); - if (fabs (__imag__ x) <= 1.0) - __real__ res = 1.0 / __real__ x; - else if (fabs (__real__ x) <= 1.0) - __real__ res = __real__ x / __imag__ x / __imag__ x; - else - { - double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0); - __real__ res = __real__ x / h / h / 4.0; - } - } - else - { - if (fabs (__real__ x) == 1.0 - && fabs (__imag__ x) < DBL_EPSILON * DBL_EPSILON) - __real__ res = (__copysign (0.5, __real__ x) - * (M_LN2 - __ieee754_log (fabs (__imag__ x)))); - else - { - double i2 = 0.0; - if (fabs (__imag__ x) >= DBL_EPSILON * DBL_EPSILON) - i2 = __imag__ x * __imag__ x; - - double num = 1.0 + __real__ x; - num = i2 + num * num; - - double den = 1.0 - __real__ x; - den = i2 + den * den; - - double f = num / den; - if (f < 0.5) - __real__ res = 0.25 * __ieee754_log (f); - else - { - num = 4.0 * __real__ x; - __real__ res = 0.25 * __log1p (num / den); - } - } - - double absx, absy, den; - - absx = fabs (__real__ x); - absy = fabs (__imag__ x); - if (absx < absy) - { - double t = absx; - absx = absy; - absy = t; - } - - if (absy < DBL_EPSILON / 2.0) - { - den = (1.0 - absx) * (1.0 + absx); - if (den == -0.0) - den = 0.0; - } - else if (absx >= 1.0) - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - else if (absx >= 0.75 || absy >= 0.5) - den = -__x2y2m1 (absx, absy); - else - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - - __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den); - } - - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__catanh, catanh) -#ifdef NO_LONG_DOUBLE -strong_alias (__catanh, __catanhl) -weak_alias (__catanh, catanhl) -#endif diff --git a/math/s_catanh_template.c b/math/s_catanh_template.c index 11ea06246e..0669c4c1f8 100644 --- a/math/s_catanh_template.c +++ b/math/s_catanh_template.c @@ -1,4 +1,4 @@ -/* Return arc hyperbole tangent for double value. +/* Return arc hyperbolic tangent for a complex float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -22,10 +22,10 @@ #include <math_private.h> #include <float.h> -__complex__ double -__catanh (__complex__ double x) +CFLOAT +M_DECL_FUNC (__catanh) (CFLOAT x) { - __complex__ double res; + CFLOAT res; int rcls = fpclassify (__real__ x); int icls = fpclassify (__imag__ x); @@ -33,21 +33,21 @@ __catanh (__complex__ double x) { if (icls == FP_INFINITE) { - __real__ res = __copysign (0.0, __real__ x); - __imag__ res = __copysign (M_PI_2, __imag__ x); + __real__ res = M_COPYSIGN (0, __real__ x); + __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x); } else if (rcls == FP_INFINITE || rcls == FP_ZERO) { - __real__ res = __copysign (0.0, __real__ x); + __real__ res = M_COPYSIGN (0, __real__ x); if (icls >= FP_ZERO) - __imag__ res = __copysign (M_PI_2, __imag__ x); + __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x); else - __imag__ res = __nan (""); + __imag__ res = M_NAN; } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + __real__ res = M_NAN; + __imag__ res = M_NAN; } } else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) @@ -56,73 +56,74 @@ __catanh (__complex__ double x) } else { - if (fabs (__real__ x) >= 16.0 / DBL_EPSILON - || fabs (__imag__ x) >= 16.0 / DBL_EPSILON) + if (M_FABS (__real__ x) >= 16 / M_EPSILON + || M_FABS (__imag__ x) >= 16 / M_EPSILON) { - __imag__ res = __copysign (M_PI_2, __imag__ x); - if (fabs (__imag__ x) <= 1.0) - __real__ res = 1.0 / __real__ x; - else if (fabs (__real__ x) <= 1.0) + __imag__ res = M_COPYSIGN (M_MLIT (M_PI_2), __imag__ x); + if (M_FABS (__imag__ x) <= 1) + __real__ res = 1 / __real__ x; + else if (M_FABS (__real__ x) <= 1) __real__ res = __real__ x / __imag__ x / __imag__ x; else { - double h = __ieee754_hypot (__real__ x / 2.0, __imag__ x / 2.0); - __real__ res = __real__ x / h / h / 4.0; + FLOAT h = M_HYPOT (__real__ x / 2, __imag__ x / 2); + __real__ res = __real__ x / h / h / 4; } } else { - if (fabs (__real__ x) == 1.0 - && fabs (__imag__ x) < DBL_EPSILON * DBL_EPSILON) - __real__ res = (__copysign (0.5, __real__ x) - * (M_LN2 - __ieee754_log (fabs (__imag__ x)))); + if (M_FABS (__real__ x) == 1 + && M_FABS (__imag__ x) < M_EPSILON * M_EPSILON) + __real__ res = (M_COPYSIGN (M_LIT (0.5), __real__ x) + * ((FLOAT) M_MLIT (M_LN2) + - M_LOG (M_FABS (__imag__ x)))); else { - double i2 = 0.0; - if (fabs (__imag__ x) >= DBL_EPSILON * DBL_EPSILON) + FLOAT i2 = 0; + if (M_FABS (__imag__ x) >= M_EPSILON * M_EPSILON) i2 = __imag__ x * __imag__ x; - double num = 1.0 + __real__ x; + FLOAT num = 1 + __real__ x; num = i2 + num * num; - double den = 1.0 - __real__ x; + FLOAT den = 1 - __real__ x; den = i2 + den * den; - double f = num / den; - if (f < 0.5) - __real__ res = 0.25 * __ieee754_log (f); + FLOAT f = num / den; + if (f < M_LIT (0.5)) + __real__ res = M_LIT (0.25) * M_LOG (f); else { - num = 4.0 * __real__ x; - __real__ res = 0.25 * __log1p (num / den); + num = 4 * __real__ x; + __real__ res = M_LIT (0.25) * M_LOG1P (num / den); } } - double absx, absy, den; + FLOAT absx, absy, den; - absx = fabs (__real__ x); - absy = fabs (__imag__ x); + absx = M_FABS (__real__ x); + absy = M_FABS (__imag__ x); if (absx < absy) { - double t = absx; + FLOAT t = absx; absx = absy; absy = t; } - if (absy < DBL_EPSILON / 2.0) + if (absy < M_EPSILON / 2) { - den = (1.0 - absx) * (1.0 + absx); - if (den == -0.0) - den = 0.0; + den = (1 - absx) * (1 + absx); + if (den == 0) + den = 0; } - else if (absx >= 1.0) - den = (1.0 - absx) * (1.0 + absx) - absy * absy; - else if (absx >= 0.75 || absy >= 0.5) - den = -__x2y2m1 (absx, absy); + else if (absx >= 1) + den = (1 - absx) * (1 + absx) - absy * absy; + else if (absx >= M_LIT (0.75) || absy >= M_LIT (0.5)) + den = -M_SUF (__x2y2m1) (absx, absy); else - den = (1.0 - absx) * (1.0 + absx) - absy * absy; + den = (1 - absx) * (1 + absx) - absy * absy; - __imag__ res = 0.5 * __ieee754_atan2 (2.0 * __imag__ x, den); + __imag__ res = M_LIT (0.5) * M_ATAN2 (2 * __imag__ x, den); } math_check_force_underflow_complex (res); @@ -130,8 +131,9 @@ __catanh (__complex__ double x) return res; } -weak_alias (__catanh, catanh) -#ifdef NO_LONG_DOUBLE -strong_alias (__catanh, __catanhl) -weak_alias (__catanh, catanhl) + +declare_mgen_alias (__catanh, catanh) + +#if M_LIBM_NEED_COMPAT (catanh) +declare_mgen_libm_compat (__catanh, catanh) #endif diff --git a/math/s_catanhf.c b/math/s_catanhf.c deleted file mode 100644 index fe43a518fb..0000000000 --- a/math/s_catanhf.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Return arc hyperbole tangent for float value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ float -__catanhf (__complex__ float x) -{ - __complex__ float res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (icls == FP_INFINITE) - { - __real__ res = __copysignf (0.0, __real__ x); - __imag__ res = __copysignf (M_PI_2, __imag__ x); - } - else if (rcls == FP_INFINITE || rcls == FP_ZERO) - { - __real__ res = __copysignf (0.0, __real__ x); - if (icls >= FP_ZERO) - __imag__ res = __copysignf (M_PI_2, __imag__ x); - else - __imag__ res = __nanf (""); - } - else - { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabsf (__real__ x) >= 16.0f / FLT_EPSILON - || fabsf (__imag__ x) >= 16.0f / FLT_EPSILON) - { - __imag__ res = __copysignf ((float) M_PI_2, __imag__ x); - if (fabsf (__imag__ x) <= 1.0f) - __real__ res = 1.0f / __real__ x; - else if (fabsf (__real__ x) <= 1.0f) - __real__ res = __real__ x / __imag__ x / __imag__ x; - else - { - float h = __ieee754_hypotf (__real__ x / 2.0f, - __imag__ x / 2.0f); - __real__ res = __real__ x / h / h / 4.0f; - } - } - else - { - if (fabsf (__real__ x) == 1.0f - && fabsf (__imag__ x) < FLT_EPSILON * FLT_EPSILON) - __real__ res = (__copysignf (0.5f, __real__ x) - * ((float) M_LN2 - - __ieee754_logf (fabsf (__imag__ x)))); - else - { - float i2 = 0.0f; - if (fabsf (__imag__ x) >= FLT_EPSILON * FLT_EPSILON) - i2 = __imag__ x * __imag__ x; - - float num = 1.0f + __real__ x; - num = i2 + num * num; - - float den = 1.0f - __real__ x; - den = i2 + den * den; - - float f = num / den; - if (f < 0.5f) - __real__ res = 0.25f * __ieee754_logf (f); - else - { - num = 4.0f * __real__ x; - __real__ res = 0.25f * __log1pf (num / den); - } - } - - float absx, absy, den; - - absx = fabsf (__real__ x); - absy = fabsf (__imag__ x); - if (absx < absy) - { - float t = absx; - absx = absy; - absy = t; - } - - if (absy < FLT_EPSILON / 2.0f) - { - den = (1.0f - absx) * (1.0f + absx); - if (den == -0.0f) - den = 0.0f; - } - else if (absx >= 1.0f) - den = (1.0f - absx) * (1.0f + absx) - absy * absy; - else if (absx >= 0.75f || absy >= 0.5f) - den = -__x2y2m1f (absx, absy); - else - den = (1.0f - absx) * (1.0f + absx) - absy * absy; - - __imag__ res = 0.5f * __ieee754_atan2f (2.0f * __imag__ x, den); - } - - math_check_force_underflow_complex (res); - } - - return res; -} -#ifndef __catanhf -weak_alias (__catanhf, catanhf) -#endif diff --git a/math/s_catanhl.c b/math/s_catanhl.c deleted file mode 100644 index 4c8e8711ab..0000000000 --- a/math/s_catanhl.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Return arc hyperbole tangent for long double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -/* To avoid spurious overflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -__complex__ long double -__catanhl (__complex__ long double x) -{ - __complex__ long double res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (icls == FP_INFINITE) - { - __real__ res = __copysignl (0.0, __real__ x); - __imag__ res = __copysignl (M_PI_2l, __imag__ x); - } - else if (rcls == FP_INFINITE || rcls == FP_ZERO) - { - __real__ res = __copysignl (0.0, __real__ x); - if (icls >= FP_ZERO) - __imag__ res = __copysignl (M_PI_2l, __imag__ x); - else - __imag__ res = __nanl (""); - } - else - { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabsl (__real__ x) >= 16.0L / LDBL_EPSILON - || fabsl (__imag__ x) >= 16.0L / LDBL_EPSILON) - { - __imag__ res = __copysignl (M_PI_2l, __imag__ x); - if (fabsl (__imag__ x) <= 1.0L) - __real__ res = 1.0L / __real__ x; - else if (fabsl (__real__ x) <= 1.0L) - __real__ res = __real__ x / __imag__ x / __imag__ x; - else - { - long double h = __ieee754_hypotl (__real__ x / 2.0L, - __imag__ x / 2.0L); - __real__ res = __real__ x / h / h / 4.0L; - } - } - else - { - if (fabsl (__real__ x) == 1.0L - && fabsl (__imag__ x) < LDBL_EPSILON * LDBL_EPSILON) - __real__ res = (__copysignl (0.5L, __real__ x) - * (M_LN2l - __ieee754_logl (fabsl (__imag__ x)))); - else - { - long double i2 = 0.0; - if (fabsl (__imag__ x) >= LDBL_EPSILON * LDBL_EPSILON) - i2 = __imag__ x * __imag__ x; - - long double num = 1.0L + __real__ x; - num = i2 + num * num; - - long double den = 1.0L - __real__ x; - den = i2 + den * den; - - long double f = num / den; - if (f < 0.5L) - __real__ res = 0.25L * __ieee754_logl (f); - else - { - num = 4.0L * __real__ x; - __real__ res = 0.25L * __log1pl (num / den); - } - } - - long double absx, absy, den; - - absx = fabsl (__real__ x); - absy = fabsl (__imag__ x); - if (absx < absy) - { - long double t = absx; - absx = absy; - absy = t; - } - - if (absy < LDBL_EPSILON / 2.0L) - { - den = (1.0L - absx) * (1.0L + absx); - if (den == -0.0L) - den = 0.0L; - } - else if (absx >= 1.0L) - den = (1.0L - absx) * (1.0L + absx) - absy * absy; - else if (absx >= 0.75L || absy >= 0.5L) - den = -__x2y2m1l (absx, absy); - else - den = (1.0L - absx) * (1.0L + absx) - absy * absy; - - __imag__ res = 0.5L * __ieee754_atan2l (2.0L * __imag__ x, den); - } - - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__catanhl, catanhl) diff --git a/math/s_catanl.c b/math/s_catanl.c deleted file mode 100644 index 4425002599..0000000000 --- a/math/s_catanl.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Return arc tangent of complex long double value. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -/* To avoid spurious overflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -__complex__ long double -__catanl (__complex__ long double x) -{ - __complex__ long double res; - int rcls = fpclassify (__real__ x); - int icls = fpclassify (__imag__ x); - - if (__glibc_unlikely (rcls <= FP_INFINITE || icls <= FP_INFINITE)) - { - if (rcls == FP_INFINITE) - { - __real__ res = __copysignl (M_PI_2l, __real__ x); - __imag__ res = __copysignl (0.0, __imag__ x); - } - else if (icls == FP_INFINITE) - { - if (rcls >= FP_ZERO) - __real__ res = __copysignl (M_PI_2l, __real__ x); - else - __real__ res = __nanl (""); - __imag__ res = __copysignl (0.0, __imag__ x); - } - else if (icls == FP_ZERO || icls == FP_INFINITE) - { - __real__ res = __nanl (""); - __imag__ res = __copysignl (0.0, __imag__ x); - } - else - { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); - } - } - else if (__glibc_unlikely (rcls == FP_ZERO && icls == FP_ZERO)) - { - res = x; - } - else - { - if (fabsl (__real__ x) >= 16.0L / LDBL_EPSILON - || fabsl (__imag__ x) >= 16.0L / LDBL_EPSILON) - { - __real__ res = __copysignl (M_PI_2l, __real__ x); - if (fabsl (__real__ x) <= 1.0L) - __imag__ res = 1.0L / __imag__ x; - else if (fabsl (__imag__ x) <= 1.0L) - __imag__ res = __imag__ x / __real__ x / __real__ x; - else - { - long double h = __ieee754_hypotl (__real__ x / 2.0L, - __imag__ x / 2.0L); - __imag__ res = __imag__ x / h / h / 4.0L; - } - } - else - { - long double den, absx, absy; - - absx = fabsl (__real__ x); - absy = fabsl (__imag__ x); - if (absx < absy) - { - long double t = absx; - absx = absy; - absy = t; - } - - if (absy < LDBL_EPSILON / 2.0L) - { - den = (1.0L - absx) * (1.0L + absx); - if (den == -0.0L) - den = 0.0L; - } - else if (absx >= 1.0L) - den = (1.0L - absx) * (1.0L + absx) - absy * absy; - 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); - - if (fabsl (__imag__ x) == 1.0L - && fabsl (__real__ x) < LDBL_EPSILON * LDBL_EPSILON) - __imag__ res = (__copysignl (0.5L, __imag__ x) - * (M_LN2l - __ieee754_logl (fabsl (__real__ x)))); - else - { - long double r2 = 0.0L, num, f; - - if (fabsl (__real__ x) >= LDBL_EPSILON * LDBL_EPSILON) - r2 = __real__ x * __real__ x; - - num = __imag__ x + 1.0L; - num = r2 + num * num; - - den = __imag__ x - 1.0L; - den = r2 + den * den; - - f = num / den; - if (f < 0.5L) - __imag__ res = 0.25L * __ieee754_logl (f); - else - { - num = 4.0L * __imag__ x; - __imag__ res = 0.25L * __log1pl (num / den); - } - } - } - - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__catanl, catanl) diff --git a/math/s_ctan.c b/math/s_ctan.c deleted file mode 100644 index 8e8bf2ee2b..0000000000 --- a/math/s_ctan.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Complex tangent function for double. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ double -__ctan (__complex__ double x) -{ - __complex__ double res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__imag__ x)) - { - if (isfinite (__real__ x) && fabs (__real__ x) > 1.0) - { - double sinrx, cosrx; - __sincos (__real__ x, &sinrx, &cosrx); - __real__ res = __copysign (0.0, sinrx * cosrx); - } - else - __real__ res = __copysign (0.0, __real__ x); - __imag__ res = __copysign (1.0, __imag__ x); - } - else if (__real__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nan (""); - __imag__ res = __nan (""); - - if (isinf (__real__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - double sinrx, cosrx; - double den; - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2); - - /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) - = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - - if (__glibc_likely (fabs (__real__ x) > DBL_MIN)) - { - __sincos (__real__ x, &sinrx, &cosrx); - } - else - { - sinrx = __real__ x; - cosrx = 1.0; - } - - if (fabs (__imag__ x) > t) - { - /* Avoid intermediate overflow when the real part of the - result may be subnormal. Ignoring negligible terms, the - imaginary part is +/- 1, the real part is - sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ - double exp_2t = __ieee754_exp (2 * t); - - __imag__ res = __copysign (1.0, __imag__ x); - __real__ res = 4 * sinrx * cosrx; - __imag__ x = fabs (__imag__ x); - __imag__ x -= t; - __real__ res /= exp_2t; - if (__imag__ x > t) - { - /* Underflow (original imaginary part of x has absolute - value > 2t). */ - __real__ res /= exp_2t; - } - else - __real__ res /= __ieee754_exp (2 * __imag__ x); - } - else - { - double sinhix, coshix; - if (fabs (__imag__ x) > DBL_MIN) - { - sinhix = __ieee754_sinh (__imag__ x); - coshix = __ieee754_cosh (__imag__ x); - } - else - { - sinhix = __imag__ x; - coshix = 1.0; - } - - if (fabs (sinhix) > fabs (cosrx) * DBL_EPSILON) - den = cosrx * cosrx + sinhix * sinhix; - else - den = cosrx * cosrx; - __real__ res = sinrx * cosrx / den; - __imag__ res = sinhix * coshix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__ctan, ctan) -#ifdef NO_LONG_DOUBLE -strong_alias (__ctan, __ctanl) -weak_alias (__ctan, ctanl) -#endif diff --git a/math/s_ctan_template.c b/math/s_ctan_template.c index 8e8bf2ee2b..96efa47465 100644 --- a/math/s_ctan_template.c +++ b/math/s_ctan_template.c @@ -1,4 +1,4 @@ -/* Complex tangent function for double. +/* Complex tangent function for a complex float type. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -23,33 +23,33 @@ #include <math_private.h> #include <float.h> -__complex__ double -__ctan (__complex__ double x) +CFLOAT +M_DECL_FUNC (__ctan) (CFLOAT x) { - __complex__ double res; + CFLOAT res; if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (isinf (__imag__ x)) { - if (isfinite (__real__ x) && fabs (__real__ x) > 1.0) + if (isfinite (__real__ x) && M_FABS (__real__ x) > 1) { - double sinrx, cosrx; - __sincos (__real__ x, &sinrx, &cosrx); - __real__ res = __copysign (0.0, sinrx * cosrx); + FLOAT sinrx, cosrx; + M_SINCOS (__real__ x, &sinrx, &cosrx); + __real__ res = M_COPYSIGN (0, sinrx * cosrx); } else - __real__ res = __copysign (0.0, __real__ x); - __imag__ res = __copysign (1.0, __imag__ x); + __real__ res = M_COPYSIGN (0, __real__ x); + __imag__ res = M_COPYSIGN (1, __imag__ x); } - else if (__real__ x == 0.0) + else if (__real__ x == 0) { res = x; } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + __real__ res = M_NAN; + __imag__ res = M_NAN; if (isinf (__real__ x)) feraiseexcept (FE_INVALID); @@ -57,34 +57,34 @@ __ctan (__complex__ double x) } else { - double sinrx, cosrx; - double den; - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2); + FLOAT sinrx, cosrx; + FLOAT den; + const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2) / 2); /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - if (__glibc_likely (fabs (__real__ x) > DBL_MIN)) + if (__glibc_likely (M_FABS (__real__ x) > M_MIN)) { - __sincos (__real__ x, &sinrx, &cosrx); + M_SINCOS (__real__ x, &sinrx, &cosrx); } else { sinrx = __real__ x; - cosrx = 1.0; + cosrx = 1; } - if (fabs (__imag__ x) > t) + if (M_FABS (__imag__ x) > t) { /* Avoid intermediate overflow when the real part of the result may be subnormal. Ignoring negligible terms, the imaginary part is +/- 1, the real part is sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ - double exp_2t = __ieee754_exp (2 * t); + FLOAT exp_2t = M_EXP (2 * t); - __imag__ res = __copysign (1.0, __imag__ x); + __imag__ res = M_COPYSIGN (1, __imag__ x); __real__ res = 4 * sinrx * cosrx; - __imag__ x = fabs (__imag__ x); + __imag__ x = M_FABS (__imag__ x); __imag__ x -= t; __real__ res /= exp_2t; if (__imag__ x > t) @@ -94,23 +94,23 @@ __ctan (__complex__ double x) __real__ res /= exp_2t; } else - __real__ res /= __ieee754_exp (2 * __imag__ x); + __real__ res /= M_EXP (2 * __imag__ x); } else { - double sinhix, coshix; - if (fabs (__imag__ x) > DBL_MIN) + FLOAT sinhix, coshix; + if (M_FABS (__imag__ x) > M_MIN) { - sinhix = __ieee754_sinh (__imag__ x); - coshix = __ieee754_cosh (__imag__ x); + sinhix = M_SINH (__imag__ x); + coshix = M_COSH (__imag__ x); } else { sinhix = __imag__ x; - coshix = 1.0; + coshix = 1; } - if (fabs (sinhix) > fabs (cosrx) * DBL_EPSILON) + if (M_FABS (sinhix) > M_FABS (cosrx) * M_EPSILON) den = cosrx * cosrx + sinhix * sinhix; else den = cosrx * cosrx; @@ -122,8 +122,9 @@ __ctan (__complex__ double x) return res; } -weak_alias (__ctan, ctan) -#ifdef NO_LONG_DOUBLE -strong_alias (__ctan, __ctanl) -weak_alias (__ctan, ctanl) + +declare_mgen_alias (__ctan, ctan) + +#if M_LIBM_NEED_COMPAT (ctan) +declare_mgen_libm_compat (__ctan, ctan) #endif diff --git a/math/s_ctanf.c b/math/s_ctanf.c deleted file mode 100644 index 0db2c90310..0000000000 --- a/math/s_ctanf.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Complex tangent function for float. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ float -__ctanf (__complex__ float x) -{ - __complex__ float res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__imag__ x)) - { - if (isfinite (__real__ x) && fabsf (__real__ x) > 1.0f) - { - float sinrx, cosrx; - __sincosf (__real__ x, &sinrx, &cosrx); - __real__ res = __copysignf (0.0f, sinrx * cosrx); - } - else - __real__ res = __copysignf (0.0, __real__ x); - __imag__ res = __copysignf (1.0, __imag__ x); - } - else if (__real__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); - - if (isinf (__real__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - float sinrx, cosrx; - float den; - const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2 / 2); - - /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) - = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - - if (__glibc_likely (fabsf (__real__ x) > FLT_MIN)) - { - __sincosf (__real__ x, &sinrx, &cosrx); - } - else - { - sinrx = __real__ x; - cosrx = 1.0f; - } - - if (fabsf (__imag__ x) > t) - { - /* Avoid intermediate overflow when the real part of the - result may be subnormal. Ignoring negligible terms, the - imaginary part is +/- 1, the real part is - sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ - float exp_2t = __ieee754_expf (2 * t); - - __imag__ res = __copysignf (1.0, __imag__ x); - __real__ res = 4 * sinrx * cosrx; - __imag__ x = fabsf (__imag__ x); - __imag__ x -= t; - __real__ res /= exp_2t; - if (__imag__ x > t) - { - /* Underflow (original imaginary part of x has absolute - value > 2t). */ - __real__ res /= exp_2t; - } - else - __real__ res /= __ieee754_expf (2 * __imag__ x); - } - else - { - float sinhix, coshix; - if (fabsf (__imag__ x) > FLT_MIN) - { - sinhix = __ieee754_sinhf (__imag__ x); - coshix = __ieee754_coshf (__imag__ x); - } - else - { - sinhix = __imag__ x; - coshix = 1.0f; - } - - if (fabsf (sinhix) > fabsf (cosrx) * FLT_EPSILON) - den = cosrx * cosrx + sinhix * sinhix; - else - den = cosrx * cosrx; - __real__ res = sinrx * cosrx / den; - __imag__ res = sinhix * coshix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -#ifndef __ctanf -weak_alias (__ctanf, ctanf) -#endif diff --git a/math/s_ctanh.c b/math/s_ctanh.c deleted file mode 100644 index 2d18875c70..0000000000 --- a/math/s_ctanh.c +++ /dev/null @@ -1,129 +0,0 @@ -/* Complex hyperbole tangent for double. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ double -__ctanh (__complex__ double x) -{ - __complex__ double res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__real__ x)) - { - __real__ res = __copysign (1.0, __real__ x); - if (isfinite (__imag__ x) && fabs (__imag__ x) > 1.0) - { - double sinix, cosix; - __sincos (__imag__ x, &sinix, &cosix); - __imag__ res = __copysign (0.0, sinix * cosix); - } - else - __imag__ res = __copysign (0.0, __imag__ x); - } - else if (__imag__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nan (""); - __imag__ res = __nan (""); - - if (isinf (__imag__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - double sinix, cosix; - double den; - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2); - - /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) - = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) - { - __sincos (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - if (fabs (__real__ x) > t) - { - /* Avoid intermediate overflow when the imaginary part of - the result may be subnormal. Ignoring negligible terms, - the real part is +/- 1, the imaginary part is - sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ - double exp_2t = __ieee754_exp (2 * t); - - __real__ res = __copysign (1.0, __real__ x); - __imag__ res = 4 * sinix * cosix; - __real__ x = fabs (__real__ x); - __real__ x -= t; - __imag__ res /= exp_2t; - if (__real__ x > t) - { - /* Underflow (original real part of x has absolute value - > 2t). */ - __imag__ res /= exp_2t; - } - else - __imag__ res /= __ieee754_exp (2 * __real__ x); - } - else - { - double sinhrx, coshrx; - if (fabs (__real__ x) > DBL_MIN) - { - sinhrx = __ieee754_sinh (__real__ x); - coshrx = __ieee754_cosh (__real__ x); - } - else - { - sinhrx = __real__ x; - coshrx = 1.0; - } - - if (fabs (sinhrx) > fabs (cosix) * DBL_EPSILON) - den = sinhrx * sinhrx + cosix * cosix; - else - den = cosix * cosix; - __real__ res = sinhrx * coshrx / den; - __imag__ res = sinix * cosix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__ctanh, ctanh) -#ifdef NO_LONG_DOUBLE -strong_alias (__ctanh, __ctanhl) -weak_alias (__ctanh, ctanhl) -#endif diff --git a/math/s_ctanh_template.c b/math/s_ctanh_template.c index 2d18875c70..a7b7ebc3e2 100644 --- a/math/s_ctanh_template.c +++ b/math/s_ctanh_template.c @@ -1,4 +1,4 @@ -/* Complex hyperbole tangent for double. +/* Complex hyperbolic tangent for float types. Copyright (C) 1997-2016 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. @@ -23,33 +23,33 @@ #include <math_private.h> #include <float.h> -__complex__ double -__ctanh (__complex__ double x) +CFLOAT +M_DECL_FUNC (__ctanh) (CFLOAT x) { - __complex__ double res; + CFLOAT res; if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) { if (isinf (__real__ x)) { - __real__ res = __copysign (1.0, __real__ x); - if (isfinite (__imag__ x) && fabs (__imag__ x) > 1.0) + __real__ res = M_COPYSIGN (1, __real__ x); + if (isfinite (__imag__ x) && M_FABS (__imag__ x) > 1) { - double sinix, cosix; - __sincos (__imag__ x, &sinix, &cosix); - __imag__ res = __copysign (0.0, sinix * cosix); + FLOAT sinix, cosix; + M_SINCOS (__imag__ x, &sinix, &cosix); + __imag__ res = M_COPYSIGN (0, sinix * cosix); } else - __imag__ res = __copysign (0.0, __imag__ x); + __imag__ res = M_COPYSIGN (0, __imag__ x); } - else if (__imag__ x == 0.0) + else if (__imag__ x == 0) { res = x; } else { - __real__ res = __nan (""); - __imag__ res = __nan (""); + __real__ res = M_NAN; + __imag__ res = M_NAN; if (isinf (__imag__ x)) feraiseexcept (FE_INVALID); @@ -57,34 +57,34 @@ __ctanh (__complex__ double x) } else { - double sinix, cosix; - double den; - const int t = (int) ((DBL_MAX_EXP - 1) * M_LN2 / 2); + FLOAT sinix, cosix; + FLOAT den; + const int t = (int) ((M_MAX_EXP - 1) * M_MLIT (M_LN2) / 2); /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - if (__glibc_likely (fabs (__imag__ x) > DBL_MIN)) + if (__glibc_likely (M_FABS (__imag__ x) > M_MIN)) { - __sincos (__imag__ x, &sinix, &cosix); + M_SINCOS (__imag__ x, &sinix, &cosix); } else { sinix = __imag__ x; - cosix = 1.0; + cosix = 1; } - if (fabs (__real__ x) > t) + if (M_FABS (__real__ x) > t) { /* Avoid intermediate overflow when the imaginary part of the result may be subnormal. Ignoring negligible terms, the real part is +/- 1, the imaginary part is sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ - double exp_2t = __ieee754_exp (2 * t); + FLOAT exp_2t = M_EXP (2 * t); - __real__ res = __copysign (1.0, __real__ x); + __real__ res = M_COPYSIGN (1, __real__ x); __imag__ res = 4 * sinix * cosix; - __real__ x = fabs (__real__ x); + __real__ x = M_FABS (__real__ x); __real__ x -= t; __imag__ res /= exp_2t; if (__real__ x > t) @@ -94,23 +94,23 @@ __ctanh (__complex__ double x) __imag__ res /= exp_2t; } else - __imag__ res /= __ieee754_exp (2 * __real__ x); + __imag__ res /= M_EXP (2 * __real__ x); } else { - double sinhrx, coshrx; - if (fabs (__real__ x) > DBL_MIN) + FLOAT sinhrx, coshrx; + if (M_FABS (__real__ x) > M_MIN) { - sinhrx = __ieee754_sinh (__real__ x); - coshrx = __ieee754_cosh (__real__ x); + sinhrx = M_SINH (__real__ x); + coshrx = M_COSH (__real__ x); } else { sinhrx = __real__ x; - coshrx = 1.0; + coshrx = 1; } - if (fabs (sinhrx) > fabs (cosix) * DBL_EPSILON) + if (M_FABS (sinhrx) > M_FABS (cosix) * M_EPSILON) den = sinhrx * sinhrx + cosix * cosix; else den = cosix * cosix; @@ -122,8 +122,9 @@ __ctanh (__complex__ double x) return res; } -weak_alias (__ctanh, ctanh) -#ifdef NO_LONG_DOUBLE -strong_alias (__ctanh, __ctanhl) -weak_alias (__ctanh, ctanhl) + +declare_mgen_alias (__ctanh, ctanh) + +#if M_LIBM_NEED_COMPAT (ctanh) +declare_mgen_libm_compat (__ctanh, ctanh) #endif diff --git a/math/s_ctanhf.c b/math/s_ctanhf.c deleted file mode 100644 index ffe95f635e..0000000000 --- a/math/s_ctanhf.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Complex hyperbole tangent for float. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -__complex__ float -__ctanhf (__complex__ float x) -{ - __complex__ float res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__real__ x)) - { - __real__ res = __copysignf (1.0, __real__ x); - if (isfinite (__imag__ x) && fabsf (__imag__ x) > 1.0f) - { - float sinix, cosix; - __sincosf (__imag__ x, &sinix, &cosix); - __imag__ res = __copysignf (0.0f, sinix * cosix); - } - else - __imag__ res = __copysignf (0.0, __imag__ x); - } - else if (__imag__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nanf (""); - __imag__ res = __nanf (""); - - if (isinf (__imag__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - float sinix, cosix; - float den; - const int t = (int) ((FLT_MAX_EXP - 1) * M_LN2 / 2); - - /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) - = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - - if (__glibc_likely (fabsf (__imag__ x) > FLT_MIN)) - { - __sincosf (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0f; - } - - if (fabsf (__real__ x) > t) - { - /* Avoid intermediate overflow when the imaginary part of - the result may be subnormal. Ignoring negligible terms, - the real part is +/- 1, the imaginary part is - sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ - float exp_2t = __ieee754_expf (2 * t); - - __real__ res = __copysignf (1.0, __real__ x); - __imag__ res = 4 * sinix * cosix; - __real__ x = fabsf (__real__ x); - __real__ x -= t; - __imag__ res /= exp_2t; - if (__real__ x > t) - { - /* Underflow (original real part of x has absolute value - > 2t). */ - __imag__ res /= exp_2t; - } - else - __imag__ res /= __ieee754_expf (2 * __real__ x); - } - else - { - float sinhrx, coshrx; - if (fabsf (__real__ x) > FLT_MIN) - { - sinhrx = __ieee754_sinhf (__real__ x); - coshrx = __ieee754_coshf (__real__ x); - } - else - { - sinhrx = __real__ x; - coshrx = 1.0f; - } - - if (fabsf (sinhrx) > fabsf (cosix) * FLT_EPSILON) - den = sinhrx * sinhrx + cosix * cosix; - else - den = cosix * cosix; - __real__ res = sinhrx * coshrx / den; - __imag__ res = sinix * cosix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -#ifndef __ctanhf -weak_alias (__ctanhf, ctanhf) -#endif diff --git a/math/s_ctanhl.c b/math/s_ctanhl.c deleted file mode 100644 index 3404d0687e..0000000000 --- a/math/s_ctanhl.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Complex hyperbole tangent for long double. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -/* To avoid spurious underflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -__complex__ long double -__ctanhl (__complex__ long double x) -{ - __complex__ long double res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__real__ x)) - { - __real__ res = __copysignl (1.0, __real__ x); - if (isfinite (__imag__ x) && fabsl (__imag__ x) > 1.0L) - { - long double sinix, cosix; - __sincosl (__imag__ x, &sinix, &cosix); - __imag__ res = __copysignl (0.0L, sinix * cosix); - } - else - __imag__ res = __copysignl (0.0, __imag__ x); - } - else if (__imag__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); - - if (isinf (__imag__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - long double sinix, cosix; - long double den; - const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); - - /* tanh(x+iy) = (sinh(2x) + i*sin(2y))/(cosh(2x) + cos(2y)) - = (sinh(x)*cosh(x) + i*sin(y)*cos(y))/(sinh(x)^2 + cos(y)^2). */ - - if (__glibc_likely (fabsl (__imag__ x) > LDBL_MIN)) - { - __sincosl (__imag__ x, &sinix, &cosix); - } - else - { - sinix = __imag__ x; - cosix = 1.0; - } - - if (fabsl (__real__ x) > t) - { - /* Avoid intermediate overflow when the imaginary part of - the result may be subnormal. Ignoring negligible terms, - the real part is +/- 1, the imaginary part is - sin(y)*cos(y)/sinh(x)^2 = 4*sin(y)*cos(y)/exp(2x). */ - long double exp_2t = __ieee754_expl (2 * t); - - __real__ res = __copysignl (1.0, __real__ x); - __imag__ res = 4 * sinix * cosix; - __real__ x = fabsl (__real__ x); - __real__ x -= t; - __imag__ res /= exp_2t; - if (__real__ x > t) - { - /* Underflow (original real part of x has absolute value - > 2t). */ - __imag__ res /= exp_2t; - } - else - __imag__ res /= __ieee754_expl (2 * __real__ x); - } - else - { - long double sinhrx, coshrx; - if (fabsl (__real__ x) > LDBL_MIN) - { - sinhrx = __ieee754_sinhl (__real__ x); - coshrx = __ieee754_coshl (__real__ x); - } - else - { - sinhrx = __real__ x; - coshrx = 1.0L; - } - - if (fabsl (sinhrx) > fabsl (cosix) * LDBL_EPSILON) - den = sinhrx * sinhrx + cosix * cosix; - else - den = cosix * cosix; - __real__ res = sinhrx * coshrx / den; - __imag__ res = sinix * cosix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__ctanhl, ctanhl) diff --git a/math/s_ctanl.c b/math/s_ctanl.c deleted file mode 100644 index d6be22d015..0000000000 --- a/math/s_ctanl.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Complex tangent function for long double. - Copyright (C) 1997-2016 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <http://www.gnu.org/licenses/>. */ - -#include <complex.h> -#include <fenv.h> -#include <math.h> -#include <math_private.h> -#include <float.h> - -/* To avoid spurious underflows, use this definition to treat IBM long - double as approximating an IEEE-style format. */ -#if LDBL_MANT_DIG == 106 -# undef LDBL_EPSILON -# define LDBL_EPSILON 0x1p-106L -#endif - -__complex__ long double -__ctanl (__complex__ long double x) -{ - __complex__ long double res; - - if (__glibc_unlikely (!isfinite (__real__ x) || !isfinite (__imag__ x))) - { - if (isinf (__imag__ x)) - { - if (isfinite (__real__ x) && fabsl (__real__ x) > 1.0L) - { - long double sinrx, cosrx; - __sincosl (__real__ x, &sinrx, &cosrx); - __real__ res = __copysignl (0.0L, sinrx * cosrx); - } - else - __real__ res = __copysignl (0.0, __real__ x); - __imag__ res = __copysignl (1.0, __imag__ x); - } - else if (__real__ x == 0.0) - { - res = x; - } - else - { - __real__ res = __nanl (""); - __imag__ res = __nanl (""); - - if (isinf (__real__ x)) - feraiseexcept (FE_INVALID); - } - } - else - { - long double sinrx, cosrx; - long double den; - const int t = (int) ((LDBL_MAX_EXP - 1) * M_LN2l / 2); - - /* tan(x+iy) = (sin(2x) + i*sinh(2y))/(cos(2x) + cosh(2y)) - = (sin(x)*cos(x) + i*sinh(y)*cosh(y)/(cos(x)^2 + sinh(y)^2). */ - - if (__glibc_likely (fabsl (__real__ x) > LDBL_MIN)) - { - __sincosl (__real__ x, &sinrx, &cosrx); - } - else - { - sinrx = __real__ x; - cosrx = 1.0; - } - - if (fabsl (__imag__ x) > t) - { - /* Avoid intermediate overflow when the real part of the - result may be subnormal. Ignoring negligible terms, the - imaginary part is +/- 1, the real part is - sin(x)*cos(x)/sinh(y)^2 = 4*sin(x)*cos(x)/exp(2y). */ - long double exp_2t = __ieee754_expl (2 * t); - - __imag__ res = __copysignl (1.0, __imag__ x); - __real__ res = 4 * sinrx * cosrx; - __imag__ x = fabsl (__imag__ x); - __imag__ x -= t; - __real__ res /= exp_2t; - if (__imag__ x > t) - { - /* Underflow (original imaginary part of x has absolute - value > 2t). */ - __real__ res /= exp_2t; - } - else - __real__ res /= __ieee754_expl (2 * __imag__ x); - } - else - { - long double sinhix, coshix; - if (fabsl (__imag__ x) > LDBL_MIN) - { - sinhix = __ieee754_sinhl (__imag__ x); - coshix = __ieee754_coshl (__imag__ x); - } - else - { - sinhix = __imag__ x; - coshix = 1.0L; - } - - if (fabsl (sinhix) > fabsl (cosrx) * LDBL_EPSILON) - den = cosrx * cosrx + sinhix * sinhix; - else - den = cosrx * cosrx; - __real__ res = sinrx * cosrx / den; - __imag__ res = sinhix * coshix / den; - } - math_check_force_underflow_complex (res); - } - - return res; -} -weak_alias (__ctanl, ctanl) diff --git a/sysdeps/alpha/fpu/s_catanf.c b/sysdeps/alpha/fpu/s_catanf.c index 76c1718dff..ee2443d4a4 100644 --- a/sysdeps/alpha/fpu/s_catanf.c +++ b/sysdeps/alpha/fpu/s_catanf.c @@ -24,14 +24,18 @@ #undef __catanf #undef catanf -#define __catanf internal_catanf static _Complex float internal_catanf (_Complex float x); -#include <math/s_catanf.c> -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_catanf +#include <math-type-macros-float.h> -#undef __catanf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include <math/s_catan_template.c> +#include "cfloat-compat.h" c1_cfloat_rettype __c1_catanf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_catanhf.c b/sysdeps/alpha/fpu/s_catanhf.c index 18148ddafb..d9f2d2157f 100644 --- a/sysdeps/alpha/fpu/s_catanhf.c +++ b/sysdeps/alpha/fpu/s_catanhf.c @@ -24,14 +24,18 @@ #undef __catanhf #undef catanhf -#define __catanhf internal_catanhf static _Complex float internal_catanhf (_Complex float x); -#include <math/s_catanhf.c> -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_catanhf +#include <math-type-macros-float.h> -#undef __catanhf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include <math/s_catanh_template.c> +#include "cfloat-compat.h" c1_cfloat_rettype __c1_catanhf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_ctanf.c b/sysdeps/alpha/fpu/s_ctanf.c index ee02f31c28..cd5dd910f3 100644 --- a/sysdeps/alpha/fpu/s_ctanf.c +++ b/sysdeps/alpha/fpu/s_ctanf.c @@ -24,14 +24,18 @@ #undef __ctanf #undef ctanf -#define __ctanf internal_ctanf static _Complex float internal_ctanf (_Complex float x); -#include <math/s_ctanf.c> -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_ctanf +#include <math-type-macros-float.h> -#undef __ctanf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include <math/s_ctan_template.c> +#include "cfloat-compat.h" c1_cfloat_rettype __c1_ctanf (c1_cfloat_decl (x)) diff --git a/sysdeps/alpha/fpu/s_ctanhf.c b/sysdeps/alpha/fpu/s_ctanhf.c index cb99279de6..359f053489 100644 --- a/sysdeps/alpha/fpu/s_ctanhf.c +++ b/sysdeps/alpha/fpu/s_ctanhf.c @@ -24,14 +24,18 @@ #undef __ctanhf #undef ctanhf -#define __ctanhf internal_ctanhf static _Complex float internal_ctanhf (_Complex float x); -#include <math/s_ctanhf.c> -#include "cfloat-compat.h" +#define M_DECL_FUNC(f) internal_ctanhf +#include <math-type-macros-float.h> -#undef __ctanhf +/* Disable any aliasing from base template. */ +#undef declare_mgen_alias +#define declare_mgen_alias(__to, __from) + +#include <math/s_ctanh_template.c> +#include "cfloat-compat.h" c1_cfloat_rettype __c1_ctanhf (c1_cfloat_decl (x)) diff --git a/sysdeps/ieee754/ldbl-opt/s_catan.c b/sysdeps/ieee754/ldbl-opt/s_catan.c deleted file mode 100644 index 19f61736d2..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_catan.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#include <math/s_catan.c> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __catan, catanl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_catanh.c b/sysdeps/ieee754/ldbl-opt/s_catanh.c deleted file mode 100644 index cff7861444..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_catanh.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#include <math/s_catanh.c> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __catanh, catanhl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_catanhl.c b/sysdeps/ieee754/ldbl-opt/s_catanhl.c deleted file mode 100644 index e9562825e9..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_catanhl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#undef weak_alias -#define weak_alias(n,a) -#include <math/s_catanhl.c> -long_double_symbol (libm, __catanhl, catanhl); diff --git a/sysdeps/ieee754/ldbl-opt/s_catanl.c b/sysdeps/ieee754/ldbl-opt/s_catanl.c deleted file mode 100644 index ee2fdf5d6c..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_catanl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#undef weak_alias -#define weak_alias(n,a) -#include <math/s_catanl.c> -long_double_symbol (libm, __catanl, catanl); diff --git a/sysdeps/ieee754/ldbl-opt/s_ctan.c b/sysdeps/ieee754/ldbl-opt/s_ctan.c deleted file mode 100644 index a6a21f9f23..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_ctan.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#include <math/s_ctan.c> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __ctan, ctanl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanh.c b/sysdeps/ieee754/ldbl-opt/s_ctanh.c deleted file mode 100644 index fd4be129f8..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_ctanh.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#include <math/s_ctanh.c> -#if LONG_DOUBLE_COMPAT(libm, GLIBC_2_1) -compat_symbol (libm, __ctanh, ctanhl, GLIBC_2_1); -#endif diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanhl.c b/sysdeps/ieee754/ldbl-opt/s_ctanhl.c deleted file mode 100644 index f159373b39..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_ctanhl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#undef weak_alias -#define weak_alias(n,a) -#include <math/s_ctanhl.c> -long_double_symbol (libm, __ctanhl, ctanhl); diff --git a/sysdeps/ieee754/ldbl-opt/s_ctanl.c b/sysdeps/ieee754/ldbl-opt/s_ctanl.c deleted file mode 100644 index 0c2d94cf49..0000000000 --- a/sysdeps/ieee754/ldbl-opt/s_ctanl.c +++ /dev/null @@ -1,6 +0,0 @@ -#include <complex.h> -#include <math_ldbl_opt.h> -#undef weak_alias -#define weak_alias(n,a) -#include <math/s_ctanl.c> -long_double_symbol (libm, __ctanl, ctanl); |