Print this page
11210 libm should be cstyle(1ONBLD) clean

@@ -20,18 +20,19 @@
  */
 
 /*
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  */
+
 /*
  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 #pragma weak __casin = casin
 
-/* INDENT OFF */
+
 /*
  * dcomplex casin(dcomplex z);
  *
  * Alogrithm
  * (based on T.E.Hull, Thomas F. Fairgrieve and Ping Tak Peter Tang's

@@ -189,32 +190,30 @@
  *                    = 0.5*log(1+2y(y+sqrt(1+y^2)));
  *                    = 0.5*log1p(2y(y+A));
  *
  *      casin(z) = asin(B) + i sign(y) log (A + sqrt(A*A-1)),
  */
-/* INDENT ON */
 
 #include "libm.h"               /* asin/atan/fabs/log/log1p/sqrt */
 #include "complex_wrapper.h"
 
-/* INDENT OFF */
-static const double
-        zero = 0.0,
+static const double zero = 0.0,
         one = 1.0,
         E = 1.11022302462515654042e-16,                 /* 2**-53 */
         ln2 = 6.93147180559945286227e-01,
         pi_2 = 1.570796326794896558e+00,
         pi_2_l = 6.123233995736765886e-17,
         pi_4 = 7.85398163397448278999e-01,
         Foursqrtu = 5.96667258496016539463e-154,        /* 2**(-509) */
         Acrossover = 1.5,
         Bcrossover = 0.6417,
         half = 0.5;
-/* INDENT ON */
+
 
 dcomplex
-casin(dcomplex z) {
+casin(dcomplex z)
+{
         double x, y, t, R, S, A, Am1, B, y2, xm1, xp1, Apx;
         int ix, iy, hx, hy;
         unsigned lx, ly;
         dcomplex ans;
 

@@ -233,37 +232,41 @@
 
         /* x is inf or NaN */
         if (ix >= 0x7ff00000) { /* x is inf or NaN */
                 if (ISINF(ix, lx)) {    /* x is INF */
                         D_IM(ans) = x;
+
                         if (iy >= 0x7ff00000) {
                                 if (ISINF(iy, ly))
                                         /* casin(inf + i inf) = pi/4 + i inf */
                                         D_RE(ans) = pi_4;
                                 else    /* casin(inf + i NaN) = NaN  + i inf  */
                                         D_RE(ans) = y + y;
-                        } else  /* casin(inf + iy) = pi/2 + i inf */
+                        } else { /* casin(inf + iy) = pi/2 + i inf */
                                 D_RE(ans) = pi_2;
+                        }
                 } else {                /* x is NaN */
                         if (iy >= 0x7ff00000) {
-                                /* INDENT OFF */
+
                                 /*
                                  * casin(NaN + i inf) = NaN + i inf
                                  * casin(NaN + i NaN) = NaN + i NaN
                                  */
-                                /* INDENT ON */
                                 D_IM(ans) = y + y;
                                 D_RE(ans) = x + x;
                         } else {
                                 /* casin(NaN + i y ) = NaN  + i NaN */
                                 D_IM(ans) = D_RE(ans) = x + y;
                         }
                 }
+
                 if (hx < 0)
                         D_RE(ans) = -D_RE(ans);
+
                 if (hy < 0)
                         D_IM(ans) = -D_IM(ans);
+
                 return (ans);
         }
 
         /* casin(+0 + i 0  ) =  0   + i 0. */
         if ((ix | lx | iy | ly) == 0)

@@ -273,47 +276,53 @@
                 if (ISINF(iy, ly)) {    /* casin(x + i inf) =  0   + i inf */
                         D_IM(ans) = y;
                         D_RE(ans) = zero;
                 } else {                /* casin(x + i NaN) = NaN  + i NaN */
                         D_IM(ans) = x + y;
+
                         if ((ix | lx) == 0)
                                 D_RE(ans) = x;
                         else
                                 D_RE(ans) = y;
                 }
+
                 if (hx < 0)
                         D_RE(ans) = -D_RE(ans);
+
                 if (hy < 0)
                         D_IM(ans) = -D_IM(ans);
+
                 return (ans);
         }
 
         if ((iy | ly) == 0) {   /* region 1: y=0 */
                 if (ix < 0x3ff00000) {  /* |x| < 1 */
                         D_RE(ans) = asin(x);
                         D_IM(ans) = zero;
                 } else {
                         D_RE(ans) = pi_2;
-                        if (ix >= 0x43500000)   /* |x| >= 2**54 */
+
+                        if (ix >= 0x43500000) {         /* |x| >= 2**54 */
                                 D_IM(ans) = ln2 + log(x);
-                        else if (ix >= 0x3ff80000)      /* x > Acrossover */
+                        } else if (ix >= 0x3ff80000) {  /* x > Acrossover */
                                 D_IM(ans) = log(x + sqrt((x - one) * (x +
                                         one)));
-                        else {
+                        } else {
                                 xm1 = x - one;
                                 D_IM(ans) = log1p(xm1 + sqrt(xm1 * (x + one)));
                         }
                 }
         } else if (y <= E * fabs(x - one)) {    /* region 2: y < tiny*|x-1| */
                 if (ix < 0x3ff00000) {  /* x < 1 */
                         D_RE(ans) = asin(x);
                         D_IM(ans) = y / sqrt((one + x) * (one - x));
                 } else {
                         D_RE(ans) = pi_2;
-                        if (ix >= 0x43500000) { /* |x| >= 2**54 */
+
+                        if (ix >= 0x43500000)           /* |x| >= 2**54 */
                                 D_IM(ans) = ln2 + log(x);
-                        } else if (ix >= 0x3ff80000)    /* x > Acrossover */
+                        else if (ix >= 0x3ff80000)      /* x > Acrossover */
                                 D_IM(ans) = log(x + sqrt((x - one) * (x +
                                         one)));
                         else
                                 D_IM(ans) = log1p((x - one) + sqrt((x - one) *
                                         (x + one)));

@@ -332,10 +341,11 @@
                 D_IM(ans) = ln2 + log(y) + half * log1p(t * t);
         } else if (x < Foursqrtu) {
                 /* region 6: x is very small, < 4sqrt(min) */
                 A = sqrt(one + y * y);
                 D_RE(ans) = x / A;      /* may underflow */
+
                 if (iy >= 0x3ff80000)   /* if y > Acrossover */
                         D_IM(ans) = log(y + A);
                 else
                         D_IM(ans) = half * log1p((y + y) * (y + A));
         } else {        /* safe region */

@@ -345,35 +355,39 @@
                 R = sqrt(xp1 * xp1 + y2);
                 S = sqrt(xm1 * xm1 + y2);
                 A = half * (R + S);
                 B = x / A;
 
-                if (B <= Bcrossover)
+                if (B <= Bcrossover) {
                         D_RE(ans) = asin(B);
-                else {          /* use atan and an accurate approx to a-x */
+                } else {        /* use atan and an accurate approx to a-x */
                         Apx = A + x;
+
                         if (x <= one)
                                 D_RE(ans) = atan(x / sqrt(half * Apx * (y2 /
                                         (R + xp1) + (S - xm1))));
                         else
                                 D_RE(ans) = atan(x / (y * sqrt(half * (Apx /
                                         (R + xp1) + Apx / (S + xm1)))));
                 }
+
                 if (A <= Acrossover) {
                         /* use log1p and an accurate approx to A-1 */
                         if (x < one)
                                 Am1 = half * (y2 / (R + xp1) + y2 / (S - xm1));
                         else
                                 Am1 = half * (y2 / (R + xp1) + (S + xm1));
+
                         D_IM(ans) = log1p(Am1 + sqrt(Am1 * (A + one)));
                 } else {
                         D_IM(ans) = log(A + sqrt(A * A - one));
                 }
         }
 
         if (hx < 0)
                 D_RE(ans) = -D_RE(ans);
+
         if (hy < 0)
                 D_IM(ans) = -D_IM(ans);
 
         return (ans);
 }