casinl.c revision ddc0e0b53c661f6e439e3b7072b3ef353eadb4af
/*
* 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_4 = 0.7853981633974483095739921312272713294078130L,
pi_4_l = 4.1668714592604391641479322342670193036704898e-20L,
pi_2 = 1.5707963267948966191479842624545426588156260L,
pi_2_l = 8.3337429185208783282958644685340386073409796e-20L;
#else
E = 9.6296497219361792652798897129246365926905e-35L, /* 2**-113 */
pi_4 = 0.7853981633974483096156608458198756993697670L,
pi_4_l = 2.1679525325309452561992610065108379921905808e-35L,
pi_2 = 1.5707963267948966192313216916397513987395340L,
pi_2_l = 4.3359050650618905123985220130216759843811616e-35L;
#endif
/* INDENT ON */
#if defined(__x86)
#else
#endif
x = LD_RE(z);
y = LD_IM(z);
x = fabsl(x);
y = fabsl(y);
/* special cases */
/* x is inf or NaN */
if (isinfl(x)) { /* x is INF */
if (iy >= 0x7fff0000) {
if (isinfl(y))
/* casin(inf + i inf) = pi/4 + i inf */
else /* casin(inf + i NaN) = NaN + i inf */
} else /* casin(inf + iy) = pi/2 + i inf */
} else { /* x is NaN */
if (iy >= 0x7fff0000) {
/* INDENT OFF */
/*
* casin(NaN + i inf) = NaN + i inf
* casin(NaN + i NaN) = NaN + i NaN
*/
/* INDENT ON */
} else {
/* INDENT OFF */
/* casin(NaN + i y ) = NaN + i NaN */
/* INDENT ON */
}
}
if (hx < 0)
if (hy < 0)
return (ans);
}
/* casin(+0 + i 0) = 0 + i 0. */
return (z);
if (isinfl(y)) { /* casin(x + i inf) = 0 + i inf */
} else { /* casin(x + i NaN) = NaN + i NaN */
if (x == zero)
else
}
if (hx < 0)
if (hy < 0)
return (ans);
}
if (y == zero) { /* region 1: y=0 */
} else {
one)));
else {
one)));
}
}
} else {
one)));
else
}
} else if (y < Foursqrtu) { /* region 3 */
t = sqrtl(y);
} else if (E * y - one >= x) { /* region 4 */
/* region 5: x+1 and y are both (>= sqrt(max)/8) i.e. 2**8188 */
t = x / y;
} else if (x < Foursqrtu) {
/* region 6: x is very small, < 4sqrt(min) */
else
} else { /* safe region */
y2 = y * y;
A = half * (R + S);
B = x / A;
if (B <= Bcrossover)
else { /* use atan and an accurate approx to a-x */
Apx = A + x;
if (x <= one)
else
}
if (A <= Acrossover) {
/* use log1p and an accurate approx to A-1 */
if (x < one)
else
} else {
}
}
if (hx < 0)
if (hy < 0)
return (ans);
}