Back to index

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

Go to the source code of this file.

Functions

static long double sin_pi (long double x)
long double __ieee754_lgammal_r (long double x, int *signgamp)

Variables

static long double half = 0.5L
static long double one = 1.0L
static long double pi = 3.14159265358979323846264L
static long double two63 = 9.223372036854775808e18L
static long double a0 = -6.343246574721079391729402781192128239938E2L
static long double a1 = 1.856560238672465796768677717168371401378E3L
static long double a2 = 2.404733102163746263689288466865843408429E3L
static long double a3 = 8.804188795790383497379532868917517596322E2L
static long double a4 = 1.135361354097447729740103745999661157426E2L
static long double a5 = 3.766956539107615557608581581190400021285E0L
static long double b0 = 8.214973713960928795704317259806842490498E3L
static long double b1 = 1.026343508841367384879065363925870888012E4L
static long double b2 = 4.553337477045763320522762343132210919277E3L
static long double b3 = 8.506975785032585797446253359230031874803E2L
static long double b4 = 6.042447899703295436820744186992189445813E1L
static long double tc = 1.4616321449683623412626595423257213284682E0L
static long double tf = -1.2148629053584961146050602565082954242826E-1
static long double tt = 3.3649914684731379602768989080467587736363E-18L
static long double g0 = 3.645529916721223331888305293534095553827E-18L
static long double g1 = 5.126654642791082497002594216163574795690E3L
static long double g2 = 8.828603575854624811911631336122070070327E3L
static long double g3 = 5.464186426932117031234820886525701595203E3L
static long double g4 = 1.455427403530884193180776558102868592293E3L
static long double g5 = 1.541735456969245924860307497029155838446E2L
static long double g6 = 4.335498275274822298341872707453445815118E0L
static long double h0 = 1.059584930106085509696730443974495979641E4L
static long double h1 = 2.147921653490043010629481226937850618860E4L
static long double h2 = 1.643014770044524804175197151958100656728E4L
static long double h3 = 5.869021995186925517228323497501767586078E3L
static long double h4 = 9.764244777714344488787381271643502742293E2L
static long double h5 = 6.442485441570592541741092969581997002349E1L
static long double u0 = -8.886217500092090678492242071879342025627E1L
static long double u1 = 6.840109978129177639438792958320783599310E2L
static long double u2 = 2.042626104514127267855588786511809932433E3L
static long double u3 = 1.911723903442667422201651063009856064275E3L
static long double u4 = 7.447065275665887457628865263491667767695E2L
static long double u5 = 1.132256494121790736268471016493103952637E2L
static long double u6 = 4.484398885516614191003094714505960972894E0L
static long double v0 = 1.150830924194461522996462401210374632929E3L
static long double v1 = 3.399692260848747447377972081399737098610E3L
static long double v2 = 3.786631705644460255229513563657226008015E3L
static long double v3 = 1.966450123004478374557778781564114347876E3L
static long double v4 = 4.741359068914069299837355438370682773122E2L
static long double v5 = 4.508989649747184050907206782117647852364E1L
static long double s0 = 1.454726263410661942989109455292824853344E6L
static long double s1 = -3.901428390086348447890408306153378922752E6L
static long double s2 = -6.573568698209374121847873064292963089438E6L
static long double s3 = -3.319055881485044417245964508099095984643E6L
static long double s4 = -7.094891568758439227560184618114707107977E5L
static long double s5 = -6.263426646464505837422314539808112478303E4L
static long double s6 = -1.684926520999477529949915657519454051529E3L
static long double r0 = -1.883978160734303518163008696712983134698E7L
static long double r1 = -2.815206082812062064902202753264922306830E7L
static long double r2 = -1.600245495251915899081846093343626358398E7L
static long double r3 = -4.310526301881305003489257052083370058799E6L
static long double r4 = -5.563807682263923279438235987186184968542E5L
static long double r5 = -3.027734654434169996032905158145259713083E4L
static long double r6 = -4.501995652861105629217250715790764371267E2L
static long double w0 = 4.189385332046727417803e-1L
static long double w1 = 8.333333333333331447505E-2L
static long double w2 = -2.777777777750349603440E-3L
static long double w3 = 7.936507795855070755671E-4L
static long double w4 = -5.952345851765688514613E-4L
static long double w5 = 8.412723297322498080632E-4L
static long double w6 = -1.880801938119376907179E-3L
static long double w7 = 4.885026142432270781165E-3L
static long double zero = 0.0L

Function Documentation

long double __ieee754_lgammal_r ( long double  x,
int signgamp 
)

Definition at line 291 of file e_lgammal_r.c.

{
  long double t, y, z, nadj, p, p1, p2, q, r, w;
  int i, ix;
  u_int32_t se, i0, i1;

  *signgamp = 1;
  GET_LDOUBLE_WORDS (se, i0, i1, x);
  ix = se & 0x7fff;

  if ((ix | i0 | i1) == 0)
    {
      if (se & 0x8000)
       *signgamp = -1;
      return one / fabsl (x);
    }

  ix = (ix << 16) | (i0 >> 16);

  /* purge off +-inf, NaN, +-0, and negative arguments */
  if (ix >= 0x7fff0000)
    return x * x;

  if (ix < 0x3fc08000) /* 2^-63 */
    {                       /* |x|<2**-63, return -log(|x|) */
      if (se & 0x8000)
       {
         *signgamp = -1;
         return -__ieee754_logl (-x);
       }
      else
       return -__ieee754_logl (x);
    }
  if (se & 0x8000)
    {
      t = sin_pi (x);
      if (t == zero)
       return one / fabsl (t);     /* -integer */
      nadj = __ieee754_logl (pi / fabsl (t * x));
      if (t < zero)
       *signgamp = -1;
      x = -x;
    }

  /* purge off 1 and 2 */
  if ((((ix - 0x3fff8000) | i0 | i1) == 0)
      || (((ix - 0x40008000) | i0 | i1) == 0))
    r = 0;
  else if (ix < 0x40008000) /* 2.0 */
    {
      /* x < 2.0 */
      if (ix <= 0x3ffee666) /* 8.99993896484375e-1 */
       {
         /* lgamma(x) = lgamma(x+1) - log(x) */
         r = -__ieee754_logl (x);
         if (ix >= 0x3ffebb4a) /* 7.31597900390625e-1 */
           {
             y = x - one;
             i = 0;
           }
         else if (ix >= 0x3ffced33)/* 2.31639862060546875e-1 */
           {
             y = x - (tc - one);
             i = 1;
           }
         else
           {
             /* x < 0.23 */
             y = x;
             i = 2;
           }
       }
      else
       {
         r = zero;
         if (ix >= 0x3fffdda6) /* 1.73162841796875 */
           {
             /* [1.7316,2] */
             y = x - 2.0;
             i = 0;
           }
         else if (ix >= 0x3fff9da6)/* 1.23162841796875 */
           {
             /* [1.23,1.73] */
             y = x - tc;
             i = 1;
           }
         else
           {
             /* [0.9, 1.23] */
             y = x - one;
             i = 2;
           }
       }
      switch (i)
       {
       case 0:
         p1 = a0 + y * (a1 + y * (a2 + y * (a3 + y * (a4 + y * a5))));
         p2 = b0 + y * (b1 + y * (b2 + y * (b3 + y * (b4 + y))));
         r += half * y + y * p1/p2;
         break;
       case 1:
    p1 = g0 + y * (g1 + y * (g2 + y * (g3 + y * (g4 + y * (g5 + y * g6)))));
    p2 = h0 + y * (h1 + y * (h2 + y * (h3 + y * (h4 + y * (h5 + y)))));
    p = tt + y * p1/p2;
         r += (tf + p);
         break;
       case 2:
 p1 = y * (u0 + y * (u1 + y * (u2 + y * (u3 + y * (u4 + y * (u5 + y * u6))))));
      p2 = v0 + y * (v1 + y * (v2 + y * (v3 + y * (v4 + y * (v5 + y)))));
         r += (-half * y + p1 / p2);
       }
    }
  else if (ix < 0x40028000) /* 8.0 */
    {
      /* 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 = r0 + y * (r1 + y * (r2 + y * (r3 + y * (r4 + y * (r5 + y * (r6 + y))))));
      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_logl (z);
         break;
       }
    }
  else if (ix < 0x40418000) /* 2^66 */
    {
      /* 8.0 <= x < 2**66 */
      t = __ieee754_logl (x);
      z = one / x;
      y = z * z;
      w = w0 + z * (w1
          + y * (w2 + y * (w3 + y * (w4 + y * (w5 + y * (w6 + y * w7))))));
      r = (x - half) * (t - one) + w;
    }
  else
    /* 2**66 <= x <= inf */
    r = x * (__ieee754_logl (x) - one);
  if (se & 0x8000)
    r = nadj - r;
  return r;
}

Here is the call graph for this function:

static long double sin_pi ( long double  x) [static]

Definition at line 218 of file e_lgammal_r.c.

{
  long double y, z;
  int n, ix;
  u_int32_t se, i0, i1;

  GET_LDOUBLE_WORDS (se, i0, i1, x);
  ix = se & 0x7fff;
  ix = (ix << 16) | (i0 >> 16);
  if (ix < 0x3ffd8000) /* 0.25 */
    return __sinl (pi * x);
  y = -x;                   /* x is assume negative */

  /*
   * argument reduction, make sure inexact flag not raised if input
   * is an integer
   */
  z = __floorl (y);
  if (z != y)
    {                       /* inexact anyway */
      y  *= 0.5;
      y = 2.0*(y - __floorl(y));          /* y = |x| mod 2.0 */
      n = (int) (y*4.0);
    }
  else
    {
      if (ix >= 0x403f8000)  /* 2^64 */
       {
         y = zero; n = 0;                 /* y must be even */
       }
      else
       {
       if (ix < 0x403e8000)  /* 2^63 */
         z = y + two63;     /* exact */
       GET_LDOUBLE_WORDS (se, i0, i1, z);
       n = i1 & 1;
       y  = n;
       n <<= 2;
      }
    }

  switch (n)
    {
    case 0:
      y = __sinl (pi * y);
      break;
    case 1:
    case 2:
      y = __cosl (pi * (half - y));
      break;
    case 3:
    case 4:
      y = __sinl (pi * (one - y));
      break;
    case 5:
    case 6:
      y = -__cosl (pi * (y - 1.5));
      break;
    default:
      y = __sinl (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

long double a0 = -6.343246574721079391729402781192128239938E2L [static]

Definition at line 110 of file e_lgammal_r.c.

long double a1 = 1.856560238672465796768677717168371401378E3L [static]

Definition at line 111 of file e_lgammal_r.c.

long double a2 = 2.404733102163746263689288466865843408429E3L [static]

Definition at line 112 of file e_lgammal_r.c.

long double a3 = 8.804188795790383497379532868917517596322E2L [static]

Definition at line 113 of file e_lgammal_r.c.

long double a4 = 1.135361354097447729740103745999661157426E2L [static]

Definition at line 114 of file e_lgammal_r.c.

long double a5 = 3.766956539107615557608581581190400021285E0L [static]

Definition at line 115 of file e_lgammal_r.c.

long double b0 = 8.214973713960928795704317259806842490498E3L [static]

Definition at line 117 of file e_lgammal_r.c.

long double b1 = 1.026343508841367384879065363925870888012E4L [static]

Definition at line 118 of file e_lgammal_r.c.

long double b2 = 4.553337477045763320522762343132210919277E3L [static]

Definition at line 119 of file e_lgammal_r.c.

long double b3 = 8.506975785032585797446253359230031874803E2L [static]

Definition at line 120 of file e_lgammal_r.c.

long double b4 = 6.042447899703295436820744186992189445813E1L [static]

Definition at line 121 of file e_lgammal_r.c.

long double g0 = 3.645529916721223331888305293534095553827E-18L [static]

Definition at line 136 of file e_lgammal_r.c.

long double g1 = 5.126654642791082497002594216163574795690E3L [static]

Definition at line 137 of file e_lgammal_r.c.

long double g2 = 8.828603575854624811911631336122070070327E3L [static]

Definition at line 138 of file e_lgammal_r.c.

long double g3 = 5.464186426932117031234820886525701595203E3L [static]

Definition at line 139 of file e_lgammal_r.c.

long double g4 = 1.455427403530884193180776558102868592293E3L [static]

Definition at line 140 of file e_lgammal_r.c.

long double g5 = 1.541735456969245924860307497029155838446E2L [static]

Definition at line 141 of file e_lgammal_r.c.

long double g6 = 4.335498275274822298341872707453445815118E0L [static]

Definition at line 142 of file e_lgammal_r.c.

long double h0 = 1.059584930106085509696730443974495979641E4L [static]

Definition at line 144 of file e_lgammal_r.c.

long double h1 = 2.147921653490043010629481226937850618860E4L [static]

Definition at line 145 of file e_lgammal_r.c.

long double h2 = 1.643014770044524804175197151958100656728E4L [static]

Definition at line 146 of file e_lgammal_r.c.

long double h3 = 5.869021995186925517228323497501767586078E3L [static]

Definition at line 147 of file e_lgammal_r.c.

long double h4 = 9.764244777714344488787381271643502742293E2L [static]

Definition at line 148 of file e_lgammal_r.c.

long double h5 = 6.442485441570592541741092969581997002349E1L [static]

Definition at line 149 of file e_lgammal_r.c.

long double half = 0.5L [static]

Definition at line 102 of file e_lgammal_r.c.

long double one = 1.0L [static]

Definition at line 103 of file e_lgammal_r.c.

long double pi = 3.14159265358979323846264L [static]

Definition at line 104 of file e_lgammal_r.c.

long double r0 = -1.883978160734303518163008696712983134698E7L [static]

Definition at line 184 of file e_lgammal_r.c.

long double r1 = -2.815206082812062064902202753264922306830E7L [static]

Definition at line 185 of file e_lgammal_r.c.

long double r2 = -1.600245495251915899081846093343626358398E7L [static]

Definition at line 186 of file e_lgammal_r.c.

long double r3 = -4.310526301881305003489257052083370058799E6L [static]

Definition at line 187 of file e_lgammal_r.c.

long double r4 = -5.563807682263923279438235987186184968542E5L [static]

Definition at line 188 of file e_lgammal_r.c.

long double r5 = -3.027734654434169996032905158145259713083E4L [static]

Definition at line 189 of file e_lgammal_r.c.

long double r6 = -4.501995652861105629217250715790764371267E2L [static]

Definition at line 190 of file e_lgammal_r.c.

long double s0 = 1.454726263410661942989109455292824853344E6L [static]

Definition at line 176 of file e_lgammal_r.c.

long double s1 = -3.901428390086348447890408306153378922752E6L [static]

Definition at line 177 of file e_lgammal_r.c.

long double s2 = -6.573568698209374121847873064292963089438E6L [static]

Definition at line 178 of file e_lgammal_r.c.

long double s3 = -3.319055881485044417245964508099095984643E6L [static]

Definition at line 179 of file e_lgammal_r.c.

long double s4 = -7.094891568758439227560184618114707107977E5L [static]

Definition at line 180 of file e_lgammal_r.c.

long double s5 = -6.263426646464505837422314539808112478303E4L [static]

Definition at line 181 of file e_lgammal_r.c.

long double s6 = -1.684926520999477529949915657519454051529E3L [static]

Definition at line 182 of file e_lgammal_r.c.

long double tc = 1.4616321449683623412626595423257213284682E0L [static]

Definition at line 125 of file e_lgammal_r.c.

long double tf = -1.2148629053584961146050602565082954242826E-1 [static]

Definition at line 126 of file e_lgammal_r.c.

long double tt = 3.3649914684731379602768989080467587736363E-18L [static]

Definition at line 128 of file e_lgammal_r.c.

long double two63 = 9.223372036854775808e18L [static]

Definition at line 105 of file e_lgammal_r.c.

long double u0 = -8.886217500092090678492242071879342025627E1L [static]

Definition at line 156 of file e_lgammal_r.c.

long double u1 = 6.840109978129177639438792958320783599310E2L [static]

Definition at line 157 of file e_lgammal_r.c.

long double u2 = 2.042626104514127267855588786511809932433E3L [static]

Definition at line 158 of file e_lgammal_r.c.

long double u3 = 1.911723903442667422201651063009856064275E3L [static]

Definition at line 159 of file e_lgammal_r.c.

long double u4 = 7.447065275665887457628865263491667767695E2L [static]

Definition at line 160 of file e_lgammal_r.c.

long double u5 = 1.132256494121790736268471016493103952637E2L [static]

Definition at line 161 of file e_lgammal_r.c.

long double u6 = 4.484398885516614191003094714505960972894E0L [static]

Definition at line 162 of file e_lgammal_r.c.

long double v0 = 1.150830924194461522996462401210374632929E3L [static]

Definition at line 164 of file e_lgammal_r.c.

long double v1 = 3.399692260848747447377972081399737098610E3L [static]

Definition at line 165 of file e_lgammal_r.c.

long double v2 = 3.786631705644460255229513563657226008015E3L [static]

Definition at line 166 of file e_lgammal_r.c.

long double v3 = 1.966450123004478374557778781564114347876E3L [static]

Definition at line 167 of file e_lgammal_r.c.

long double v4 = 4.741359068914069299837355438370682773122E2L [static]

Definition at line 168 of file e_lgammal_r.c.

long double v5 = 4.508989649747184050907206782117647852364E1L [static]

Definition at line 169 of file e_lgammal_r.c.

long double w0 = 4.189385332046727417803e-1L [static]

Definition at line 198 of file e_lgammal_r.c.

long double w1 = 8.333333333333331447505E-2L [static]

Definition at line 199 of file e_lgammal_r.c.

long double w2 = -2.777777777750349603440E-3L [static]

Definition at line 200 of file e_lgammal_r.c.

long double w3 = 7.936507795855070755671E-4L [static]

Definition at line 201 of file e_lgammal_r.c.

long double w4 = -5.952345851765688514613E-4L [static]

Definition at line 202 of file e_lgammal_r.c.

long double w5 = 8.412723297322498080632E-4L [static]

Definition at line 203 of file e_lgammal_r.c.

long double w6 = -1.880801938119376907179E-3L [static]

Definition at line 204 of file e_lgammal_r.c.

long double w7 = 4.885026142432270781165E-3L [static]

Definition at line 205 of file e_lgammal_r.c.

long double zero = 0.0L [static]

Definition at line 210 of file e_lgammal_r.c.