Back to index

glibc  2.9
Defines | Functions | Variables
k_sinl.c File Reference
#include "math.h"
#include "math_private.h"

Go to the source code of this file.

Defines

#define ONE   c[0]
#define SCOS1   c[1]
#define SCOS2   c[2]
#define SCOS3   c[3]
#define SCOS4   c[4]
#define SCOS5   c[5]
#define SIN1   c[6]
#define SIN2   c[7]
#define SIN3   c[8]
#define SIN4   c[9]
#define SIN5   c[10]
#define SIN6   c[11]
#define SIN7   c[12]
#define SIN8   c[13]
#define SSIN1   c[14]
#define SSIN2   c[15]
#define SSIN3   c[16]
#define SSIN4   c[17]
#define SSIN5   c[18]
#define SINCOSL_COS_HI   0
#define SINCOSL_COS_LO   1
#define SINCOSL_SIN_HI   2
#define SINCOSL_SIN_LO   3

Functions

long double __kernel_sinl (long double x, long double y, int iy)

Variables

static const long double c []
const long double __sincosl_table []

Define Documentation

#define ONE   c[0]
#define SCOS1   c[1]
#define SCOS2   c[2]
#define SCOS3   c[3]
#define SCOS4   c[4]
#define SCOS5   c[5]
#define SIN1   c[6]
#define SIN2   c[7]
#define SIN3   c[8]
#define SIN4   c[9]
#define SIN5   c[10]
#define SIN6   c[11]
#define SIN7   c[12]
#define SIN8   c[13]
#define SINCOSL_COS_HI   0

Definition at line 74 of file k_sinl.c.

#define SINCOSL_COS_LO   1

Definition at line 75 of file k_sinl.c.

#define SINCOSL_SIN_HI   2

Definition at line 76 of file k_sinl.c.

#define SINCOSL_SIN_LO   3

Definition at line 77 of file k_sinl.c.

#define SSIN1   c[14]
#define SSIN2   c[15]
#define SSIN3   c[16]
#define SSIN4   c[17]
#define SSIN5   c[18]

Function Documentation

long double __kernel_sinl ( long double  x,
long double  y,
int  iy 
)

Definition at line 81 of file k_sinl.c.

{
  long double h, l, z, sin_l, cos_l_m1;
  int64_t ix;
  u_int32_t tix, hix, index;
  GET_LDOUBLE_MSW64 (ix, x);
  tix = ((u_int64_t)ix) >> 32;
  tix &= ~0x80000000;                     /* tix = |x|'s high 32 bits */
  if (tix < 0x3ffc3000)                   /* |x| < 0.1484375 */
    {
      /* Argument is small enough to approximate it by a Chebyshev
        polynomial of degree 17.  */
      if (tix < 0x3fc60000)        /* |x| < 2^-57 */
       if (!((int)x)) return x;    /* generate inexact */
      z = x * x;
      return x + (x * (z*(SIN1+z*(SIN2+z*(SIN3+z*(SIN4+
                     z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8)))))))));
    }
  else
    {
      /* So that we don't have to use too large polynomial,  we find
        l and h such that x = l + h,  where fabsl(l) <= 1.0/256 with 83
        possible values for h.  We look up cosl(h) and sinl(h) in
        pre-computed tables,  compute cosl(l) and sinl(l) using a
        Chebyshev polynomial of degree 10(11) and compute
        sinl(h+l) = sinl(h)cosl(l) + cosl(h)sinl(l).  */
      index = 0x3ffe - (tix >> 16);
      hix = (tix + (0x200 << index)) & (0xfffffc00 << index);
      x = fabsl (x);
      switch (index)
       {
       case 0: index = ((45 << 10) + hix - 0x3ffe0000) >> 8; break;
       case 1: index = ((13 << 11) + hix - 0x3ffd0000) >> 9; break;
       default:
       case 2: index = (hix - 0x3ffc3000) >> 10; break;
       }

      SET_LDOUBLE_WORDS64(h, ((u_int64_t)hix) << 32, 0);
      if (iy)
       l = y - (h - x);
      else
       l = x - h;
      z = l * l;
      sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5)))));
      cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5))));
      z = __sincosl_table [index + SINCOSL_SIN_HI]
         + (__sincosl_table [index + SINCOSL_SIN_LO]
            + (__sincosl_table [index + SINCOSL_SIN_HI] * cos_l_m1)
            + (__sincosl_table [index + SINCOSL_COS_HI] * sin_l));
      return (ix < 0) ? -z : z;
    }
}

Here is the call graph for this function:


Variable Documentation

const long double __sincosl_table[]

Definition at line 29 of file t_sincosl.c.

const long double c[] [static]

Definition at line 24 of file k_sinl.c.