Back to index

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

Go to the source code of this file.

Functions

static double sin_pi (double x)
double __ieee754_lgamma_r (double x, int *signgamp)

Variables

static double two52 = 4.50359962737049600000e+15
static double half = 5.00000000000000000000e-01
static double one = 1.00000000000000000000e+00
static double pi = 3.14159265358979311600e+00
static double a0 = 7.72156649015328655494e-02
static double a1 = 3.22467033424113591611e-01
static double a2 = 6.73523010531292681824e-02
static double a3 = 2.05808084325167332806e-02
static double a4 = 7.38555086081402883957e-03
static double a5 = 2.89051383673415629091e-03
static double a6 = 1.19270763183362067845e-03
static double a7 = 5.10069792153511336608e-04
static double a8 = 2.20862790713908385557e-04
static double a9 = 1.08011567247583939954e-04
static double a10 = 2.52144565451257326939e-05
static double a11 = 4.48640949618915160150e-05
static double tc = 1.46163214496836224576e+00
static double tf = -1.21486290535849611461e-01
static double tt = -3.63867699703950536541e-18
static double t0 = 4.83836122723810047042e-01
static double t1 = -1.47587722994593911752e-01
static double t2 = 6.46249402391333854778e-02
static double t3 = -3.27885410759859649565e-02
static double t4 = 1.79706750811820387126e-02
static double t5 = -1.03142241298341437450e-02
static double t6 = 6.10053870246291332635e-03
static double t7 = -3.68452016781138256760e-03
static double t8 = 2.25964780900612472250e-03
static double t9 = -1.40346469989232843813e-03
static double t10 = 8.81081882437654011382e-04
static double t11 = -5.38595305356740546715e-04
static double t12 = 3.15632070903625950361e-04
static double t13 = -3.12754168375120860518e-04
static double t14 = 3.35529192635519073543e-04
static double u0 = -7.72156649015328655494e-02
static double u1 = 6.32827064025093366517e-01
static double u2 = 1.45492250137234768737e+00
static double u3 = 9.77717527963372745603e-01
static double u4 = 2.28963728064692451092e-01
static double u5 = 1.33810918536787660377e-02
static double v1 = 2.45597793713041134822e+00
static double v2 = 2.12848976379893395361e+00
static double v3 = 7.69285150456672783825e-01
static double v4 = 1.04222645593369134254e-01
static double v5 = 3.21709242282423911810e-03
static double s0 = -7.72156649015328655494e-02
static double s1 = 2.14982415960608852501e-01
static double s2 = 3.25778796408930981787e-01
static double s3 = 1.46350472652464452805e-01
static double s4 = 2.66422703033638609560e-02
static double s5 = 1.84028451407337715652e-03
static double s6 = 3.19475326584100867617e-05
static double r1 = 1.39200533467621045958e+00
static double r2 = 7.21935547567138069525e-01
static double r3 = 1.71933865632803078993e-01
static double r4 = 1.86459191715652901344e-02
static double r5 = 7.77942496381893596434e-04
static double r6 = 7.32668430744625636189e-06
static double w0 = 4.18938533204672725052e-01
static double w1 = 8.33333333333329678849e-02
static double w2 = -2.77777777728775536470e-03
static double w3 = 7.93650558643019558500e-04
static double w4 = -5.95187557450339963135e-04
static double w5 = 8.36339918996282139126e-04
static double w6 = -1.63092934096575273989e-03
static double zero = 0.00000000000000000000e+00

Function Documentation

double __ieee754_lgamma_r ( double  x,
int signgamp 
)

Definition at line 218 of file e_lgamma_r.c.

{
       double t,y,z,nadj,p,p1,p2,p3,q,r,w;
       int i,hx,lx,ix;

       EXTRACT_WORDS(hx,lx,x);

    /* purge off +-inf, NaN, +-0, and negative arguments */
       *signgamp = 1;
       ix = hx&0x7fffffff;
       if(ix>=0x7ff00000) return x*x;
       if((ix|lx)==0)
         {
           if (hx < 0)
             *signgamp = -1;
           return one/fabs(x);
         }
       if(ix<0x3b900000) {  /* |x|<2**-70, return -log(|x|) */
           if(hx<0) {
               *signgamp = -1;
               return -__ieee754_log(-x);
           } else return -__ieee754_log(x);
       }
       if(hx<0) {
           if(ix>=0x43300000)      /* |x|>=2**52, must be -integer */
              return x/zero;
           t = sin_pi(x);
           if(t==zero) return one/fabsf(t); /* -integer */
           nadj = __ieee754_log(pi/fabs(t*x));
           if(t<zero) *signgamp = -1;
           x = -x;
       }

    /* purge off 1 and 2 */
       if((((ix-0x3ff00000)|lx)==0)||(((ix-0x40000000)|lx)==0)) r = 0;
    /* for x < 2.0 */
       else if(ix<0x40000000) {
           if(ix<=0x3feccccc) {    /* lgamma(x) = lgamma(x+1)-log(x) */
              r = -__ieee754_log(x);
              if(ix>=0x3FE76944) {y = one-x; i= 0;}
              else if(ix>=0x3FCDA661) {y= x-(tc-one); i=1;}
              else {y = x; i=2;}
           } else {
              r = zero;
               if(ix>=0x3FFBB4C3) {y=2.0-x;i=0;} /* [1.7316,2] */
               else if(ix>=0x3FF3B4C4) {y=x-tc;i=1;} /* [1.23,1.73] */
              else {y=x-one;i=2;}
           }
           switch(i) {
             case 0:
              z = y*y;
              p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
              p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
              p  = y*p1+p2;
              r  += (p-0.5*y); break;
             case 1:
              z = y*y;
              w = z*y;
              p1 = t0+w*(t3+w*(t6+w*(t9 +w*t12)));      /* parallel comp */
              p2 = t1+w*(t4+w*(t7+w*(t10+w*t13)));
              p3 = t2+w*(t5+w*(t8+w*(t11+w*t14)));
              p  = z*p1-(tt-w*(p2+y*p3));
              r += (tf + p); break;
             case 2:
              p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
              p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
              r += (-0.5*y + p1/p2);
           }
       }
       else if(ix<0x40200000) {                  /* x < 8.0 */
           i = (int)x;
           t = zero;
           y = x-(double)i;
           p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
           q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
           r = half*y+p/q;
           z = one;  /* lgamma(1+s) = log(s) + lgamma(s) */
           switch(i) {
           case 7: z *= (y+6.0);   /* FALLTHRU */
           case 6: z *= (y+5.0);   /* FALLTHRU */
           case 5: z *= (y+4.0);   /* FALLTHRU */
           case 4: z *= (y+3.0);   /* FALLTHRU */
           case 3: z *= (y+2.0);   /* FALLTHRU */
                  r += __ieee754_log(z); break;
           }
    /* 8.0 <= x < 2**58 */
       } else if (ix < 0x43900000) {
           t = __ieee754_log(x);
           z = one/x;
           y = z*z;
           w = w0+z*(w1+y*(w2+y*(w3+y*(w4+y*(w5+y*w6)))));
           r = (x-half)*(t-one)+w;
       } else
    /* 2**58 <= x <= inf */
           r =  x*(__ieee754_log(x)-one);
       if(hx<0) r = nadj - r;
       return r;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static double sin_pi ( double  x) [static]

Definition at line 168 of file e_lgamma_r.c.

{
       double y,z;
       int n,ix;

       GET_HIGH_WORD(ix,x);
       ix &= 0x7fffffff;

       if(ix<0x3fd00000) return __sin(pi*x);
       y = -x;              /* x is assume negative */

    /*
     * argument reduction, make sure inexact flag not raised if input
     * is an integer
     */
       z = __floor(y);
       if(z!=y) {                         /* inexact anyway */
           y  *= 0.5;
           y   = 2.0*(y - __floor(y));           /* y = |x| mod 2.0 */
           n   = (int) (y*4.0);
       } else {
            if(ix>=0x43400000) {
                y = zero; n = 0;                 /* y must be even */
            } else {
                if(ix<0x43300000) z = y+two52;   /* exact */
              GET_LOW_WORD(n,z);
              n &= 1;
                y  = n;
                n<<= 2;
            }
        }
       switch (n) {
           case 0:   y =  __sin(pi*y); break;
           case 1:
           case 2:   y =  __cos(pi*(0.5-y)); break;
           case 3:
           case 4:   y =  __sin(pi*(one-y)); break;
           case 5:
           case 6:   y = -__cos(pi*(y-1.5)); break;
           default:  y =  __sin(pi*(y-2.0)); break;
           }
       return -y;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double a0 = 7.72156649015328655494e-02 [static]

Definition at line 96 of file e_lgamma_r.c.

double a1 = 3.22467033424113591611e-01 [static]

Definition at line 97 of file e_lgamma_r.c.

double a10 = 2.52144565451257326939e-05 [static]

Definition at line 106 of file e_lgamma_r.c.

double a11 = 4.48640949618915160150e-05 [static]

Definition at line 107 of file e_lgamma_r.c.

double a2 = 6.73523010531292681824e-02 [static]

Definition at line 98 of file e_lgamma_r.c.

double a3 = 2.05808084325167332806e-02 [static]

Definition at line 99 of file e_lgamma_r.c.

double a4 = 7.38555086081402883957e-03 [static]

Definition at line 100 of file e_lgamma_r.c.

double a5 = 2.89051383673415629091e-03 [static]

Definition at line 101 of file e_lgamma_r.c.

double a6 = 1.19270763183362067845e-03 [static]

Definition at line 102 of file e_lgamma_r.c.

double a7 = 5.10069792153511336608e-04 [static]

Definition at line 103 of file e_lgamma_r.c.

double a8 = 2.20862790713908385557e-04 [static]

Definition at line 104 of file e_lgamma_r.c.

double a9 = 1.08011567247583939954e-04 [static]

Definition at line 105 of file e_lgamma_r.c.

double half = 5.00000000000000000000e-01 [static]

Definition at line 93 of file e_lgamma_r.c.

double one = 1.00000000000000000000e+00 [static]

Definition at line 94 of file e_lgamma_r.c.

double pi = 3.14159265358979311600e+00 [static]

Definition at line 95 of file e_lgamma_r.c.

double r1 = 1.39200533467621045958e+00 [static]

Definition at line 145 of file e_lgamma_r.c.

double r2 = 7.21935547567138069525e-01 [static]

Definition at line 146 of file e_lgamma_r.c.

double r3 = 1.71933865632803078993e-01 [static]

Definition at line 147 of file e_lgamma_r.c.

double r4 = 1.86459191715652901344e-02 [static]

Definition at line 148 of file e_lgamma_r.c.

double r5 = 7.77942496381893596434e-04 [static]

Definition at line 149 of file e_lgamma_r.c.

double r6 = 7.32668430744625636189e-06 [static]

Definition at line 150 of file e_lgamma_r.c.

double s0 = -7.72156649015328655494e-02 [static]

Definition at line 138 of file e_lgamma_r.c.

double s1 = 2.14982415960608852501e-01 [static]

Definition at line 139 of file e_lgamma_r.c.

double s2 = 3.25778796408930981787e-01 [static]

Definition at line 140 of file e_lgamma_r.c.

double s3 = 1.46350472652464452805e-01 [static]

Definition at line 141 of file e_lgamma_r.c.

double s4 = 2.66422703033638609560e-02 [static]

Definition at line 142 of file e_lgamma_r.c.

double s5 = 1.84028451407337715652e-03 [static]

Definition at line 143 of file e_lgamma_r.c.

double s6 = 3.19475326584100867617e-05 [static]

Definition at line 144 of file e_lgamma_r.c.

double t0 = 4.83836122723810047042e-01 [static]

Definition at line 112 of file e_lgamma_r.c.

double t1 = -1.47587722994593911752e-01 [static]

Definition at line 113 of file e_lgamma_r.c.

double t10 = 8.81081882437654011382e-04 [static]

Definition at line 122 of file e_lgamma_r.c.

double t11 = -5.38595305356740546715e-04 [static]

Definition at line 123 of file e_lgamma_r.c.

double t12 = 3.15632070903625950361e-04 [static]

Definition at line 124 of file e_lgamma_r.c.

double t13 = -3.12754168375120860518e-04 [static]

Definition at line 125 of file e_lgamma_r.c.

double t14 = 3.35529192635519073543e-04 [static]

Definition at line 126 of file e_lgamma_r.c.

double t2 = 6.46249402391333854778e-02 [static]

Definition at line 114 of file e_lgamma_r.c.

double t3 = -3.27885410759859649565e-02 [static]

Definition at line 115 of file e_lgamma_r.c.

double t4 = 1.79706750811820387126e-02 [static]

Definition at line 116 of file e_lgamma_r.c.

double t5 = -1.03142241298341437450e-02 [static]

Definition at line 117 of file e_lgamma_r.c.

double t6 = 6.10053870246291332635e-03 [static]

Definition at line 118 of file e_lgamma_r.c.

double t7 = -3.68452016781138256760e-03 [static]

Definition at line 119 of file e_lgamma_r.c.

double t8 = 2.25964780900612472250e-03 [static]

Definition at line 120 of file e_lgamma_r.c.

double t9 = -1.40346469989232843813e-03 [static]

Definition at line 121 of file e_lgamma_r.c.

double tc = 1.46163214496836224576e+00 [static]

Definition at line 108 of file e_lgamma_r.c.

double tf = -1.21486290535849611461e-01 [static]

Definition at line 109 of file e_lgamma_r.c.

double tt = -3.63867699703950536541e-18 [static]

Definition at line 111 of file e_lgamma_r.c.

double two52 = 4.50359962737049600000e+15 [static]

Definition at line 92 of file e_lgamma_r.c.

double u0 = -7.72156649015328655494e-02 [static]

Definition at line 127 of file e_lgamma_r.c.

double u1 = 6.32827064025093366517e-01 [static]

Definition at line 128 of file e_lgamma_r.c.

double u2 = 1.45492250137234768737e+00 [static]

Definition at line 129 of file e_lgamma_r.c.

double u3 = 9.77717527963372745603e-01 [static]

Definition at line 130 of file e_lgamma_r.c.

double u4 = 2.28963728064692451092e-01 [static]

Definition at line 131 of file e_lgamma_r.c.

double u5 = 1.33810918536787660377e-02 [static]

Definition at line 132 of file e_lgamma_r.c.

double v1 = 2.45597793713041134822e+00 [static]

Definition at line 133 of file e_lgamma_r.c.

double v2 = 2.12848976379893395361e+00 [static]

Definition at line 134 of file e_lgamma_r.c.

double v3 = 7.69285150456672783825e-01 [static]

Definition at line 135 of file e_lgamma_r.c.

double v4 = 1.04222645593369134254e-01 [static]

Definition at line 136 of file e_lgamma_r.c.

double v5 = 3.21709242282423911810e-03 [static]

Definition at line 137 of file e_lgamma_r.c.

double w0 = 4.18938533204672725052e-01 [static]

Definition at line 151 of file e_lgamma_r.c.

double w1 = 8.33333333333329678849e-02 [static]

Definition at line 152 of file e_lgamma_r.c.

double w2 = -2.77777777728775536470e-03 [static]

Definition at line 153 of file e_lgamma_r.c.

double w3 = 7.93650558643019558500e-04 [static]

Definition at line 154 of file e_lgamma_r.c.

double w4 = -5.95187557450339963135e-04 [static]

Definition at line 155 of file e_lgamma_r.c.

double w5 = 8.36339918996282139126e-04 [static]

Definition at line 156 of file e_lgamma_r.c.

double w6 = -1.63092934096575273989e-03 [static]

Definition at line 157 of file e_lgamma_r.c.

double zero = 0.00000000000000000000e+00 [static]

Definition at line 162 of file e_lgamma_r.c.