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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/__tanl.c
          +++ new/usr/src/lib/libm/common/Q/__tanl.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  /*
  31   32   * long double __k_tanl(long double x; long double y, int k);
  32   33   * kernel tan/cotan function on [-pi/4, pi/4], pi/4 ~ 0.785398164
  33   34   * Input x is assumed to be bounded by ~pi/4 in magnitude.
  34   35   * Input y is the tail of x.
↓ open down ↓ 4 lines elided ↑ open up ↑
  39   40   *      2. if x < 5/32 = [0x3ffc4000, 0] = 0.15625 , then
  40   41   *           if x < 2^-57 (hx < 0x3fc40000 0), set w=x with inexact if x !=  0
  41   42   *           else
  42   43   *              z = x*x;
  43   44   *              w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6))))))
  44   45   *         return (k == 0)? w: 1/w;
  45   46   *      3. else
  46   47   *              ht = (hx + 0x400)&0x7ffff800    (round x to a break point t)
  47   48   *              lt = 0
  48   49   *              i  = (hy-0x3ffc4000)>>11;       (i<=64)
  49      - *              x' = (x - t)+y                  (|x'| ~<= 2^-7)
       50 + *              x' = (x - t)+y                  (|x'| ~<= 2^-7)
  50   51   *         By
  51   52   *              tan(t+x')
  52   53   *                = (tan(t)+tan(x'))/(1-tan(x')tan(t))
  53   54   *         We have
  54   55   *                           sin(x')+tan(t)*(tan(t)*sin(x'))
  55   56   *                = tan(t) + -------------------------------    for k=0
  56   57   *                              cos(x') - tan(t)*sin(x')
  57   58   *
  58   59   *                           cos(x') - tan(t)*sin(x')
  59   60   *                = - --------------------------------------    for k=1
  60   61   *                     tan(t) + tan(t)*(cos(x')-1) + sin(x')
  61   62   *
  62   63   *
  63      - *         where        tan(t) is from the table,
       64 + *         where        tan(t) is from the table,
  64   65   *                      sin(x') = x + pp1*x^3 + ...+ pp5*x^11
  65   66   *                      cos(x') = 1 + qq1*x^2 + ...+ qq5*x^10
  66   67   */
  67   68  
  68   69  #include "libm.h"
  69   70  
  70   71  extern const long double _TBL_tanl_hi[], _TBL_tanl_lo[];
  71      -static const long double
  72      -        one     = 1.0L,
       72 +static const long double one = 1.0L;
       73 +
  73   74  /*
  74   75   *                   3           11       -122.32
  75   76   * |sin(x) - (x+pp1*x +...+ pp5*x  )| <= 2        for |x|<1/64
  76   77   */
  77      -        pp1     = -1.666666666666666666666666666586782940810e-0001L,
  78      -        pp2     = +8.333333333333333333333003723660929317540e-0003L,
  79      -        pp3     = -1.984126984126984076045903483778337804470e-0004L,
  80      -        pp4     = +2.755731922361906641319723106210900949413e-0006L,
  81      -        pp5     = -2.505198398570947019093998469135012057673e-0008L,
       78 +static const long double
       79 +        pp1 = -1.666666666666666666666666666586782940810e-0001L,
       80 +        pp2 = +8.333333333333333333333003723660929317540e-0003L,
       81 +        pp3 = -1.984126984126984076045903483778337804470e-0004L,
       82 +        pp4 = +2.755731922361906641319723106210900949413e-0006L,
       83 +        pp5 = -2.505198398570947019093998469135012057673e-0008L;
       84 +
  82   85  /*
  83   86   *                   2           10        -123.84
  84   87   * |cos(x) - (1+qq1*x +...+ qq5*x  )| <= 2        for |x|<=1/128
  85   88   */
  86      -        qq1     = -4.999999999999999999999999999999378373641e-0001L,
  87      -        qq2     = +4.166666666666666666666665478399327703130e-0002L,
  88      -        qq3     = -1.388888888888888888058211230618051613494e-0003L,
  89      -        qq4     = +2.480158730156105377771585658905303111866e-0005L,
  90      -        qq5     = -2.755728099762526325736488376695157008736e-0007L,
       89 +static const long double
       90 +        qq1 = -4.999999999999999999999999999999378373641e-0001L,
       91 +        qq2 = +4.166666666666666666666665478399327703130e-0002L,
       92 +        qq3 = -1.388888888888888888058211230618051613494e-0003L,
       93 +        qq4 = +2.480158730156105377771585658905303111866e-0005L,
       94 +        qq5 = -2.755728099762526325736488376695157008736e-0007L;
       95 +
  91   96  /*
  92   97   * |tan(x) - (x+t1*x^3+...+t6*x^13)|
  93   98   * |------------------------------ | <= 2^-59.73 for |x|<0.15625
  94   99   * |                x              |
  95  100   */
  96      -        t1      = +3.333333333333333333333333333333423342490e-0001L,
  97      -        t2      = +1.333333333333333333333333333093838744537e-0001L,
  98      -        t3      = +5.396825396825396825396827906318682662250e-0002L,
  99      -        t4      = +2.186948853615520282185576976994418486911e-0002L,
 100      -        t5      = +8.863235529902196573354554519991152936246e-0003L,
 101      -        t6      = +3.592128036572480064652191427543994878790e-0003L,
 102      -        t7      = +1.455834387051455257856833807581901305474e-0003L,
 103      -        t8      = +5.900274409318599857829983256201725587477e-0004L,
 104      -        t9      = +2.391291152117265181501116961901122362937e-0004L,
 105      -        t10     = +9.691533169382729742394024173194981882375e-0005L,
 106      -        t11     = +3.927994733186415603228178184225780859951e-0005L,
 107      -        t12     = +1.588300018848323824227640064883334101288e-0005L,
 108      -        t13     = +6.916271223396808311166202285131722231723e-0006L;
      101 +static const long double
      102 +        t1 = +3.333333333333333333333333333333423342490e-0001L,
      103 +        t2 = +1.333333333333333333333333333093838744537e-0001L,
      104 +        t3 = +5.396825396825396825396827906318682662250e-0002L,
      105 +        t4 = +2.186948853615520282185576976994418486911e-0002L,
      106 +        t5 = +8.863235529902196573354554519991152936246e-0003L,
      107 +        t6 = +3.592128036572480064652191427543994878790e-0003L,
      108 +        t7 = +1.455834387051455257856833807581901305474e-0003L,
      109 +        t8 = +5.900274409318599857829983256201725587477e-0004L,
      110 +        t9 = +2.391291152117265181501116961901122362937e-0004L,
      111 +        t10 = +9.691533169382729742394024173194981882375e-0005L,
      112 +        t11 = +3.927994733186415603228178184225780859951e-0005L,
      113 +        t12 = +1.588300018848323824227640064883334101288e-0005L,
      114 +        t13 = +6.916271223396808311166202285131722231723e-0006L;
 109  115  
 110  116  #define i0      0
 111  117  
 112  118  long double
 113      -__k_tanl(long double x, long double y, int k) {
      119 +__k_tanl(long double x, long double y, int k)
      120 +{
 114  121          long double a, t, z, w = 0, s, c;
 115      -        int *pt = (int *) &t, *px = (int *) &x;
      122 +        int *pt = (int *)&t, *px = (int *)&x;
 116  123          int i, j, hx, ix;
 117  124  
 118  125          t = 1.0L;
 119  126          hx = px[i0];
 120  127          ix = hx & 0x7fffffff;
      128 +
 121  129          if (ix < 0x3ffc4000) {
 122      -                *(3 - i0 + (int *) &t) = 1;     /* make t = one+ulp */
      130 +                *(3 - i0 + (int *)&t) = 1;      /* make t = one+ulp */
      131 +
 123  132                  if (ix < 0x3fc60000) {
 124      -                        if (((int) (x * t)) < 1)        /* generate inexact */
 125      -                                w = x;  /* generate underflow if subnormal */
      133 +                        if (((int)(x * t)) < 1) /* generate inexact */
      134 +                                w = x; /* generate underflow if subnormal */
 126  135                  } else {
 127  136                          z = x * x;
 128      -                        if (ix < 0x3ff30000)    /* 2**-12 */
      137 +
      138 +                        if (ix < 0x3ff30000) {  /* 2**-12 */
 129  139                                  t = z * (t1 + z * (t2 + z * (t3 + z * t4)));
 130      -                        else
 131      -                                t = z * (t1 + z * (t2 + z * (t3 + z * (t4 +
 132      -                                        z * (t5 + z * (t6 + z * (t7 + z * (t8 +
 133      -                                        z * (t9 + z * (t10 + z * (t11 +
 134      -                                        z * (t12 + z * t13))))))))))));
      140 +                        } else {
      141 +                                t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + z *
      142 +                                    (t5 + z * (t6 + z * (t7 + z * (t8 + z *
      143 +                                    (t9 + z * (t10 + z * (t11 + z * (t12 + z *
      144 +                                    t13))))))))))));
      145 +                        }
      146 +
 135  147                          t = y + x * t;
 136  148                          w = x + t;
 137  149                  }
      150 +
 138  151                  return (k == 0 ? w : -one / w);
 139  152          }
      153 +
 140  154          j = (ix + 0x400) & 0x7ffff800;
 141  155          i = (j - 0x3ffc4000) >> 11;
 142  156          pt[i0] = j;
      157 +
 143  158          if (hx > 0)
 144  159                  x = y - (t - x);
 145  160          else
 146  161                  x = (-y) - (t + x);
      162 +
 147  163          a = _TBL_tanl_hi[i];
 148  164          z = x * x;
 149  165          /* cos(x)-1 */
 150  166          t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
 151  167          /* sin(x) */
 152  168          s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5)))));
      169 +
 153  170          if (k == 0) {
 154  171                  w = a * s;
 155  172                  t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t));
 156  173                  return (hx < 0 ? -a - t : a + t);
 157  174          } else {
 158  175                  w = s + a * t;
 159  176                  c = w + _TBL_tanl_lo[i];
 160  177                  z = one - (a * s - t);
 161  178                  return (hx >= 0 ? z / (-a - c) : z / (a + c));
 162  179          }
 163  180  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX