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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libm/common/Q/__sinl.c
          +++ new/usr/src/lib/libm/common/Q/__sinl.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_sinl(long double x, long double y);
  32   33   * kernel sin 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   *           if x < 2^-57 (hx < 0x3fc60000,0,0,0), return x (inexact if x !=  0)
  40   41   *           z = x*x;
  41   42   *           if x <= 1/64 = 2**-6
  42   43   *              sin(x) = x + (y+(x*z)*(p1 + z*p2))
  43   44   *           else
  44   45   *              sin(x) = x + (y+(x*z)*(p1 + z*(p2 + z*(p3 + z*p4))))
  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   *              sin(t+x')
  52   53   *                = sin(t)cos(x')+cos(t)sin(x')
  53   54   *                = sin(t)(1+z*(qq1+z*qq2))+[cos(t)]*x*(1+z*(pp1+z*pp2))
  54   55   *                = sin(t) + [sin(t)]*(z*(qq1+z*qq2))+
  55   56   *                              [cos(t)]*x*(1+z*(pp1+z*pp2))
  56   57   *
  57   58   *         Thus,
  58   59   *              let a= _TBL_sin_hi[i], b = _TBL_sin_lo[i], c= _TBL_cos_hi[i],
  59   60   *              x = (x-t)+y
  60   61   *              z = x*x;
  61   62   *              sin(t+x) = a+(b+ ((c*x)*(1+z*(pp1+z*pp2))+a*(z*(qq1+z*qq2)))
  62   63   */
  63   64  
  64   65  #include "libm.h"
  65   66  
  66   67  extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[];
  67      -static const long double
  68      -one     = 1.0L,
       68 +static const long double one = 1.0L;
       69 +
  69   70  /*
  70   71   *                   3           11       -122.32
  71   72   * |sin(x) - (x+pp1*x +...+ pp5*x  )| <= 2        for |x|<1/64
  72   73   */
  73      -        pp1     = -1.666666666666666666666666666586782940810e-0001L,
  74      -        pp2     = +8.333333333333333333333003723660929317540e-0003L,
  75      -        pp3     = -1.984126984126984076045903483778337804470e-0004L,
  76      -        pp4     = +2.755731922361906641319723106210900949413e-0006L,
  77      -        pp5     = -2.505198398570947019093998469135012057673e-0008L,
       74 +static const long double
       75 +        pp1 = -1.666666666666666666666666666586782940810e-0001L,
       76 +        pp2 = +8.333333333333333333333003723660929317540e-0003L,
       77 +        pp3 = -1.984126984126984076045903483778337804470e-0004L,
       78 +        pp4 = +2.755731922361906641319723106210900949413e-0006L,
       79 +        pp5 = -2.505198398570947019093998469135012057673e-0008L;
       80 +
  78   81  /*
  79   82   * |(sin(x) - (x+p1*x^3+...+p8*x^17)|
  80   83   * |------------------------------- | <= 2^-116.17 for |x|<0.1953125
  81   84   * |                 x              |
  82   85   */
  83      -        p1      = -1.666666666666666666666666666666211262297e-0001L,
  84      -        p2      = +8.333333333333333333333333301497876908541e-0003L,
  85      -        p3      = -1.984126984126984126984041302881180621922e-0004L,
  86      -        p4      = +2.755731922398589064100587351307269621093e-0006L,
  87      -        p5      = -2.505210838544163129378906953765595393873e-0008L,
  88      -        p6      = +1.605904383643244375050998243778534074273e-0010L,
  89      -        p7      = -7.647162722800685516901456114270824622699e-0013L,
  90      -        p8      = +2.810046428661902961725428841068844462603e-0015L,
       86 +static const long double
       87 +        p1 = -1.666666666666666666666666666666211262297e-0001L,
       88 +        p2 = +8.333333333333333333333333301497876908541e-0003L,
       89 +        p3 = -1.984126984126984126984041302881180621922e-0004L,
       90 +        p4 = +2.755731922398589064100587351307269621093e-0006L,
       91 +        p5 = -2.505210838544163129378906953765595393873e-0008L,
       92 +        p6 = +1.605904383643244375050998243778534074273e-0010L,
       93 +        p7 = -7.647162722800685516901456114270824622699e-0013L,
       94 +        p8 = +2.810046428661902961725428841068844462603e-0015L;
       95 +
  91   96  /*
  92   97   *                   2           10        -123.84
  93   98   * |cos(x) - (1+qq1*x +...+ qq5*x  )| <= 2        for |x|<=1/128
  94   99   */
  95      -        qq1     = -4.999999999999999999999999999999378373641e-0001L,
  96      -        qq2     = +4.166666666666666666666665478399327703130e-0002L,
  97      -        qq3     = -1.388888888888888888058211230618051613494e-0003L,
  98      -        qq4     = +2.480158730156105377771585658905303111866e-0005L,
  99      -        qq5     = -2.755728099762526325736488376695157008736e-0007L;
      100 +static const long double
      101 +        qq1 = -4.999999999999999999999999999999378373641e-0001L,
      102 +        qq2 = +4.166666666666666666666665478399327703130e-0002L,
      103 +        qq3 = -1.388888888888888888058211230618051613494e-0003L,
      104 +        qq4 = +2.480158730156105377771585658905303111866e-0005L,
      105 +        qq5 = -2.755728099762526325736488376695157008736e-0007L;
 100  106  
 101  107  #define i0      0
 102  108  
 103  109  long double
 104      -__k_sinl(long double x, long double y) {
      110 +__k_sinl(long double x, long double y)
      111 +{
 105  112          long double a, t, z, w;
 106      -        int *pt = (int *) &t, *px = (int *) &x;
      113 +        int *pt = (int *)&t, *px = (int *)&x;
 107  114          int i, j, hx, ix;
 108  115  
 109  116          t = 1.0L;
 110  117          hx = px[i0];
 111  118          ix = hx & 0x7fffffff;
      119 +
 112  120          if (ix < 0x3ffc9000) {
 113      -                *(3 - i0 + (int *) &t) = -1;    /* one-ulp */
 114      -                *(2 + (int *) &t) = -1; /* one-ulp */
 115      -                *(1 + (int *) &t) = -1; /* one-ulp */
 116      -                *(i0 + (int *) &t) -= 1;        /* one-ulp */
      121 +                *(3 - i0 + (int *)&t) = -1;     /* one-ulp */
      122 +                *(2 + (int *)&t) = -1;          /* one-ulp */
      123 +                *(1 + (int *)&t) = -1;          /* one-ulp */
      124 +                *(i0 + (int *)&t) -= 1;         /* one-ulp */
      125 +
 117  126                  if (ix < 0x3fc60000)
 118      -                        if (((int) (x * t)) < 1)
 119      -                                return (x);     /* inexact and underflow */
      127 +                        if (((int)(x * t)) < 1)
      128 +                                return (x);
      129 +
      130 +                /* inexact and underflow */
 120  131                  z = x * x;
 121      -                t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 +
 122      -                        z * (p6 + z * (p7 + z * p8)))))));
      132 +                t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 + z * (p6 +
      133 +                    z * (p7 + z * p8)))))));
 123  134                  t = y + x * t;
 124  135                  return (x + t);
 125  136          }
      137 +
 126  138          j = (ix + 0x400) & 0x7ffff800;
 127  139          i = (j - 0x3ffc4000) >> 11;
 128  140          pt[i0] = j;
      141 +
 129  142          if (hx > 0)
 130  143                  x = y - (t - x);
 131  144          else
 132  145                  x = (-y) - (t + x);
      146 +
 133  147          a = _TBL_sinl_hi[i];
 134  148          z = x * x;
 135  149          t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
 136  150          w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5)))));
 137  151          t = _TBL_cosl_hi[i] * w + a * t;
 138  152          t += _TBL_sinl_lo[i];
      153 +
 139  154          if (hx < 0)
 140  155                  return (-a - t);
 141  156          else
 142  157                  return (a + t);
 143  158  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX