cacosl.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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "complex_wrapper.h"
#include "longdouble.h"
/* INDENT OFF */
static const long double
zero = 0.0L,
one = 1.0L,
Acrossover = 1.5L,
Bcrossover = 0.6417L,
half = 0.5L,
ln2 = 6.931471805599453094172321214581765680755e-0001L,
#if defined(__x86)
E = 5.4210108624275221700372640043497085571289e-20L, /* 2**-64 */
pi = 3.141592653589793238295968524909085317631252110004425048828125L,
pi_l = 1.666748583704175665659172893706807721468195923078e-19L,
pi_2 = 1.5707963267948966191479842624545426588156260L,
pi_2_l = 8.3337429185208783282958644685340386073409796e-20L,
pi_4 = 0.78539816339744830957399213122727132940781302750110626220703125L,
pi_4_l = 4.166871459260439164147932234267019303670489807695410e-20L,
pi3_4 = 2.35619449019234492872197639368181398822343908250331878662109375L,
pi3_4_l = 1.250061437778131749244379670280105791101146942308e-19L;
#else
E = 9.6296497219361792652798897129246365926905e-35L, /* 2**-113 */
pi = 3.1415926535897932384626433832795027974790680981372955730045043318L,
pi_l = 8.6718101301237810247970440260433519687623233462565303417759356862e-35L,
pi_2 = 1.5707963267948966192313216916397513987395340L,
pi_2_l = 4.3359050650618905123985220130216759843811616e-35L,
pi_4 = 0.785398163397448309615660845819875699369767024534323893251126L,
pi_4_l = 2.167952532530945256199261006510837992190580836564132585443e-35L,
pi3_4 = 2.35619449019234492884698253745962709810930107360297167975337824L,
pi3_4_l = 6.503857597592835768597783019532513976571742509692397756331e-35L;
#endif
/* INDENT ON */
#if defined(__x86)
#else
#endif
x = LD_RE(z);
y = LD_IM(z);
/* x is 0 */
if (x == zero) {
return (ans);
}
}
/* |y| is inf or NaN */
if (iy >= 0x7fff0000) {
if (isinfl(y)) { /* cacos(x + i inf) = pi/2 - i inf */
if (ix < 0x7fff0000) {
} else if (isinfl(x)) {
if (hx >= 0)
else
} else {
}
} else { /* cacos(x + i NaN) = NaN + i NaN */
if (isinfl(x))
else
}
return (ans);
}
y = fabsl(y);
if (isinfl(x)) { /* x is INF */
if (iy >= 0x7fff0000) {
if (isinfl(y)) {
/* INDENT OFF */
/* cacos(inf + i inf) = pi/4 - i inf */
/* cacos(-inf+ i inf) =3pi/4 - i inf */
/* INDENT ON */
if (hx >= 0)
else
} else
/* INDENT OFF */
/* cacos(inf + i NaN) = NaN - i inf */
/* INDENT ON */
} else {
/* INDENT OFF */
/* cacos(inf + iy ) = 0 - i inf */
/* cacos(-inf+ iy ) = pi - i inf */
/* INDENT ON */
if (hx >= 0)
else
}
} else { /* x is NaN */
/* INDENT OFF */
/*
* cacos(NaN + i inf) = NaN - i inf
* cacos(NaN + i y ) = NaN + i NaN
* cacos(NaN + i NaN) = NaN + i NaN
*/
/* INDENT ON */
if (iy >= 0x7fff0000) {
} else {
}
}
if (hy < 0)
return (ans);
}
if (y == zero) { /* region 1: y=0 */
} else {
x = fabsl(x);
one)));
else {
one)));
}
}
/* region 2: y < tiny*||x|-1| */
x = fabsl(x);
if (hx >= 0)
else {
else {
t = pi_l + y / x;
}
}
} else {
x = fabsl(x);
else
}
} else if (y < Foursqrtu) { /* region 3 */
t = sqrtl(y);
/* region 5: x+1 and y are both (>= sqrt(max)/8) i.e. 2**8188 */
t = x / y;
/* region 6: x is very small, < 4sqrt(min) */
else
} else { /* safe region */
t = fabsl(x);
y2 = y * y;
A = half * (R + S);
B = t / A;
if (B <= Bcrossover)
else { /* use atan and an accurate approx to a-x */
Apx = A + t;
if (t <= one)
else
}
if (A <= Acrossover) {
/* use log1p and an accurate approx to A-1 */
if (ix < 0x3fff0000)
else
} else {
}
}
if (hy >= 0)
return (ans);
}