Print this page




  59 #define S0      C[0]
  60 #define S1      C[1]
  61 #define S2      C[2]
  62 #define S3      C[3]
  63 #define C0      C[4]
  64 #define C1      C[5]
  65 #define C2      C[6]
  66 #define C3      C[7]
  67 #define C4      C[8]
  68 #define invpio2 C[9]
  69 #define half    C[10]
  70 #define pio2_1  C[11]
  71 #define pio2_t  C[12]
  72 
  73 float
  74 cosf(float x)
  75 {
  76         double  y, z, w;
  77         float   f;
  78         int     n, ix, hx, hy;

  79 
  80         hx = *((int *)&x);
  81         ix = hx & 0x7fffffff;
  82 
  83         y = (double)x;
  84 
  85         if (ix <= 0x4016cbe4) {              /* |x| < 3*pi/4 */
  86                 if (ix <= 0x3f490fdb) {              /* |x| < pi/4 */
  87                         if (ix <= 0x39800000) {      /* |x| <= 2**-12 */
  88                                 volatile int    i = (int)y;
  89 #ifdef lint
  90                                 i = i;
  91 #endif
  92                                 return (1.0f);
  93                         }
  94                         z = y * y;
  95                         return ((float)(((C0 + z * C1) + (z * z) * C2) *
  96                             (C3 + z * (C4 + z))));
  97                 } else if (hx > 0) {
  98                         y = (y - pio2_1) - pio2_t;
  99                         z = y * y;
 100                         return ((float)-((y * (S0 + z * S1)) *
 101                             (S2 + z * (S3 + z))));
 102                 } else {
 103                         y = (y + pio2_1) + pio2_t;
 104                         z = y * y;
 105                         return ((float)((y * (S0 + z * S1)) *
 106                             (S2 + z * (S3 + z))));
 107                 }
 108         } else if (ix <= 0x49c90fdb) {       /* |x| < 2^19*pi */




  59 #define S0      C[0]
  60 #define S1      C[1]
  61 #define S2      C[2]
  62 #define S3      C[3]
  63 #define C0      C[4]
  64 #define C1      C[5]
  65 #define C2      C[6]
  66 #define C3      C[7]
  67 #define C4      C[8]
  68 #define invpio2 C[9]
  69 #define half    C[10]
  70 #define pio2_1  C[11]
  71 #define pio2_t  C[12]
  72 
  73 float
  74 cosf(float x)
  75 {
  76         double  y, z, w;
  77         float   f;
  78         int     n, ix, hx, hy;
  79         volatile int i;
  80 
  81         hx = *((int *)&x);
  82         ix = hx & 0x7fffffff;
  83 
  84         y = (double)x;
  85 
  86         if (ix <= 0x4016cbe4) {              /* |x| < 3*pi/4 */
  87                 if (ix <= 0x3f490fdb) {              /* |x| < pi/4 */
  88                         if (ix <= 0x39800000) {      /* |x| <= 2**-12 */
  89                                 i = (int)y;
  90 #ifdef lint
  91                                 i = i;
  92 #endif
  93                                 return (1.0f);
  94                         }
  95                         z = y * y;
  96                         return ((float)(((C0 + z * C1) + (z * z) * C2) *
  97                             (C3 + z * (C4 + z))));
  98                 } else if (hx > 0) {
  99                         y = (y - pio2_1) - pio2_t;
 100                         z = y * y;
 101                         return ((float)-((y * (S0 + z * S1)) *
 102                             (S2 + z * (S3 + z))));
 103                 } else {
 104                         y = (y + pio2_1) + pio2_t;
 105                         z = y * y;
 106                         return ((float)((y * (S0 + z * S1)) *
 107                             (S2 + z * (S3 + z))));
 108                 }
 109         } else if (ix <= 0x49c90fdb) {       /* |x| < 2^19*pi */