cpowf.c revision 25c28e83beb90e7c80452a7c818c5e6f73a07dc8
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "libm.h"
#include "complex_wrapper.h"
extern void sincospi(double, double *, double *);
extern void sincospif(float, float *, float *);
extern double atan2pi(double, double);
extern float atan2pif(float, float);
extern int __swapRP(int);
#endif
static const double
dhalf = 0.5,
dinvpi = 0.3183098861837906715377675;
#define hiinf 0x7f800000
float x, y, u, v, t, c, s;
x = F_RE(z);
y = F_IM(z);
u = F_RE(w);
v = F_IM(w);
j = 0;
if (iv == 0) { /* z**(real) */
} else if (iu == 0) { /* (anything) ** 0 is 1 */
} else if (iy == 0) { /* (real)**(real) */
/* -x ** u is exp(i*pi*u)*pow(x,u) */
t = powf(-x, u);
sincospif(u, &s, &c);
} else {
}
} else {
v = fabsf(y);
if (ix != 0)
v += fabsf(x);
t = atan2pif(y, x);
sincospif(t * u, &s, &c);
}
#endif
dx = (double)x;
du = (double)u;
if (hy < 0)
if (rp != fp_extended)
#endif
} else {
j = 1;
}
if (j == 0)
return (ans);
}
/*
* non-zero imaginery part(s) with inf component(s) yields NaN
*/
} else {
#endif
/* INDENT OFF */
/*
* r = u*log(hypot(x,y))-v*atan2(y,x),
* q = u*atan2(y,x)+v*log(hypot(x,y))
* or
* r = u*log(hypot(x,y))-v*pi*atan2pi(y,x),
*/
/* INDENT ON */
dx = (double)x;
dy = (double)y;
du = (double)u;
dv = (double)v;
else
if (iv == 0) { /* dv = 0 */
} else {
}
if (rp != fp_extended)
#endif
}
return (ans);
}