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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/complex/catanf.c
          +++ new/usr/src/lib/libm/common/complex/catanf.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23   24   */
       25 +
  24   26  /*
  25   27   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  26   28   * Use is subject to license terms.
  27   29   */
  28   30  
  29   31  #pragma weak __catanf = catanf
  30   32  
  31   33  #include "libm.h"
  32   34  #include "complex_wrapper.h"
  33   35  
  34   36  #if defined(__i386) && !defined(__amd64)
  35   37  extern int __swapRP(int);
  36   38  #endif
  37   39  
  38      -static const float
  39      -        pi_2 = 1.570796326794896558e+00F,
       40 +static const float pi_2 = 1.570796326794896558e+00F,
  40   41          zero = 0.0F,
  41   42          half = 0.5F,
  42   43          two = 2.0F,
  43   44          one = 1.0F;
  44   45  
  45   46  fcomplex
  46      -catanf(fcomplex z) {
  47      -        fcomplex        ans;
  48      -        float           x, y, ax, ay, t;
  49      -        double          dx, dy, dt;
  50      -        int             hx, hy, ix, iy;
       47 +catanf(fcomplex z)
       48 +{
       49 +        fcomplex ans;
       50 +        float x, y, ax, ay, t;
       51 +        double dx, dy, dt;
       52 +        int hx, hy, ix, iy;
  51   53  
  52   54          x = F_RE(z);
  53   55          y = F_IM(z);
  54   56          ax = fabsf(x);
  55   57          ay = fabsf(y);
  56   58          hx = THE_WORD(x);
  57   59          hy = THE_WORD(y);
  58   60          ix = hx & 0x7fffffff;
  59   61          iy = hy & 0x7fffffff;
  60   62  
  61   63          if (ix >= 0x7f800000) {         /* x is inf or NaN */
  62   64                  if (ix == 0x7f800000) {
  63   65                          F_RE(ans) = pi_2;
  64   66                          F_IM(ans) = zero;
  65   67                  } else {
  66   68                          F_RE(ans) = x * x;
       69 +
  67   70                          if (iy == 0 || iy == 0x7f800000)
  68   71                                  F_IM(ans) = zero;
  69   72                          else
  70   73                                  F_IM(ans) = (fabsf(y) - ay) / (fabsf(y) - ay);
  71   74                  }
  72   75          } else if (iy >= 0x7f800000) {  /* y is inf or NaN */
  73   76                  if (iy == 0x7f800000) {
  74   77                          F_RE(ans) = pi_2;
  75   78                          F_IM(ans) = zero;
  76   79                  } else {
  77   80                          F_RE(ans) = (fabsf(x) - ax) / (fabsf(x) - ax);
  78   81                          F_IM(ans) = y * y;
  79   82                  }
  80   83          } else if (ix == 0) {
  81      -                /* INDENT OFF */
       84 +                /* BEGIN CSTYLED */
  82   85                  /*
  83   86                   * x = 0
  84   87                   *      1                            1
  85   88                   * A = --- * atan2(2x, 1-x*x-y*y) = --- atan2(0,1-|y|)
  86   89                   *      2                            2
  87   90                   *
  88   91                   *     1     [ (y+1)*(y+1) ]   1          2      1         2y
  89   92                   * B = - log [ ----------- ] = - log (1+ ---) or - log(1+ ----)
  90   93                   *     4     [ (y-1)*(y-1) ]   2         y-1     2         1-y
  91   94                   */
  92      -                /* INDENT ON */
       95 +                /* END CSTYLED */
  93   96                  t = one - ay;
       97 +
  94   98                  if (iy == 0x3f800000) {
  95   99                          /* y=1: catan(0,1)=(0,+inf) with 1/0 signal */
  96  100                          F_IM(ans) = ay / ax;
  97  101                          F_RE(ans) = zero;
  98  102                  } else if (iy > 0x3f800000) {   /* y>1 */
  99  103                          F_IM(ans) = half * log1pf(two / (-t));
 100  104                          F_RE(ans) = pi_2;
 101      -                } else {                /* y<1 */
      105 +                } else {                        /* y<1 */
 102  106                          F_IM(ans) = half * log1pf((ay + ay) / t);
 103  107                          F_RE(ans) = zero;
 104  108                  }
 105  109          } else {
 106      -                /* INDENT OFF */
      110 +                /* BEGIN CSTYLED */
 107  111                  /*
 108  112                   * use double precision x,y
 109  113                   *      1
 110  114                   * A = --- * atan2(2x, 1-x*x-y*y)
 111  115                   *      2
 112  116                   *
 113  117                   *     1     [ x*x+(y+1)*(y+1) ]   1               4y
 114  118                   * B = - log [ --------------- ] = - log (1+ -----------------)
 115  119                   *     4     [ x*x+(y-1)*(y-1) ]   4         x*x + (y-1)*(y-1)
 116  120                   */
 117      -                /* INDENT ON */
      121 +                /* END CSTYLED */
      122 +
 118  123  #if defined(__i386) && !defined(__amd64)
 119      -                int     rp = __swapRP(fp_extended);
      124 +                int rp = __swapRP(fp_extended);
 120  125  #endif
 121  126                  dx = (double)ax;
 122  127                  dy = (double)ay;
 123      -                F_RE(ans) = (float)(0.5 * atan2(dx + dx,
 124      -                    1.0 - dx * dx - dy * dy));
      128 +                F_RE(ans) = (float)(0.5 * atan2(dx + dx, 1.0 - dx * dx - dy *
      129 +                    dy));
 125  130                  dt = dy - 1.0;
 126      -                F_IM(ans) = (float)(0.25 * log1p(4.0 * dy /
 127      -                    (dx * dx + dt * dt)));
      131 +                F_IM(ans) = (float)(0.25 * log1p(4.0 * dy / (dx * dx + dt *
      132 +                    dt)));
      133 +
 128  134  #if defined(__i386) && !defined(__amd64)
 129  135                  if (rp != fp_extended)
 130  136                          (void) __swapRP(rp);
 131  137  #endif
 132  138          }
      139 +
 133  140          if (hx < 0)
 134  141                  F_RE(ans) = -F_RE(ans);
      142 +
 135  143          if (hy < 0)
 136  144                  F_IM(ans) = -F_IM(ans);
      145 +
 137  146          return (ans);
 138  147  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX