Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
cdf_39.c
Go to the documentation of this file.00001 #include "cdflib.h"
00002 double dinvnr(double *p,double *q)
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 {
00043 #define maxit 100
00044 #define eps (1.0e-13)
00045 #define r2pi 0.3989422804014326e0
00046 #define nhalf (-0.5e0)
00047 #define dennor(x) (r2pi*exp(nhalf*(x)*(x)))
00048 static double dinvnr,strtx,xcur,cum,ccum,pp,dx;
00049 static int i;
00050 static unsigned long qporq;
00051
00052
00053
00054
00055
00056
00057
00058 qporq = *p <= *q;
00059 if(!qporq) goto S10;
00060 pp = *p;
00061 goto S20;
00062 S10:
00063 pp = *q;
00064 S20:
00065
00066
00067
00068 strtx = stvaln(&pp);
00069 xcur = strtx;
00070
00071
00072
00073 for(i=1; i<=maxit; i++) {
00074 cumnor(&xcur,&cum,&ccum);
00075 dx = (cum-pp)/dennor(xcur);
00076 xcur -= dx;
00077 if(fabs(dx/xcur) < eps) goto S40;
00078 }
00079 dinvnr = strtx;
00080
00081
00082
00083 if(!qporq) dinvnr = -dinvnr;
00084 return dinvnr;
00085 S40:
00086
00087
00088
00089 dinvnr = xcur;
00090 if(!qporq) dinvnr = -dinvnr;
00091 return dinvnr;
00092 #undef maxit
00093 #undef eps
00094 #undef r2pi
00095 #undef nhalf
00096 #undef dennor
00097 }