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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/complex/ctanhf.c
          +++ new/usr/src/lib/libm/common/complex/ctanhf.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 __ctanhf = ctanhf
  31   32  
  32      -#include "libm.h"               /* expf/expm1f/fabsf/sincosf/sinf/tanhf */
       33 +#include "libm.h"       /* expf/expm1f/fabsf/sincosf/sinf/tanhf */
  33   34  #include "complex_wrapper.h"
  34   35  
  35      -/* INDENT OFF */
  36   36  static const float four = 4.0F, two = 2.0F, one = 1.0F, zero = 0.0F;
  37      -/* INDENT ON */
       37 +
  38   38  
  39   39  fcomplex
  40      -ctanhf(fcomplex z) {
       40 +ctanhf(fcomplex z)
       41 +{
  41   42          float r, u, v, t, x, y, S, C;
  42   43          int hx, ix, hy, iy;
  43   44          fcomplex ans;
  44   45  
  45   46          x = F_RE(z);
  46   47          y = F_IM(z);
  47   48          hx = THE_WORD(x);
  48   49          ix = hx & 0x7fffffff;
  49   50          hy = THE_WORD(y);
  50   51          iy = hy & 0x7fffffff;
  51   52          x = fabsf(x);
  52   53          y = fabsf(y);
  53   54  
  54   55          if (iy == 0) {          /* ctanh(x,0) = (x,0) for x = 0 or NaN */
  55   56                  F_RE(ans) = tanhf(x);
  56   57                  F_IM(ans) = zero;
  57      -        } else if (iy >= 0x7f800000) {  /* y is inf or NaN */
  58      -                if (ix < 0x7f800000)    /* catanh(finite x,inf/nan) is nan */
       58 +        } else if (iy >= 0x7f800000) { /* y is inf or NaN */
       59 +                if (ix < 0x7f800000) { /* catanh(finite x,inf/nan) is nan */
  59   60                          F_RE(ans) = F_IM(ans) = y - y;
  60      -                else if (ix == 0x7f800000) {    /* x is inf */
       61 +                } else if (ix == 0x7f800000) {  /* x is inf */
  61   62                          F_RE(ans) = one;
  62   63                          F_IM(ans) = zero;
  63   64                  } else {
  64   65                          F_RE(ans) = x + y;
  65   66                          F_IM(ans) = y - y;
  66   67                  }
  67   68          } else if (ix >= 0x41600000) {
  68   69                  /*
  69   70                   * |x| > 14 = prec/2 (14,28,34,60)
  70   71                   * ctanh z ~ 1 + i (sin2y)/(exp(2x))
  71   72                   */
  72   73                  F_RE(ans) = one;
  73      -                if (iy < 0x7f000000)    /* t = sin(2y) */
       74 +
       75 +                if (iy < 0x7f000000) {  /* t = sin(2y) */
  74   76                          S = sinf(y + y);
  75      -                else {
       77 +                } else {
  76   78                          (void) sincosf(y, &S, &C);
  77   79                          S = (S + S) * C;
  78   80                  }
  79      -                if (ix >= 0x7f000000) { /* |x| > max/2 */
       81 +
       82 +                if (ix >= 0x7f000000) {         /* |x| > max/2 */
  80   83                          if (ix >= 0x7f800000) { /* |x| is inf or NaN */
  81      -                                if (ix > 0x7f800000)    /* x is NaN */
       84 +                                if (ix > 0x7f800000)            /* x is NaN */
  82   85                                          F_RE(ans) = F_IM(ans) = x + y;
  83   86                                  else
  84   87                                          F_IM(ans) = zero * S;   /* x is inf */
  85      -                        } else
       88 +                        } else {
  86   89                                  F_IM(ans) = S * expf(-x);       /* underflow */
  87      -                } else
       90 +                        }
       91 +                } else {
  88   92                          F_IM(ans) = (S + S) * expf(-(x + x));
  89      -                                                        /* 2 sin 2y / exp(2x) */
       93 +                }
       94 +
       95 +                /* 2 sin 2y / exp(2x) */
  90   96          } else {
  91      -                /* INDENT OFF */
       97 +                /* BEGIN CSTYLED */
  92   98                  /*
  93   99                   *                        t*t+2t
  94  100                   *    ctanh z = ---------------------------
  95  101                   *               t*t+[4(t+1)(cos y)](cos y)
  96  102                   *
  97  103                   *                  [4(t+1)(cos y)]*(sin y)
  98  104                   *              i --------------------------
  99  105                   *                t*t+[4(t+1)(cos y)](cos y)
 100  106                   */
 101      -                /* INDENT ON */
      107 +                /* END CSTYLED */
 102  108                  (void) sincosf(y, &S, &C);
 103  109                  t = expm1f(x + x);
 104  110                  r = (four * C) * (t + one);
 105  111                  u = t * t;
 106  112                  v = one / (u + r * C);
 107  113                  F_RE(ans) = (u + two * t) * v;
 108  114                  F_IM(ans) = (r * S) * v;
 109  115          }
      116 +
 110  117          if (hx < 0)
 111  118                  F_RE(ans) = -F_RE(ans);
      119 +
 112  120          if (hy < 0)
 113  121                  F_IM(ans) = -F_IM(ans);
      122 +
 114  123          return (ans);
 115  124  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX