/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* INDENT OFF */
/*
* dcomplex cexp(dcomplex z);
*
* x+iy x
* e = e (cos(y)+i*sin(y))
*
* --------------------
* exp(x) may be huge but cos(y) or sin(y) may be tiny. So we use
* function __k_cexp(x,&n) to return exp(x) = __k_cexp(x,&n)*2**n.
* Thus if exp(x+iy) = A + Bi and t = __k_cexp(x,&n), then
* A = t*cos(y)*2**n, B = t*sin(y)*2**n
*
* Purge off all exceptional arguments:
* (x,0) --> (exp(x),0) for all x, include inf and NaN
* (+inf, y) --> (+inf, NaN) for inf, nan
* (-inf, y) --> (+-0, +-0) for y = inf, nan
* For all other cases, return
* (x,y) --> exp(x)*cos(y)+i*exp(x)*sin(y))
*
* 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 "complex_wrapper.h"
double x, y, t, c, s;
x = D_RE(z);
y = D_IM(z);
if (hx < 0) {
if (iy >= 0x7ff00000) {
} else {
sincos(y, &s, &c);
}
} else {
if (iy >= 0x7ff00000) {
} else {
(void) sincos(y, &s, &c);
}
}
} else {
(void) sincos(y, &s, &c);
t = __k_cexp(x, &n);
} else {
t = exp(x);
}
}
return (ans);
}