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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/complex/cexp.c
          +++ new/usr/src/lib/libm/common/complex/cexp.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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   23   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
       25 +
  25   26  /*
  26   27   * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  #pragma weak __cexp = cexp
  31   32  
  32      -/* INDENT OFF */
       33 +
  33   34  /*
  34   35   * dcomplex cexp(dcomplex z);
  35   36   *
  36   37   *  x+iy    x
  37   38   * e     = e  (cos(y)+i*sin(y))
  38   39   *
  39   40   * Over/underflow issue
  40   41   * --------------------
  41   42   * exp(x) may be huge but cos(y) or sin(y) may be tiny. So we use
  42   43   * function __k_cexp(x,&n) to return exp(x) = __k_cexp(x,&n)*2**n.
↓ open down ↓ 6 lines elided ↑ open up ↑
  49   50   *      (-inf, y) --> (+-0, +-0)     for y = inf, nan
  50   51   *      (x,+-inf/NaN) --> (NaN,NaN)  for finite x
  51   52   * For all other cases, return
  52   53   *      (x,y) --> exp(x)*cos(y)+i*exp(x)*sin(y))
  53   54   *
  54   55   * Algorithm for out of range x and finite y
  55   56   *      1. compute exp(x) in factor form (t=__k_cexp(x,&n))*2**n
  56   57   *      2. compute sincos(y,&s,&c)
  57   58   *      3. compute t*s+i*(t*c), then scale back to 2**n and return.
  58   59   */
  59      -/* INDENT ON */
  60   60  
  61      -#include "libm.h"               /* exp/scalbn/sincos/__k_cexp */
       61 +#include "libm.h"                       /* exp/scalbn/sincos/__k_cexp */
  62   62  #include "complex_wrapper.h"
  63   63  
  64   64  static const double zero = 0.0;
  65   65  
  66   66  dcomplex
  67      -cexp(dcomplex z) {
       67 +cexp(dcomplex z)
       68 +{
  68   69          dcomplex ans;
  69   70          double x, y, t, c, s;
  70   71          int n, ix, iy, hx, hy, lx, ly;
  71   72  
  72   73          x = D_RE(z);
  73   74          y = D_IM(z);
  74   75          hx = HI_WORD(x);
  75   76          lx = LO_WORD(x);
  76   77          hy = HI_WORD(y);
  77   78          ly = LO_WORD(y);
  78   79          ix = hx & 0x7fffffff;
  79   80          iy = hy & 0x7fffffff;
  80      -        if ((iy | ly) == 0) {   /* y = 0 */
       81 +
       82 +        if ((iy | ly) == 0) {           /* y = 0 */
  81   83                  D_RE(ans) = exp(x);
  82   84                  D_IM(ans) = y;
  83   85          } else if (ISINF(ix, lx)) {     /* x is +-inf */
  84   86                  if (hx < 0) {
  85   87                          if (iy >= 0x7ff00000) {
  86   88                                  D_RE(ans) = zero;
  87   89                                  D_IM(ans) = zero;
  88   90                          } else {
  89   91                                  sincos(y, &s, &c);
  90   92                                  D_RE(ans) = zero * c;
↓ open down ↓ 4 lines elided ↑ open up ↑
  95   97                                  D_RE(ans) = x;
  96   98                                  D_IM(ans) = y - y;
  97   99                          } else {
  98  100                                  (void) sincos(y, &s, &c);
  99  101                                  D_RE(ans) = x * c;
 100  102                                  D_IM(ans) = x * s;
 101  103                          }
 102  104                  }
 103  105          } else {
 104  106                  (void) sincos(y, &s, &c);
      107 +
 105  108                  if (ix >= 0x40862E42) { /* |x| > 709.78... ~ log(2**1024) */
 106  109                          t = __k_cexp(x, &n);
 107  110                          D_RE(ans) = scalbn(t * c, n);
 108  111                          D_IM(ans) = scalbn(t * s, n);
 109  112                  } else {
 110  113                          t = exp(x);
 111  114                          D_RE(ans) = t * c;
 112  115                          D_IM(ans) = t * s;
 113  116                  }
 114  117          }
      118 +
 115  119          return (ans);
 116  120  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX