Back to index

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

Go to the source code of this file.

Defines

#define ZERO   logtbl[38]

Functions

long double __ieee754_logl (long double x)

Variables

static const long double l3 = 3.333333333333333333333333333333336096926E-1L
static const long double l4 = -2.499999999999999999999999999486853077002E-1L
static const long double l5 = 1.999999999999999999999999998515277861905E-1L
static const long double l6 = -1.666666666666666666666798448356171665678E-1L
static const long double l7 = 1.428571428571428571428808945895490721564E-1L
static const long double l8 = -1.249999999999999987884655626377588149000E-1L
static const long double l9 = 1.111111111111111093947834982832456459186E-1L
static const long double l10 = -1.000000000000532974938900317952530453248E-1L
static const long double l11 = 9.090909090915566247008015301349979892689E-2L
static const long double l12 = -8.333333211818065121250921925397567745734E-2L
static const long double l13 = 7.692307559897661630807048686258659316091E-2L
static const long double l14 = -7.144242754190814657241902218399056829264E-2L
static const long double l15 = 6.668057591071739754844678883223432347481E-2L
static const long double logtbl [92]
static const long double ln2a = 6.93145751953125e-1L
static const long double ln2b = 1.4286068203094172321214581765680755001344E-6L

Define Documentation

#define ZERO   logtbl[38]

Function Documentation

long double __ieee754_logl ( long double  x)

Definition at line 186 of file e_logl.c.

{
  long double z, y, w;
  ieee854_long_double_shape_type u, t;
  unsigned int m;
  int k, e;

  u.value = x;
  m = u.parts32.w0;

  /* Check for IEEE special cases.  */
  k = m & 0x7fffffff;
  /* log(0) = -infinity. */
  if ((k | u.parts32.w1 | u.parts32.w2 | u.parts32.w3) == 0)
    {
      return -0.5L / ZERO;
    }
  /* log ( x < 0 ) = NaN */
  if (m & 0x80000000)
    {
      return (x - x) / ZERO;
    }
  /* log (infinity or NaN) */
  if (k >= 0x7fff0000)
    {
      return x + x;
    }

  /* Extract exponent and reduce domain to 0.703125 <= u < 1.40625  */
  e = (int) (m >> 16) - (int) 0x3ffe;
  m &= 0xffff;
  u.parts32.w0 = m | 0x3ffe0000;
  m |= 0x10000;
  /* Find lookup table index k from high order bits of the significand. */
  if (m < 0x16800)
    {
      k = (m - 0xff00) >> 9;
      /* t is the argument 0.5 + (k+26)/128
        of the nearest item to u in the lookup table.  */
      t.parts32.w0 = 0x3fff0000 + (k << 9);
      t.parts32.w1 = 0;
      t.parts32.w2 = 0;
      t.parts32.w3 = 0;
      u.parts32.w0 += 0x10000;
      e -= 1;
      k += 64;
    }
  else
    {
      k = (m - 0xfe00) >> 10;
      t.parts32.w0 = 0x3ffe0000 + (k << 10);
      t.parts32.w1 = 0;
      t.parts32.w2 = 0;
      t.parts32.w3 = 0;
    }
  /* On this interval the table is not used due to cancellation error.  */
  if ((x <= 1.0078125L) && (x >= 0.9921875L))
    {
      z = x - 1.0L;
      k = 64;
      t.value  = 1.0L;
      e = 0;
    }
  else
    {
      /* log(u) = log( t u/t ) = log(t) + log(u/t)
        log(t) is tabulated in the lookup table.
        Express log(u/t) = log(1+z),  where z = u/t - 1 = (u-t)/t.
         cf. Cody & Waite. */
      z = (u.value - t.value) / t.value;
    }
  /* Series expansion of log(1+z).  */
  w = z * z;
  y = ((((((((((((l15 * z
                + l14) * z
               + l13) * z
              + l12) * z
              + l11) * z
             + l10) * z
            + l9) * z
           + l8) * z
          + l7) * z
         + l6) * z
        + l5) * z
       + l4) * z
       + l3) * z * w;
  y -= 0.5 * w;
  y += e * ln2b;  /* Base 2 exponent offset times ln(2).  */
  y += z;
  y += logtbl[k-26]; /* log(t) - (t-1) */
  y += (t.value - 1.0L);
  y += e * ln2a;
  return y;
}

Variable Documentation

const long double l10 = -1.000000000000532974938900317952530453248E-1L [static]

Definition at line 74 of file e_logl.c.

const long double l11 = 9.090909090915566247008015301349979892689E-2L [static]

Definition at line 75 of file e_logl.c.

const long double l12 = -8.333333211818065121250921925397567745734E-2L [static]

Definition at line 76 of file e_logl.c.

const long double l13 = 7.692307559897661630807048686258659316091E-2L [static]

Definition at line 77 of file e_logl.c.

const long double l14 = -7.144242754190814657241902218399056829264E-2L [static]

Definition at line 78 of file e_logl.c.

const long double l15 = 6.668057591071739754844678883223432347481E-2L [static]

Definition at line 79 of file e_logl.c.

const long double l3 = 3.333333333333333333333333333333336096926E-1L [static]

Definition at line 67 of file e_logl.c.

const long double l4 = -2.499999999999999999999999999486853077002E-1L [static]

Definition at line 68 of file e_logl.c.

const long double l5 = 1.999999999999999999999999998515277861905E-1L [static]

Definition at line 69 of file e_logl.c.

const long double l6 = -1.666666666666666666666798448356171665678E-1L [static]

Definition at line 70 of file e_logl.c.

const long double l7 = 1.428571428571428571428808945895490721564E-1L [static]

Definition at line 71 of file e_logl.c.

const long double l8 = -1.249999999999999987884655626377588149000E-1L [static]

Definition at line 72 of file e_logl.c.

const long double l9 = 1.111111111111111093947834982832456459186E-1L [static]

Definition at line 73 of file e_logl.c.

const long double ln2a = 6.93145751953125e-1L [static]

Definition at line 182 of file e_logl.c.

const long double ln2b = 1.4286068203094172321214581765680755001344E-6L [static]

Definition at line 183 of file e_logl.c.

const long double logtbl[92] [static]

Definition at line 84 of file e_logl.c.