diff options
author | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-06-28 11:06:42 -0500 |
---|---|---|
committer | Paul E. Murphy <murphyp@linux.vnet.ibm.com> | 2016-08-19 16:47:31 -0500 |
commit | d5602cebf1ff25ef34298a52209283879609ec16 (patch) | |
tree | 6d48955e25b06314b107b9484ae008d8b1a2c374 /math/s_ctan_template.c | |
parent | f6d3a72eca7558e3c52cecc8484665399eeea626 (diff) | |
download | glibc-d5602cebf1ff25ef34298a52209283879609ec16.tar.gz glibc-d5602cebf1ff25ef34298a52209283879609ec16.tar.xz glibc-d5602cebf1ff25ef34298a52209283879609ec16.zip |
Convert _Complex tangent functions to generated code
This converts s_c{,a}tan{,h}{f,,l} into a single templated file c{,a}tan{,h}_template.c with the exception of alpha.
Diffstat (limited to 'math/s_ctan_template.c')
-rw-r--r-- | math/s_ctan_template.c | 69 |
1 files changed, 35 insertions, 34 deletions
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 |