Back to index

radiance  4R0+20100331
Defines | Functions | Variables
erf.c File Reference

Go to the source code of this file.

Defines

#define M   7
#define N   9

Functions

double erf (double arg)
double erfc (double arg)

Variables

static const char RCSid [] = "$Id: erf.c,v 3.1 2003/02/22 02:07:22 greg Exp $"
static char sccsid [] = "@(#)erf.c 1.1 87/12/21 SMI"
static double torp = 1.1283791670955125738961589031
static double p1 []
static double q1 []
static double p2 []
static double q2 []

Define Documentation

#define M   7

Definition at line 29 of file erf.c.

#define N   9

Definition at line 30 of file erf.c.


Function Documentation

double erf ( double  arg)

Definition at line 74 of file erf.c.

                    {
       double erfc();
       int sign;
       double argsq;
       double d, n;
       int i;

       sign = 1;
       if(arg < 0.){
              arg = -arg;
              sign = -1;
       }
       if(arg < 0.5){
              argsq = arg*arg;
              for(n=0,d=0,i=M-1; i>=0; i--){
                     n = n*argsq + p1[i];
                     d = d*argsq + q1[i];
              }
              return(sign*torp*arg*n/d);
       }
       if(arg >= 10.)
              return(sign*1.);
       return(sign*(1. - erfc(arg)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

double erfc ( double  arg)

Definition at line 100 of file erf.c.

                     {
       double erf();
       double exp();
       double n, d;
       int i;

       if(arg < 0.)
              return(2. - erfc(-arg));
/*
       if(arg < 0.5)
              return(1. - erf(arg));
*/
       if(arg >= 10.)
              return(0.);

       for(n=0,d=0,i=N-1; i>=0; i--){
              n = n*arg + p2[i];
              d = d*arg + q2[i];
       }
       return(exp(-arg*arg)*n/d);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

double p1[] [static]
Initial value:
 {
       0.804373630960840172832162e5,
       0.740407142710151470082064e4,
       0.301782788536507577809226e4,
       0.380140318123903008244444e2,
       0.143383842191748205576712e2,
       -.288805137207594084924010e0,
       0.007547728033418631287834e0,
}

Definition at line 32 of file erf.c.

double p2[] [static]
Initial value:
 {
       0.18263348842295112592168999e4,
       0.28980293292167655611275846e4,
       0.2320439590251635247384768711e4,
       0.1143262070703886173606073338e4,
       0.3685196154710010637133875746e3,
       0.7708161730368428609781633646e2,
       0.9675807882987265400604202961e1,
       0.5641877825507397413087057563e0,
       0.0,
}

Definition at line 50 of file erf.c.

double q1[] [static]
Initial value:
 {
       0.804373630960840172826266e5,
       0.342165257924628539769006e5,
       0.637960017324428279487120e4,
       0.658070155459240506326937e3,
       0.380190713951939403753468e2,
       0.100000000000000000000000e1,
       0.0,
}

Definition at line 41 of file erf.c.

double q2[] [static]
Initial value:
 {
       0.18263348842295112595576438e4,
       0.495882756472114071495438422e4,
       0.60895424232724435504633068e4,
       0.4429612803883682726711528526e4,
       0.2094384367789539593790281779e4,
       0.6617361207107653469211984771e3,
       0.1371255960500622202878443578e3,
       0.1714980943627607849376131193e2,
       1.0,
}

Definition at line 61 of file erf.c.

const char RCSid[] = "$Id: erf.c,v 3.1 2003/02/22 02:07:22 greg Exp $" [static]

Definition at line 2 of file erf.c.

char sccsid[] = "@(#)erf.c 1.1 87/12/21 SMI" [static]

Definition at line 5 of file erf.c.

double torp = 1.1283791670955125738961589031 [static]

Definition at line 31 of file erf.c.