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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/complex/clog.c
          +++ new/usr/src/lib/libm/common/complex/clog.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 clog = __clog
  30   32  
  31      -/* INDENT OFF */
       33 +
  32   34  /*
  33   35   * dcomplex clog(dcomplex z);
  34   36   *
  35   37   *                    _________
  36   38   *                   / 2    2            -1   y
  37   39   * log(x+iy) = log(\/ x  + y    ) + i tan   (---)
  38   40   *                                            x
  39   41   *
  40   42   *              1       2    2         -1   y
  41   43   *           = --- log(x  + y ) + i tan   (---)
↓ open down ↓ 9 lines elided ↑ open up ↑
  51   53   *    clog( x + i NaN ) =  NaN  + i NaN with invalid for finite x
  52   54   *    clog(-inf + iy   )=  +inf + i pi, for finite positive-signed y
  53   55   *    clog(+inf + iy   )=  +inf + i 0 , for finite positive-signed y
  54   56   *    clog(-inf + i inf)=  inf  + i 3pi/4
  55   57   *    clog(+inf + i inf)=  inf  + i pi/4
  56   58   *    clog(+-inf+ i NaN)=  inf  + i NaN
  57   59   *    clog(NaN  + i y  )=  NaN  + i NaN for finite y
  58   60   *    clog(NaN  + i inf)=  inf  + i NaN
  59   61   *    clog(NaN  + i NaN)=  NaN  + i NaN
  60   62   */
  61      -/* INDENT ON */
  62   63  
  63      -#include <math.h>               /* atan2/fabs/log/log1p */
       64 +#include <math.h>                       /* atan2/fabs/log/log1p */
  64   65  #include "complex_wrapper.h"
  65      -#include "libm_protos.h"        /* __k_clog_r */
  66      -
       66 +#include "libm_protos.h"                /* __k_clog_r */
  67   67  
  68   68  static const double half = 0.5, one = 1.0;
  69   69  
  70   70  dcomplex
  71      -__clog(dcomplex z) {
  72      -        dcomplex        ans;
  73      -        double          x, y, t, ax, ay, w;
  74      -        int             n, ix, iy, hx, hy;
  75      -        unsigned        lx, ly;
       71 +__clog(dcomplex z)
       72 +{
       73 +        dcomplex ans;
       74 +        double x, y, t, ax, ay, w;
       75 +        int n, ix, iy, hx, hy;
       76 +        unsigned lx, ly;
  76   77  
  77   78          x = D_RE(z);
  78   79          y = D_IM(z);
  79   80          hx = HI_WORD(x);
  80   81          lx = LO_WORD(x);
  81   82          hy = HI_WORD(y);
  82   83          ly = LO_WORD(y);
  83   84          ix = hx & 0x7fffffff;
  84   85          iy = hy & 0x7fffffff;
  85   86          ay = fabs(y);
  86   87          ax = fabs(x);
  87   88          D_IM(ans) = carg(z);
       89 +
  88   90          if (ix < iy || (ix == iy && lx < ly)) {
  89   91                  /* swap x and y to force ax >= ay */
  90   92                  t = ax;
  91   93                  ax = ay;
  92   94                  ay = t;
  93   95                  n = ix, ix = iy;
  94   96                  iy = n;
  95   97                  n = lx, lx = ly;
  96   98                  ly = n;
  97   99          }
      100 +
  98  101          n = (ix - iy) >> 20;
  99      -        if (ix >= 0x7ff00000) { /* x or y is Inf or NaN */
      102 +
      103 +        if (ix >= 0x7ff00000) {         /* x or y is Inf or NaN */
 100  104                  if (ISINF(ix, lx))
 101  105                          D_RE(ans) = ax;
 102  106                  else if (ISINF(iy, ly))
 103  107                          D_RE(ans) = ay;
 104  108                  else
 105  109                          D_RE(ans) = ax * ay;
 106  110          } else if ((iy | ly) == 0) {
 107      -                D_RE(ans) = ((ix | lx) == 0)? -one / ax : log(ax);
      111 +                D_RE(ans) = ((ix | lx) == 0) ? -one / ax : log(ax);
 108  112          } else if (((0x3fffffff - ix) ^ (ix - 0x3fe00000)) >= 0) {
 109  113                  /* 0.5 <= x < 2 */
 110  114                  if (ix >= 0x3ff00000) {
 111  115                          if (((ix - 0x3ff00000) | lx) == 0)
 112  116                                  D_RE(ans) = half * log1p(ay * ay);
 113  117                          else if (n >= 60)
 114  118                                  D_RE(ans) = log(ax);
 115  119                          else
 116      -                                D_RE(ans) = half * (log1p(ay * ay + (ax -
 117      -                                    one) * (ax + one)));
      120 +                                D_RE(ans) = half * (log1p(ay * ay + (ax - one) *
      121 +                                    (ax + one)));
 118  122                  } else if (n >= 60) {
 119  123                          D_RE(ans) = log(ax);
 120  124                  } else {
 121  125                          D_RE(ans) = __k_clog_r(ax, ay, &w);
 122  126                  }
 123  127          } else if (n >= 30) {
 124  128                  D_RE(ans) = log(ax);
 125  129          } else if (ix < 0x5f300000 && iy >= 0x20b00000) {
 126  130                  /* 2**-500< y < x < 2**500 */
 127  131                  D_RE(ans) = half * log(ax * ax + ay * ay);
 128  132          } else {
 129  133                  t = ay / ax;
 130  134                  D_RE(ans) = log(ax) + half * log1p(t * t);
 131  135          }
      136 +
 132  137          return (ans);
 133  138  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX