about summary refs log tree commit diff
path: root/math/s_ctanh_template.c
diff options
context:
space:
mode:
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>2016-06-28 11:06:42 -0500
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>2016-08-19 16:47:31 -0500
commitd5602cebf1ff25ef34298a52209283879609ec16 (patch)
tree6d48955e25b06314b107b9484ae008d8b1a2c374 /math/s_ctanh_template.c
parentf6d3a72eca7558e3c52cecc8484665399eeea626 (diff)
downloadglibc-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_ctanh_template.c')
-rw-r--r--math/s_ctanh_template.c69
1 files changed, 35 insertions, 34 deletions
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