Print this page
11210 libm should be cstyle(1ONBLD) clean
*** 20,37 ****
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __cexp = cexp
! /* INDENT OFF */
/*
* dcomplex cexp(dcomplex z);
*
* x+iy x
* e = e (cos(y)+i*sin(y))
--- 20,38 ----
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __cexp = cexp
!
/*
* dcomplex cexp(dcomplex z);
*
* x+iy x
* e = e (cos(y)+i*sin(y))
*** 54,72 ****
* Algorithm for out of range x and finite y
* 1. compute exp(x) in factor form (t=__k_cexp(x,&n))*2**n
* 2. compute sincos(y,&s,&c)
* 3. compute t*s+i*(t*c), then scale back to 2**n and return.
*/
- /* INDENT ON */
#include "libm.h" /* exp/scalbn/sincos/__k_cexp */
#include "complex_wrapper.h"
static const double zero = 0.0;
dcomplex
! cexp(dcomplex z) {
dcomplex ans;
double x, y, t, c, s;
int n, ix, iy, hx, hy, lx, ly;
x = D_RE(z);
--- 55,73 ----
* Algorithm for out of range x and finite y
* 1. compute exp(x) in factor form (t=__k_cexp(x,&n))*2**n
* 2. compute sincos(y,&s,&c)
* 3. compute t*s+i*(t*c), then scale back to 2**n and return.
*/
#include "libm.h" /* exp/scalbn/sincos/__k_cexp */
#include "complex_wrapper.h"
static const double zero = 0.0;
dcomplex
! cexp(dcomplex z)
! {
dcomplex ans;
double x, y, t, c, s;
int n, ix, iy, hx, hy, lx, ly;
x = D_RE(z);
*** 75,84 ****
--- 76,86 ----
lx = LO_WORD(x);
hy = HI_WORD(y);
ly = LO_WORD(y);
ix = hx & 0x7fffffff;
iy = hy & 0x7fffffff;
+
if ((iy | ly) == 0) { /* y = 0 */
D_RE(ans) = exp(x);
D_IM(ans) = y;
} else if (ISINF(ix, lx)) { /* x is +-inf */
if (hx < 0) {
*** 100,116 ****
--- 102,120 ----
D_IM(ans) = x * s;
}
}
} else {
(void) sincos(y, &s, &c);
+
if (ix >= 0x40862E42) { /* |x| > 709.78... ~ log(2**1024) */
t = __k_cexp(x, &n);
D_RE(ans) = scalbn(t * c, n);
D_IM(ans) = scalbn(t * s, n);
} else {
t = exp(x);
D_RE(ans) = t * c;
D_IM(ans) = t * s;
}
}
+
return (ans);
}