Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
s_erf.c File Reference
#include "fdlibm.h"

Go to the source code of this file.

Functions

double fd_erf (double x)
double erfc (double x)

Variables

static double tiny = 1e-300
static double half = 5.00000000000000000000e-01
static double one = 1.00000000000000000000e+00
static double two = 2.00000000000000000000e+00
static double erx = 8.45062911510467529297e-01
static double efx = 1.28379167095512586316e-01
static double efx8 = 1.02703333676410069053e+00
static double pp0 = 1.28379167095512558561e-01
static double pp1 = -3.25042107247001499370e-01
static double pp2 = -2.84817495755985104766e-02
static double pp3 = -5.77027029648944159157e-03
static double pp4 = -2.37630166566501626084e-05
static double qq1 = 3.97917223959155352819e-01
static double qq2 = 6.50222499887672944485e-02
static double qq3 = 5.08130628187576562776e-03
static double qq4 = 1.32494738004321644526e-04
static double qq5 = -3.96022827877536812320e-06
static double pa0 = -2.36211856075265944077e-03
static double pa1 = 4.14856118683748331666e-01
static double pa2 = -3.72207876035701323847e-01
static double pa3 = 3.18346619901161753674e-01
static double pa4 = -1.10894694282396677476e-01
static double pa5 = 3.54783043256182359371e-02
static double pa6 = -2.16637559486879084300e-03
static double qa1 = 1.06420880400844228286e-01
static double qa2 = 5.40397917702171048937e-01
static double qa3 = 7.18286544141962662868e-02
static double qa4 = 1.26171219808761642112e-01
static double qa5 = 1.36370839120290507362e-02
static double qa6 = 1.19844998467991074170e-02
static double ra0 = -9.86494403484714822705e-03
static double ra1 = -6.93858572707181764372e-01
static double ra2 = -1.05586262253232909814e+01
static double ra3 = -6.23753324503260060396e+01
static double ra4 = -1.62396669462573470355e+02
static double ra5 = -1.84605092906711035994e+02
static double ra6 = -8.12874355063065934246e+01
static double ra7 = -9.81432934416914548592e+00
static double sa1 = 1.96512716674392571292e+01
static double sa2 = 1.37657754143519042600e+02
static double sa3 = 4.34565877475229228821e+02
static double sa4 = 6.45387271733267880336e+02
static double sa5 = 4.29008140027567833386e+02
static double sa6 = 1.08635005541779435134e+02
static double sa7 = 6.57024977031928170135e+00
static double sa8 = -6.04244152148580987438e-02
static double rb0 = -9.86494292470009928597e-03
static double rb1 = -7.99283237680523006574e-01
static double rb2 = -1.77579549177547519889e+01
static double rb3 = -1.60636384855821916062e+02
static double rb4 = -6.37566443368389627722e+02
static double rb5 = -1.02509513161107724954e+03
static double rb6 = -4.83519191608651397019e+02
static double sb1 = 3.03380607434824582924e+01
static double sb2 = 3.25792512996573918826e+02
static double sb3 = 1.53672958608443695994e+03
static double sb4 = 3.19985821950859553908e+03
static double sb5 = 2.55305040643316442583e+03
static double sb6 = 4.74528541206955367215e+02
static double sb7 = -2.24409524465858183362e+01

Function Documentation

double erfc ( double  x)

Definition at line 291 of file s_erf.c.

{
        fd_twoints u;
       int hx,ix;
       double R,S,P,Q,s,y,z,r;
        u.d = x;
       hx = __HI(u);
       ix = hx&0x7fffffff;
       if(ix>=0x7ff00000) {               /* erfc(nan)=nan */
                                          /* erfc(+-inf)=0,2 */
           return (double)(((unsigned)hx>>31)<<1)+one/x;
       }

       if(ix < 0x3feb0000) {              /* |x|<0.84375 */
           if(ix < 0x3c700000)     /* |x|<2**-56 */
              return one-x;
           z = x*x;
           r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
           s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
           y = r/s;
           if(hx < 0x3fd00000) {   /* x<1/4 */
              return one-(x+x*y);
           } else {
              r = x*y;
              r += (x-half);
               return half - r ;
           }
       }
       if(ix < 0x3ff40000) {              /* 0.84375 <= |x| < 1.25 */
           s = fd_fabs(x)-one;
           P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
           Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
           if(hx>=0) {
               z  = one-erx; return z - P/Q; 
           } else {
              z = erx+P/Q; return one+z;
           }
       }
       if (ix < 0x403c0000) {             /* |x|<28 */
           x = fd_fabs(x);
           s = one/(x*x);
           if(ix< 0x4006DB6D) {    /* |x| < 1/.35 ~ 2.857143*/
               R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
                            ra5+s*(ra6+s*ra7))))));
               S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
                            sa5+s*(sa6+s*(sa7+s*sa8)))))));
           } else {                /* |x| >= 1/.35 ~ 2.857143 */
              if(hx<0&&ix>=0x40180000) return two-tiny;/* x < -6 */
               R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
                            rb5+s*rb6)))));
               S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
                            sb5+s*(sb6+s*sb7))))));
           }
           z  = x;
            u.d = z;
           __LO(u)  = 0;
            z = u.d;
           r  =  __ieee754_exp(-z*z-0.5625)*
                     __ieee754_exp((z-x)*(z+x)+R/S);
           if(hx>0) return r/x; else return two-r/x;
       } else {
           if(hx>0) return tiny*tiny; else return two-tiny;
       }
}

Here is the call graph for this function:

double fd_erf ( double  x)

Definition at line 231 of file s_erf.c.

{
        fd_twoints u;
       int hx,ix,i;
       double R,S,P,Q,s,y,z,r;
        u.d = x;
       hx = __HI(u);
       ix = hx&0x7fffffff;
       if(ix>=0x7ff00000) {        /* erf(nan)=nan */
           i = ((unsigned)hx>>31)<<1;
           return (double)(1-i)+one/x;    /* erf(+-inf)=+-1 */
       }

       if(ix < 0x3feb0000) {              /* |x|<0.84375 */
           if(ix < 0x3e300000) {   /* |x|<2**-28 */
               if (ix < 0x00800000) 
                  return 0.125*(8.0*x+efx8*x);  /*avoid underflow */
              return x + efx*x;
           }
           z = x*x;
           r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
           s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
           y = r/s;
           return x + x*y;
       }
       if(ix < 0x3ff40000) {              /* 0.84375 <= |x| < 1.25 */
           s = fd_fabs(x)-one;
           P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
           Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
           if(hx>=0) return erx + P/Q; else return -erx - P/Q;
       }
       if (ix >= 0x40180000) {            /* inf>|x|>=6 */
           if(hx>=0) return one-tiny; else return tiny-one;
       }
       x = fd_fabs(x);
       s = one/(x*x);
       if(ix< 0x4006DB6E) { /* |x| < 1/0.35 */
           R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
                            ra5+s*(ra6+s*ra7))))));
           S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
                            sa5+s*(sa6+s*(sa7+s*sa8)))))));
       } else {      /* |x| >= 1/0.35 */
           R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
                            rb5+s*rb6)))));
           S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
                            sb5+s*(sb6+s*sb7))))));
       }
       z  = x;  
        u.d = z;
       __LO(u) = 0;
        z = u.d;
       r  =  __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S);
       if(hx>=0) return one-r/x; else return  r/x-one;
}

Here is the call graph for this function:


Variable Documentation

double efx = 1.28379167095512586316e-01 [static]

Definition at line 163 of file s_erf.c.

double efx8 = 1.02703333676410069053e+00 [static]

Definition at line 164 of file s_erf.c.

double erx = 8.45062911510467529297e-01 [static]

Definition at line 159 of file s_erf.c.

double half = 5.00000000000000000000e-01 [static]

Definition at line 155 of file s_erf.c.

double one = 1.00000000000000000000e+00 [static]

Definition at line 156 of file s_erf.c.

double pa0 = -2.36211856075265944077e-03 [static]

Definition at line 178 of file s_erf.c.

double pa1 = 4.14856118683748331666e-01 [static]

Definition at line 179 of file s_erf.c.

double pa2 = -3.72207876035701323847e-01 [static]

Definition at line 180 of file s_erf.c.

double pa3 = 3.18346619901161753674e-01 [static]

Definition at line 181 of file s_erf.c.

double pa4 = -1.10894694282396677476e-01 [static]

Definition at line 182 of file s_erf.c.

double pa5 = 3.54783043256182359371e-02 [static]

Definition at line 183 of file s_erf.c.

double pa6 = -2.16637559486879084300e-03 [static]

Definition at line 184 of file s_erf.c.

double pp0 = 1.28379167095512558561e-01 [static]

Definition at line 165 of file s_erf.c.

double pp1 = -3.25042107247001499370e-01 [static]

Definition at line 166 of file s_erf.c.

double pp2 = -2.84817495755985104766e-02 [static]

Definition at line 167 of file s_erf.c.

double pp3 = -5.77027029648944159157e-03 [static]

Definition at line 168 of file s_erf.c.

double pp4 = -2.37630166566501626084e-05 [static]

Definition at line 169 of file s_erf.c.

double qa1 = 1.06420880400844228286e-01 [static]

Definition at line 185 of file s_erf.c.

double qa2 = 5.40397917702171048937e-01 [static]

Definition at line 186 of file s_erf.c.

double qa3 = 7.18286544141962662868e-02 [static]

Definition at line 187 of file s_erf.c.

double qa4 = 1.26171219808761642112e-01 [static]

Definition at line 188 of file s_erf.c.

double qa5 = 1.36370839120290507362e-02 [static]

Definition at line 189 of file s_erf.c.

double qa6 = 1.19844998467991074170e-02 [static]

Definition at line 190 of file s_erf.c.

double qq1 = 3.97917223959155352819e-01 [static]

Definition at line 170 of file s_erf.c.

double qq2 = 6.50222499887672944485e-02 [static]

Definition at line 171 of file s_erf.c.

double qq3 = 5.08130628187576562776e-03 [static]

Definition at line 172 of file s_erf.c.

double qq4 = 1.32494738004321644526e-04 [static]

Definition at line 173 of file s_erf.c.

double qq5 = -3.96022827877536812320e-06 [static]

Definition at line 174 of file s_erf.c.

double ra0 = -9.86494403484714822705e-03 [static]

Definition at line 194 of file s_erf.c.

double ra1 = -6.93858572707181764372e-01 [static]

Definition at line 195 of file s_erf.c.

double ra2 = -1.05586262253232909814e+01 [static]

Definition at line 196 of file s_erf.c.

double ra3 = -6.23753324503260060396e+01 [static]

Definition at line 197 of file s_erf.c.

double ra4 = -1.62396669462573470355e+02 [static]

Definition at line 198 of file s_erf.c.

double ra5 = -1.84605092906711035994e+02 [static]

Definition at line 199 of file s_erf.c.

double ra6 = -8.12874355063065934246e+01 [static]

Definition at line 200 of file s_erf.c.

double ra7 = -9.81432934416914548592e+00 [static]

Definition at line 201 of file s_erf.c.

double rb0 = -9.86494292470009928597e-03 [static]

Definition at line 213 of file s_erf.c.

double rb1 = -7.99283237680523006574e-01 [static]

Definition at line 214 of file s_erf.c.

double rb2 = -1.77579549177547519889e+01 [static]

Definition at line 215 of file s_erf.c.

double rb3 = -1.60636384855821916062e+02 [static]

Definition at line 216 of file s_erf.c.

double rb4 = -6.37566443368389627722e+02 [static]

Definition at line 217 of file s_erf.c.

double rb5 = -1.02509513161107724954e+03 [static]

Definition at line 218 of file s_erf.c.

double rb6 = -4.83519191608651397019e+02 [static]

Definition at line 219 of file s_erf.c.

double sa1 = 1.96512716674392571292e+01 [static]

Definition at line 202 of file s_erf.c.

double sa2 = 1.37657754143519042600e+02 [static]

Definition at line 203 of file s_erf.c.

double sa3 = 4.34565877475229228821e+02 [static]

Definition at line 204 of file s_erf.c.

double sa4 = 6.45387271733267880336e+02 [static]

Definition at line 205 of file s_erf.c.

double sa5 = 4.29008140027567833386e+02 [static]

Definition at line 206 of file s_erf.c.

double sa6 = 1.08635005541779435134e+02 [static]

Definition at line 207 of file s_erf.c.

double sa7 = 6.57024977031928170135e+00 [static]

Definition at line 208 of file s_erf.c.

double sa8 = -6.04244152148580987438e-02 [static]

Definition at line 209 of file s_erf.c.

double sb1 = 3.03380607434824582924e+01 [static]

Definition at line 220 of file s_erf.c.

double sb2 = 3.25792512996573918826e+02 [static]

Definition at line 221 of file s_erf.c.

double sb3 = 1.53672958608443695994e+03 [static]

Definition at line 222 of file s_erf.c.

double sb4 = 3.19985821950859553908e+03 [static]

Definition at line 223 of file s_erf.c.

double sb5 = 2.55305040643316442583e+03 [static]

Definition at line 224 of file s_erf.c.

double sb6 = 4.74528541206955367215e+02 [static]

Definition at line 225 of file s_erf.c.

double sb7 = -2.24409524465858183362e+01 [static]

Definition at line 226 of file s_erf.c.

double tiny = 1e-300 [static]

Definition at line 154 of file s_erf.c.

double two = 2.00000000000000000000e+00 [static]

Definition at line 157 of file s_erf.c.