15b2ba9d3SPiotr Jasiukajtis /*
25b2ba9d3SPiotr Jasiukajtis * CDDL HEADER START
35b2ba9d3SPiotr Jasiukajtis *
45b2ba9d3SPiotr Jasiukajtis * The contents of this file are subject to the terms of the
55b2ba9d3SPiotr Jasiukajtis * Common Development and Distribution License (the "License").
65b2ba9d3SPiotr Jasiukajtis * You may not use this file except in compliance with the License.
75b2ba9d3SPiotr Jasiukajtis *
85b2ba9d3SPiotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95b2ba9d3SPiotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
105b2ba9d3SPiotr Jasiukajtis * See the License for the specific language governing permissions
115b2ba9d3SPiotr Jasiukajtis * and limitations under the License.
125b2ba9d3SPiotr Jasiukajtis *
135b2ba9d3SPiotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
145b2ba9d3SPiotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155b2ba9d3SPiotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
165b2ba9d3SPiotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
175b2ba9d3SPiotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
185b2ba9d3SPiotr Jasiukajtis *
195b2ba9d3SPiotr Jasiukajtis * CDDL HEADER END
205b2ba9d3SPiotr Jasiukajtis */
215b2ba9d3SPiotr Jasiukajtis
225b2ba9d3SPiotr Jasiukajtis /*
235b2ba9d3SPiotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
245b2ba9d3SPiotr Jasiukajtis */
255b2ba9d3SPiotr Jasiukajtis /*
265b2ba9d3SPiotr Jasiukajtis * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
275b2ba9d3SPiotr Jasiukajtis * Use is subject to license terms.
285b2ba9d3SPiotr Jasiukajtis */
295b2ba9d3SPiotr Jasiukajtis
30*a9d3dcd5SRichard Lowe #pragma weak __catan = catan
315b2ba9d3SPiotr Jasiukajtis
325b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
335b2ba9d3SPiotr Jasiukajtis /*
345b2ba9d3SPiotr Jasiukajtis * dcomplex catan(dcomplex z);
355b2ba9d3SPiotr Jasiukajtis *
365b2ba9d3SPiotr Jasiukajtis * If
375b2ba9d3SPiotr Jasiukajtis * z = x + iy,
385b2ba9d3SPiotr Jasiukajtis *
395b2ba9d3SPiotr Jasiukajtis * then
405b2ba9d3SPiotr Jasiukajtis * 1 ( 2x ) 1 2 2
415b2ba9d3SPiotr Jasiukajtis * Re w = - arctan(-----------) = - ATAN2(2x, 1 - x - y )
425b2ba9d3SPiotr Jasiukajtis * 2 ( 2 2) 2
435b2ba9d3SPiotr Jasiukajtis * (1 - x - y )
445b2ba9d3SPiotr Jasiukajtis *
455b2ba9d3SPiotr Jasiukajtis * ( 2 2)
465b2ba9d3SPiotr Jasiukajtis * 1 (x + (y+1) ) 1 4y
475b2ba9d3SPiotr Jasiukajtis * Im w = - log(------------) .= --- log [ 1 + ------------- ]
485b2ba9d3SPiotr Jasiukajtis * 4 ( 2 2) 4 2 2
495b2ba9d3SPiotr Jasiukajtis * (x + (y-1) ) x + (y-1)
505b2ba9d3SPiotr Jasiukajtis *
515b2ba9d3SPiotr Jasiukajtis * 2 16 3 y
525b2ba9d3SPiotr Jasiukajtis * = t - 2t + -- t - ..., where t = -----------------
535b2ba9d3SPiotr Jasiukajtis * 3 x*x + (y-1)*(y-1)
545b2ba9d3SPiotr Jasiukajtis *
555b2ba9d3SPiotr Jasiukajtis * Note that: if catan( x, y) = ( u, v), then
565b2ba9d3SPiotr Jasiukajtis * catan(-x, y) = (-u, v)
575b2ba9d3SPiotr Jasiukajtis * catan( x,-y) = ( u,-v)
585b2ba9d3SPiotr Jasiukajtis *
595b2ba9d3SPiotr Jasiukajtis * Also, catan(x,y) = -i*catanh(-y,x), or
605b2ba9d3SPiotr Jasiukajtis * catanh(x,y) = i*catan(-y,x)
615b2ba9d3SPiotr Jasiukajtis * So, if catanh(y,x) = (v,u), then catan(x,y) = -i*(-v,u) = (u,v), i.e.,
625b2ba9d3SPiotr Jasiukajtis * catan(x,y) = (u,v)
635b2ba9d3SPiotr Jasiukajtis *
645b2ba9d3SPiotr Jasiukajtis * EXCEPTION CASES (conform to ISO/IEC 9899:1999(E)):
655b2ba9d3SPiotr Jasiukajtis * catan( 0 , 0 ) = (0 , 0 )
665b2ba9d3SPiotr Jasiukajtis * catan( NaN, 0 ) = (NaN , 0 )
675b2ba9d3SPiotr Jasiukajtis * catan( 0 , 1 ) = (0 , +inf) with divide-by-zero
685b2ba9d3SPiotr Jasiukajtis * catan( inf, y ) = (pi/2 , 0 ) for finite +y
695b2ba9d3SPiotr Jasiukajtis * catan( NaN, y ) = (NaN , NaN ) with invalid for finite y != 0
705b2ba9d3SPiotr Jasiukajtis * catan( x , inf ) = (pi/2 , 0 ) for finite +x
715b2ba9d3SPiotr Jasiukajtis * catan( inf, inf ) = (pi/2 , 0 )
725b2ba9d3SPiotr Jasiukajtis * catan( NaN, inf ) = (NaN , 0 )
735b2ba9d3SPiotr Jasiukajtis * catan( x , NaN ) = (NaN , NaN ) with invalid for finite x
745b2ba9d3SPiotr Jasiukajtis * catan( inf, NaN ) = (pi/2 , +-0 )
755b2ba9d3SPiotr Jasiukajtis */
765b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
775b2ba9d3SPiotr Jasiukajtis
785b2ba9d3SPiotr Jasiukajtis #include "libm.h" /* atan/atan2/fabs/log/log1p */
795b2ba9d3SPiotr Jasiukajtis #include "complex_wrapper.h"
805b2ba9d3SPiotr Jasiukajtis
815b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
825b2ba9d3SPiotr Jasiukajtis static const double
835b2ba9d3SPiotr Jasiukajtis pi_2 = 1.570796326794896558e+00,
845b2ba9d3SPiotr Jasiukajtis zero = 0.0,
855b2ba9d3SPiotr Jasiukajtis half = 0.5,
865b2ba9d3SPiotr Jasiukajtis two = 2.0,
875b2ba9d3SPiotr Jasiukajtis ln2 = 6.931471805599453094172321214581765680755e-0001,
885b2ba9d3SPiotr Jasiukajtis one = 1.0;
895b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
905b2ba9d3SPiotr Jasiukajtis
915b2ba9d3SPiotr Jasiukajtis dcomplex
catan(dcomplex z)925b2ba9d3SPiotr Jasiukajtis catan(dcomplex z) {
935b2ba9d3SPiotr Jasiukajtis dcomplex ans;
945b2ba9d3SPiotr Jasiukajtis double x, y, ax, ay, t;
955b2ba9d3SPiotr Jasiukajtis int hx, hy, ix, iy;
965b2ba9d3SPiotr Jasiukajtis unsigned lx, ly;
975b2ba9d3SPiotr Jasiukajtis
985b2ba9d3SPiotr Jasiukajtis x = D_RE(z);
995b2ba9d3SPiotr Jasiukajtis y = D_IM(z);
1005b2ba9d3SPiotr Jasiukajtis ax = fabs(x);
1015b2ba9d3SPiotr Jasiukajtis ay = fabs(y);
1025b2ba9d3SPiotr Jasiukajtis hx = HI_WORD(x);
1035b2ba9d3SPiotr Jasiukajtis lx = LO_WORD(x);
1045b2ba9d3SPiotr Jasiukajtis hy = HI_WORD(y);
1055b2ba9d3SPiotr Jasiukajtis ly = LO_WORD(y);
1065b2ba9d3SPiotr Jasiukajtis ix = hx & 0x7fffffff;
1075b2ba9d3SPiotr Jasiukajtis iy = hy & 0x7fffffff;
1085b2ba9d3SPiotr Jasiukajtis
1095b2ba9d3SPiotr Jasiukajtis /* x is inf or NaN */
1105b2ba9d3SPiotr Jasiukajtis if (ix >= 0x7ff00000) {
1115b2ba9d3SPiotr Jasiukajtis if (ISINF(ix, lx)) {
1125b2ba9d3SPiotr Jasiukajtis D_RE(ans) = pi_2;
1135b2ba9d3SPiotr Jasiukajtis D_IM(ans) = zero;
1145b2ba9d3SPiotr Jasiukajtis } else {
1155b2ba9d3SPiotr Jasiukajtis D_RE(ans) = x + x;
1165b2ba9d3SPiotr Jasiukajtis if ((iy | ly) == 0 || (ISINF(iy, ly)))
1175b2ba9d3SPiotr Jasiukajtis D_IM(ans) = zero;
1185b2ba9d3SPiotr Jasiukajtis else
1195b2ba9d3SPiotr Jasiukajtis D_IM(ans) = (fabs(y) - ay) / (fabs(y) - ay);
1205b2ba9d3SPiotr Jasiukajtis }
1215b2ba9d3SPiotr Jasiukajtis } else if (iy >= 0x7ff00000) {
1225b2ba9d3SPiotr Jasiukajtis /* y is inf or NaN */
1235b2ba9d3SPiotr Jasiukajtis if (ISINF(iy, ly)) {
1245b2ba9d3SPiotr Jasiukajtis D_RE(ans) = pi_2;
1255b2ba9d3SPiotr Jasiukajtis D_IM(ans) = zero;
1265b2ba9d3SPiotr Jasiukajtis } else {
1275b2ba9d3SPiotr Jasiukajtis D_RE(ans) = (fabs(x) - ax) / (fabs(x) - ax);
1285b2ba9d3SPiotr Jasiukajtis D_IM(ans) = y;
1295b2ba9d3SPiotr Jasiukajtis }
1305b2ba9d3SPiotr Jasiukajtis } else if ((ix | lx) == 0) {
1315b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
1325b2ba9d3SPiotr Jasiukajtis /*
1335b2ba9d3SPiotr Jasiukajtis * x = 0
1345b2ba9d3SPiotr Jasiukajtis * 1 1
1355b2ba9d3SPiotr Jasiukajtis * A = --- * atan2(2x, 1-x*x-y*y) = --- atan2(0,1-|y|)
1365b2ba9d3SPiotr Jasiukajtis * 2 2
1375b2ba9d3SPiotr Jasiukajtis *
1385b2ba9d3SPiotr Jasiukajtis * 1 [ (y+1)*(y+1) ] 1 2 1 2y
1395b2ba9d3SPiotr Jasiukajtis * B = - log [ ------------ ] = - log (1+ ---) or - log(1+ ----)
1405b2ba9d3SPiotr Jasiukajtis * 4 [ (y-1)*(y-1) ] 2 y-1 2 1-y
1415b2ba9d3SPiotr Jasiukajtis */
1425b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
1435b2ba9d3SPiotr Jasiukajtis t = one - ay;
1445b2ba9d3SPiotr Jasiukajtis if (((iy - 0x3ff00000) | ly) == 0) {
1455b2ba9d3SPiotr Jasiukajtis /* y=1: catan(0,1)=(0,+inf) with 1/0 signal */
1465b2ba9d3SPiotr Jasiukajtis D_IM(ans) = ay / ax;
1475b2ba9d3SPiotr Jasiukajtis D_RE(ans) = zero;
1485b2ba9d3SPiotr Jasiukajtis } else if (iy >= 0x3ff00000) { /* y>1 */
1495b2ba9d3SPiotr Jasiukajtis D_IM(ans) = half * log1p(two / (-t));
1505b2ba9d3SPiotr Jasiukajtis D_RE(ans) = pi_2;
1515b2ba9d3SPiotr Jasiukajtis } else { /* y<1 */
1525b2ba9d3SPiotr Jasiukajtis D_IM(ans) = half * log1p((ay + ay) / t);
1535b2ba9d3SPiotr Jasiukajtis D_RE(ans) = zero;
1545b2ba9d3SPiotr Jasiukajtis }
1555b2ba9d3SPiotr Jasiukajtis } else if (iy < 0x3e200000 || ((ix - iy) >> 20) >= 30) {
1565b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
1575b2ba9d3SPiotr Jasiukajtis /*
1585b2ba9d3SPiotr Jasiukajtis * Tiny y (relative to 1+|x|)
1595b2ba9d3SPiotr Jasiukajtis * |y| < E*(1+|x|)
1605b2ba9d3SPiotr Jasiukajtis * where E=2**-29, -35, -60 for double, double extended, quad precision
1615b2ba9d3SPiotr Jasiukajtis *
1625b2ba9d3SPiotr Jasiukajtis * 1 [ x<=1: atan(x)
1635b2ba9d3SPiotr Jasiukajtis * A = --- * atan2(2x, 1-x*x-y*y) ~ [ 1 1+x
1645b2ba9d3SPiotr Jasiukajtis * 2 [ x>=1: - atan2(2,(1-x)*(-----))
1655b2ba9d3SPiotr Jasiukajtis * 2 x
1665b2ba9d3SPiotr Jasiukajtis *
1675b2ba9d3SPiotr Jasiukajtis * y/x
1685b2ba9d3SPiotr Jasiukajtis * B ~ t*(1-2t), where t = ----------------- is tiny
1695b2ba9d3SPiotr Jasiukajtis * x + (y-1)*(y-1)/x
1705b2ba9d3SPiotr Jasiukajtis */
1715b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
1725b2ba9d3SPiotr Jasiukajtis if (ix < 0x3ff00000)
1735b2ba9d3SPiotr Jasiukajtis D_RE(ans) = atan(ax);
1745b2ba9d3SPiotr Jasiukajtis else
1755b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * atan2(two, (one - ax) * (one +
1765b2ba9d3SPiotr Jasiukajtis one / ax));
1775b2ba9d3SPiotr Jasiukajtis if ((iy | ly) == 0) {
1785b2ba9d3SPiotr Jasiukajtis D_IM(ans) = ay;
1795b2ba9d3SPiotr Jasiukajtis } else {
1805b2ba9d3SPiotr Jasiukajtis if (ix < 0x3e200000)
1815b2ba9d3SPiotr Jasiukajtis t = ay / ((ay - one) * (ay - one));
1825b2ba9d3SPiotr Jasiukajtis else if (ix > 0x41c00000)
1835b2ba9d3SPiotr Jasiukajtis t = (ay / ax) / ax;
1845b2ba9d3SPiotr Jasiukajtis else
1855b2ba9d3SPiotr Jasiukajtis t = ay / (ax * ax + (ay - one) * (ay - one));
1865b2ba9d3SPiotr Jasiukajtis D_IM(ans) = t * (one - (t + t));
1875b2ba9d3SPiotr Jasiukajtis }
1885b2ba9d3SPiotr Jasiukajtis } else if (iy >= 0x41c00000 && ((iy - ix) >> 20) >= 30) {
1895b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
1905b2ba9d3SPiotr Jasiukajtis /*
1915b2ba9d3SPiotr Jasiukajtis * Huge y relative to 1+|x|
1925b2ba9d3SPiotr Jasiukajtis * |y| > Einv*(1+|x|), where Einv~2**(prec/2+3),
1935b2ba9d3SPiotr Jasiukajtis * 1
1945b2ba9d3SPiotr Jasiukajtis * A ~ --- * atan2(2x, -y*y) ~ pi/2
1955b2ba9d3SPiotr Jasiukajtis * 2
1965b2ba9d3SPiotr Jasiukajtis * y
1975b2ba9d3SPiotr Jasiukajtis * B ~ t*(1-2t), where t = --------------- is tiny
1985b2ba9d3SPiotr Jasiukajtis * (y-1)*(y-1)
1995b2ba9d3SPiotr Jasiukajtis */
2005b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
2015b2ba9d3SPiotr Jasiukajtis D_RE(ans) = pi_2;
2025b2ba9d3SPiotr Jasiukajtis t = (ay / (ay - one)) / (ay - one);
2035b2ba9d3SPiotr Jasiukajtis D_IM(ans) = t * (one - (t + t));
2045b2ba9d3SPiotr Jasiukajtis } else if (((iy - 0x3ff00000) | ly) == 0) {
2055b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
2065b2ba9d3SPiotr Jasiukajtis /*
2075b2ba9d3SPiotr Jasiukajtis * y = 1
2085b2ba9d3SPiotr Jasiukajtis * 1 1
2095b2ba9d3SPiotr Jasiukajtis * A = --- * atan2(2x, -x*x) = --- atan2(2,-x)
2105b2ba9d3SPiotr Jasiukajtis * 2 2
2115b2ba9d3SPiotr Jasiukajtis *
2125b2ba9d3SPiotr Jasiukajtis * 1 [x*x + 4] 1 4 [ 0.5(log2-logx) if
2135b2ba9d3SPiotr Jasiukajtis * B = - log [-------] = - log (1+ ---) = [ |x|<E, else 0.25*
2145b2ba9d3SPiotr Jasiukajtis * 4 [ x*x ] 4 x*x [ log1p((2/x)*(2/x))
2155b2ba9d3SPiotr Jasiukajtis */
2165b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
2175b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * atan2(two, -ax);
2185b2ba9d3SPiotr Jasiukajtis if (ix < 0x3e200000)
2195b2ba9d3SPiotr Jasiukajtis D_IM(ans) = half * (ln2 - log(ax));
2205b2ba9d3SPiotr Jasiukajtis else {
2215b2ba9d3SPiotr Jasiukajtis t = two / ax;
2225b2ba9d3SPiotr Jasiukajtis D_IM(ans) = 0.25 * log1p(t * t);
2235b2ba9d3SPiotr Jasiukajtis }
2245b2ba9d3SPiotr Jasiukajtis } else if (ix >= 0x43900000) {
2255b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
2265b2ba9d3SPiotr Jasiukajtis /*
2275b2ba9d3SPiotr Jasiukajtis * Huge x:
2285b2ba9d3SPiotr Jasiukajtis * when |x| > 1/E^2,
2295b2ba9d3SPiotr Jasiukajtis * 1 pi
2305b2ba9d3SPiotr Jasiukajtis * A ~ --- * atan2(2x, -x*x-y*y) ~ ---
2315b2ba9d3SPiotr Jasiukajtis * 2 2
2325b2ba9d3SPiotr Jasiukajtis * y y/x
2335b2ba9d3SPiotr Jasiukajtis * B ~ t*(1-2t), where t = --------------- = (-------------- )/x
2345b2ba9d3SPiotr Jasiukajtis * x*x+(y-1)*(y-1) 1+((y-1)/x)^2
2355b2ba9d3SPiotr Jasiukajtis */
2365b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
2375b2ba9d3SPiotr Jasiukajtis D_RE(ans) = pi_2;
2385b2ba9d3SPiotr Jasiukajtis t = ((ay / ax) / (one + ((ay - one) / ax) * ((ay - one) /
2395b2ba9d3SPiotr Jasiukajtis ax))) / ax;
2405b2ba9d3SPiotr Jasiukajtis D_IM(ans) = t * (one - (t + t));
2415b2ba9d3SPiotr Jasiukajtis } else if (ix < 0x38b00000) {
2425b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
2435b2ba9d3SPiotr Jasiukajtis /*
2445b2ba9d3SPiotr Jasiukajtis * Tiny x:
2455b2ba9d3SPiotr Jasiukajtis * when |x| < E^4, (note that y != 1)
2465b2ba9d3SPiotr Jasiukajtis * 1 1
2475b2ba9d3SPiotr Jasiukajtis * A = --- * atan2(2x, 1-x*x-y*y) ~ --- * atan2(2x,(1-y)*(1+y))
2485b2ba9d3SPiotr Jasiukajtis * 2 2
2495b2ba9d3SPiotr Jasiukajtis *
2505b2ba9d3SPiotr Jasiukajtis * 1 [(y+1)*(y+1)] 1 2 1 2y
2515b2ba9d3SPiotr Jasiukajtis * B = - log [-----------] = - log (1+ ---) or - log(1+ ----)
2525b2ba9d3SPiotr Jasiukajtis * 4 [(y-1)*(y-1)] 2 y-1 2 1-y
2535b2ba9d3SPiotr Jasiukajtis */
2545b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
2555b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * atan2(ax + ax, (one - ay) * (one + ay));
2565b2ba9d3SPiotr Jasiukajtis if (iy >= 0x3ff00000)
2575b2ba9d3SPiotr Jasiukajtis D_IM(ans) = half * log1p(two / (ay - one));
2585b2ba9d3SPiotr Jasiukajtis else
2595b2ba9d3SPiotr Jasiukajtis D_IM(ans) = half * log1p((ay + ay) / (one - ay));
2605b2ba9d3SPiotr Jasiukajtis } else {
2615b2ba9d3SPiotr Jasiukajtis /* INDENT OFF */
2625b2ba9d3SPiotr Jasiukajtis /*
2635b2ba9d3SPiotr Jasiukajtis * normal x,y
2645b2ba9d3SPiotr Jasiukajtis * 1
2655b2ba9d3SPiotr Jasiukajtis * A = --- * atan2(2x, 1-x*x-y*y)
2665b2ba9d3SPiotr Jasiukajtis * 2
2675b2ba9d3SPiotr Jasiukajtis *
2685b2ba9d3SPiotr Jasiukajtis * 1 [x*x+(y+1)*(y+1)] 1 4y
2695b2ba9d3SPiotr Jasiukajtis * B = - log [---------------] = - log (1+ -----------------)
2705b2ba9d3SPiotr Jasiukajtis * 4 [x*x+(y-1)*(y-1)] 4 x*x + (y-1)*(y-1)
2715b2ba9d3SPiotr Jasiukajtis */
2725b2ba9d3SPiotr Jasiukajtis /* INDENT ON */
2735b2ba9d3SPiotr Jasiukajtis t = one - ay;
2745b2ba9d3SPiotr Jasiukajtis if (iy >= 0x3fe00000 && iy < 0x40000000) {
2755b2ba9d3SPiotr Jasiukajtis /* y close to 1 */
2765b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * (atan2((ax + ax), (t * (one + ay) -
2775b2ba9d3SPiotr Jasiukajtis ax * ax)));
2785b2ba9d3SPiotr Jasiukajtis } else if (ix >= 0x3fe00000 && ix < 0x40000000) {
2795b2ba9d3SPiotr Jasiukajtis /* x close to 1 */
2805b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * atan2((ax + ax), ((one - ax) *
2815b2ba9d3SPiotr Jasiukajtis (one + ax) - ay * ay));
2825b2ba9d3SPiotr Jasiukajtis } else
2835b2ba9d3SPiotr Jasiukajtis D_RE(ans) = half * atan2((ax + ax), ((one - ax * ax) -
2845b2ba9d3SPiotr Jasiukajtis ay * ay));
2855b2ba9d3SPiotr Jasiukajtis D_IM(ans) = 0.25 * log1p((4.0 * ay) / (ax * ax + t * t));
2865b2ba9d3SPiotr Jasiukajtis }
2875b2ba9d3SPiotr Jasiukajtis if (hx < 0)
2885b2ba9d3SPiotr Jasiukajtis D_RE(ans) = -D_RE(ans);
2895b2ba9d3SPiotr Jasiukajtis if (hy < 0)
2905b2ba9d3SPiotr Jasiukajtis D_IM(ans) = -D_IM(ans);
2915b2ba9d3SPiotr Jasiukajtis return (ans);
2925b2ba9d3SPiotr Jasiukajtis }
293