Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -20,18 +20,19 @@
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __ccosh = ccosh
-/* INDENT OFF */
+
/*
* dcomplex ccosh(dcomplex z);
*
* z -z x -x
* e + e e (cos(y)+i*sin(y)) + e (cos(-y)+i*sin(-y))
@@ -71,17 +72,17 @@
* ccosh(inf,NaN) = (+inf,NaN)
* ccosh(NaN,0) = (NaN,+-0)
* ccosh(NaN,y) = (NaN,NaN) for non-zero y
* ccosh(NaN,NaN) = (NaN,NaN)
*/
-/* INDENT ON */
#include "libm.h" /* cosh/exp/fabs/scalbn/sinh/sincos/__k_cexp */
#include "complex_wrapper.h"
dcomplex
-ccosh(dcomplex z) {
+ccosh(dcomplex z)
+{
double t, x, y, S, C;
int hx, ix, lx, hy, iy, ly, n;
dcomplex ans;
x = D_RE(z);
@@ -94,10 +95,11 @@
iy = hy & 0x7fffffff;
x = fabs(x);
y = fabs(y);
(void) sincos(y, &S, &C);
+
if (ix >= 0x403c0000) { /* |x| > 28 = prec/2 (14,28,34,60) */
if (ix >= 0x40862E42) { /* |x| > 709.78... ~ log(2**1024) */
if (ix >= 0x7ff00000) { /* |x| is inf or NaN */
if ((iy | ly) == 0) {
D_RE(ans) = x;
@@ -127,9 +129,11 @@
} else {
D_RE(ans) = C * cosh(x);
D_IM(ans) = S * sinh(x);
}
}
+
if ((hx ^ hy) < 0)
D_IM(ans) = -D_IM(ans);
+
return (ans);
}