math: add __math_invalidl
[musl] / src / complex / ctanh.c
index dd569fc..54004cd 100644 (file)
@@ -63,7 +63,7 @@
  *   precision.  I also handle large x differently.
  */
 
-#include "libm.h"
+#include "complex_impl.h"
 
 double complex ctanh(double complex z)
 {
@@ -95,17 +95,19 @@ double complex ctanh(double complex z)
         */
        if (ix >= 0x7ff00000) {
                if ((ix & 0xfffff) | lx)        /* x is NaN */
-                       return cpack(x, (y == 0 ? y : x * y));
+                       return CMPLX(x, (y == 0 ? y : x * y));
                SET_HIGH_WORD(x, hx - 0x40000000);      /* x = copysign(1, x) */
-               return cpack(x, copysign(0, isinf(y) ? y : sin(y) * cos(y)));
+               return CMPLX(x, copysign(0, isinf(y) ? y : sin(y) * cos(y)));
        }
 
        /*
+        * ctanh(+-0 + i NAN) = +-0 + i NaN
+        * ctanh(+-0 +- i Inf) = +-0 + i NaN
         * ctanh(x + i NAN) = NaN + i NaN
         * ctanh(x +- i Inf) = NaN + i NaN
         */
        if (!isfinite(y))
-               return cpack(y - y, y - y);
+               return CMPLX(x ? y - y : x, y - y);
 
        /*
         * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the
@@ -114,7 +116,7 @@ double complex ctanh(double complex z)
         */
        if (ix >= 0x40360000) { /* x >= 22 */
                double exp_mx = exp(-fabs(x));
-               return cpack(copysign(1, x), 4 * sin(y) * cos(y) * exp_mx * exp_mx);
+               return CMPLX(copysign(1, x), 4 * sin(y) * cos(y) * exp_mx * exp_mx);
        }
 
        /* Kahan's algorithm */
@@ -123,5 +125,5 @@ double complex ctanh(double complex z)
        s = sinh(x);
        rho = sqrt(1 + s * s);  /* = cosh(x) */
        denom = 1 + beta * s * s;
-       return cpack((beta * rho * s) / denom, t / denom);
+       return CMPLX((beta * rho * s) / denom, t / denom);
 }