make the static variables, well.. static

This commit is contained in:
Antony Dovgal
2013-04-16 12:34:25 +00:00
parent dd956ce8ee
commit 2c0c4f16dc

164
randlib.c
View File

@@ -39,10 +39,10 @@ float genbet(float aa,float bb)
#define expmax 87.49823
#define infnty 1.0E38
#define minlog 1.0E-37
float olda = -1.0E37;
float oldb = -1.0E37;
float genbet,a,alpha,b,beta,delta,gamma,k1,k2,r,s,t,u1,u2,v,w,y,z;
long qsame;
static float olda = -1.0E37;
static float oldb = -1.0E37;
static float genbet,a,alpha,b,beta,delta,gamma,k1,k2,r,s,t,u1,u2,v,w,y,z;
static long qsame;
qsame = olda == aa && oldb == bb;
if(qsame) goto S20;
@@ -265,7 +265,7 @@ float genchi(float df)
**********************************************************************
*/
{
float genchi;
static float genchi;
if(!(df <= 0.0)) goto S10;
fputs(" DF <= 0 in GENCHI - ABORT\n",stderr);
@@ -302,7 +302,7 @@ float genexp(float av)
**********************************************************************
*/
{
float genexp;
static float genexp;
/* JJV added check that av >= 0 */
if(av >= 0.0) goto S10;
@@ -332,7 +332,7 @@ float genf(float dfn,float dfd)
**********************************************************************
*/
{
float genf,xden,xnum;
static float genf,xden,xnum;
if(!(dfn <= 0.0 || dfd <= 0.0)) goto S10;
fputs(" Degrees of freedom nonpositive in GENF - abort!\n",stderr);
@@ -403,7 +403,7 @@ float gengam(float a,float r)
**********************************************************************
*/
{
float gengam;
static float gengam;
/* JJV added argument checker */
if(a > 0.0 && r > 0.0) goto S10;
fputs(" A or R nonpositive in GENGAM - abort!\n",stderr);
@@ -436,8 +436,8 @@ void genmn(float *parm,float *x,float *work)
**********************************************************************
*/
{
long i,icount,j,p,D1,D2,D3,D4;
float ae;
static long i,icount,j,p,D1,D2,D3,D4;
static float ae;
p = (long) (*parm);
/*
@@ -493,8 +493,8 @@ void genmul(long n,float *p,long ncat,long *ix)
**********************************************************************
*/
{
float prob,ptot,sum;
long i,icat,ntot;
static float prob,ptot,sum;
static long i,icat,ntot;
if(n < 0) ftnstop2("N < 0 in GENMUL");
if(ncat <= 1) ftnstop2("NCAT <= 1 in GENMUL");
ptot = 0.0F;
@@ -547,7 +547,7 @@ float gennch(float df,float xnonc)
**********************************************************************
*/
{
float gennch;
static float gennch;
if(!(df < 1.0 || xnonc < 0.0)) goto S10;
fputs("DF < 1 or XNONC < 0 in GENNCH - ABORT\n",stderr);
@@ -594,8 +594,8 @@ float gennf(float dfn,float dfd,float xnonc)
**********************************************************************
*/
{
float gennf,xden,xnum;
long qcond;
static float gennf,xden,xnum;
static long qcond;
/* JJV changed qcond, error message to allow dfn == 1.0 */
qcond = dfn < 1.0 || dfd <= 0.0 || xnonc < 0.0;
@@ -667,7 +667,7 @@ float gennor(float av,float sd)
**********************************************************************
*/
{
float gennor;
static float gennor;
/* JJV added argument checker */
if(sd >= 0.0) goto S10;
@@ -690,7 +690,7 @@ void genprm(long *iarray,int larray)
**********************************************************************
*/
{
long i,itmp,iwhich,D1,D2;
static long i,itmp,iwhich,D1,D2;
for(i=1,D1=1,D2=(larray-i+D1)/D1; D2>0; D2--,i+=D1) {
iwhich = ignuin(i,larray);
@@ -712,7 +712,7 @@ float genunf(float low,float high)
**********************************************************************
*/
{
float genunf;
static float genunf;
if(!(low > high)) goto S10;
fprintf(stderr,"LOW > HIGH in GENUNF: LOW %16.6E HIGH: %16.6E\n",low,high);
@@ -736,7 +736,7 @@ void gscgn(long getset,long *g)
*/
{
#define numg 32L
long curntg = 1;
static long curntg = 1;
if(getset == 0) *g = curntg;
else {
if(*g < 0 || *g > numg) {
@@ -759,7 +759,7 @@ void gsrgs(long getset,long *qvalue)
**********************************************************************
*/
{
long qinit = 0;
static long qinit = 0;
if(getset == 0) *qvalue = qinit;
else qinit = *qvalue;
@@ -776,7 +776,7 @@ void gssst(long getset,long *qset)
**********************************************************************
*/
{
long qstate = 0;
static long qstate = 0;
if(getset != 0) qstate = 1;
else *qset = qstate;
}
@@ -889,10 +889,10 @@ long ignbin(long n,float pp)
*/
{
/* JJV changed initial values to ridiculous values */
float psave = -1.0E37;
long nsave = -214748365;
long ignbin,i,ix,ix1,k,m,mp,T1;
float al,alv,amaxp,c,f,f1,f2,ffm,fm,g,p,p1,p2,p3,p4,q,qn,r,u,v,w,w2,x,x1,
static float psave = -1.0E37;
static long nsave = -214748365;
static long ignbin,i,ix,ix1,k,m,mp,T1;
static float al,alv,amaxp,c,f,f1,f2,ffm,fm,g,p,p1,p2,p3,p4,q,qn,r,u,v,w,w2,x,x1,
x2,xl,xll,xlr,xm,xnp,xnpq,xr,ynorm,z,z2;
if(pp != psave) goto S10;
@@ -1072,8 +1072,8 @@ long ignnbn(long n,float p)
**********************************************************************
*/
{
long ignnbn;
float y,a,r;
static long ignnbn;
static float y,a,r;
/*
..
.. Executable Statements ..
@@ -1155,23 +1155,23 @@ long ignpoi(float mu)
*/
{
extern float fsign( float num, float sign );
float a0 = -0.5;
float a1 = 0.3333333;
float a2 = -0.2500068;
float a3 = 0.2000118;
float a4 = -0.1661269;
float a5 = 0.1421878;
float a6 = -0.1384794;
float a7 = 0.125006;
static float a0 = -0.5;
static float a1 = 0.3333333;
static float a2 = -0.2500068;
static float a3 = 0.2000118;
static float a4 = -0.1661269;
static float a5 = 0.1421878;
static float a6 = -0.1384794;
static float a7 = 0.125006;
/* JJV changed the initial values of MUPREV and MUOLD */
float muold = -1.0E37;
float muprev = -1.0E37;
float fact[10] = {
static float muold = -1.0E37;
static float muprev = -1.0E37;
static float fact[10] = {
1.0,1.0,2.0,6.0,24.0,120.0,720.0,5040.0,40320.0,362880.0
};
/* JJV added ll to the list, for Case A */
long ignpoi,j,k,kflag,l,ll,m;
float b1,b2,c,c0,c1,c2,c3,d,del,difmuk,e,fk,fx,fy,g,omega,p,p0,px,py,q,s,
static long ignpoi,j,k,kflag,l,ll,m;
static float b1,b2,c,c0,c1,c2,c3,d,del,difmuk,e,fk,fx,fy,g,omega,p,p0,px,py,q,s,
t,u,v,x,xx,pp[35];
if(mu == muprev) goto S10;
@@ -1371,7 +1371,7 @@ long ignuin(long low,long high)
*/
{
#define maxnum 2147483561L
long ignuin,ign,maxnow,range,ranp1;
static long ignuin,ign,maxnow,range,ranp1;
if(!(low > high)) goto S10;
fputs(" low > high in ignuin - ABORT\n",stderr);
@@ -1433,7 +1433,7 @@ long mltmod(long a,long s,long m)
*/
{
#define h 32768L
long mltmod,a0,a1,k,p,q,qh,rh;
static long mltmod,a0,a1,k,p,q,qh,rh;
/*
H = 2**((b-2)/2) where b = 32 because we are using a 32 bit
machine. On a different machine recompute H
@@ -1537,7 +1537,7 @@ void phrtsd(char* phrase,long *seed1,long *seed2)
*/
{
char table[] =
static char table[] =
"abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ\
0123456789\
@@ -1545,11 +1545,11 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ\
long ix;
long twop30 = 1073741824L;
long shift[5] = {
static long twop30 = 1073741824L;
static long shift[5] = {
1L,64L,4096L,262144L,16777216L
};
long i,ichr,j,lphr,values[5];
static long i,ichr,j,lphr,values[5];
extern long lennob(char *str);
*seed1 = 1234567890L;
@@ -1589,7 +1589,7 @@ float ranf(void)
**********************************************************************
*/
{
float ranf;
static float ranf;
/*
4.656613057E-10 is 1/M1 M1 is set in a data statement in IGNLGI
and is currently 2147483563. If M1 changes, change this also.
@@ -1622,8 +1622,8 @@ void setgmn(float *meanv,float *covm,long p,float *parm)
*/
{
extern void spofa(float *a,long lda,long n,long *info);
long T1;
long i,icount,info,j,D2,D3,D4,D5;
static long T1;
static long i,icount,info,j,D2,D3,D4,D5;
T1 = p*(p+3)/2+1;
/*
TEST THE INPUT
@@ -1691,13 +1691,13 @@ float sexpo(void)
(HERE 8) IS DETERMINED BY Q(N)=1.0 WITHIN STANDARD PRECISION
*/
{
float q[8] = {
static float q[8] = {
0.6931472,0.9333737,0.9888778,0.9984959,0.9998293,0.9999833,0.9999986,
.9999999
};
long i;
float sexpo,a,u,ustar,umin;
float *q1 = q;
static long i;
static float sexpo,a,u,ustar,umin;
static float *q1 = q;
a = 0.0;
u = ranf();
goto S30;
@@ -1781,30 +1781,30 @@ float sgamma(float a)
*/
{
extern float fsign( float num, float sign );
float q1 = 4.166669E-2;
float q2 = 2.083148E-2;
float q3 = 8.01191E-3;
float q4 = 1.44121E-3;
float q5 = -7.388E-5;
float q6 = 2.4511E-4;
float q7 = 2.424E-4;
float a1 = 0.3333333;
float a2 = -0.250003;
float a3 = 0.2000062;
float a4 = -0.1662921;
float a5 = 0.1423657;
float a6 = -0.1367177;
float a7 = 0.1233795;
float e1 = 1.0;
float e2 = 0.4999897;
float e3 = 0.166829;
float e4 = 4.07753E-2;
float e5 = 1.0293E-2;
float aa = 0.0;
float aaa = 0.0;
float sqrt32 = 5.656854;
static float q1 = 4.166669E-2;
static float q2 = 2.083148E-2;
static float q3 = 8.01191E-3;
static float q4 = 1.44121E-3;
static float q5 = -7.388E-5;
static float q6 = 2.4511E-4;
static float q7 = 2.424E-4;
static float a1 = 0.3333333;
static float a2 = -0.250003;
static float a3 = 0.2000062;
static float a4 = -0.1662921;
static float a5 = 0.1423657;
static float a6 = -0.1367177;
static float a7 = 0.1233795;
static float e1 = 1.0;
static float e2 = 0.4999897;
static float e3 = 0.166829;
static float e4 = 4.07753E-2;
static float e5 = 1.0293E-2;
static float aa = 0.0;
static float aaa = 0.0;
static float sqrt32 = 5.656854;
/* JJV added b0 to fix rare and subtle bug */
float sgamma,s2,s,d,t,x,u,r,q0,b,b0,si,c,v,q,e,w,p;
static float sgamma,s2,s,d,t,x,u,r,q0,b,b0,si,c,v,q,e,w,p;
if(a == aa) goto S10;
if(a < 1.0) goto S120;
/*
@@ -1995,35 +1995,35 @@ float snorm(void)
H(K) ARE ACCORDING TO THE ABOVEMENTIONED ARTICLE
*/
{
float a[32] = {
static float a[32] = {
0.0,3.917609E-2,7.841241E-2,0.11777,0.1573107,0.1970991,0.2372021,0.2776904,
0.3186394,0.36013,0.4022501,0.4450965,0.4887764,0.5334097,0.5791322,
0.626099,0.6744898,0.7245144,0.7764218,0.8305109,0.8871466,0.9467818,
1.00999,1.077516,1.150349,1.229859,1.318011,1.417797,1.534121,1.67594,
1.862732,2.153875
};
float d[31] = {
static float d[31] = {
0.0,0.0,0.0,0.0,0.0,0.2636843,0.2425085,0.2255674,0.2116342,0.1999243,
0.1899108,0.1812252,0.1736014,0.1668419,0.1607967,0.1553497,0.1504094,
0.1459026,0.14177,0.1379632,0.1344418,0.1311722,0.128126,0.1252791,
0.1226109,0.1201036,0.1177417,0.1155119,0.1134023,0.1114027,0.1095039
};
float t[31] = {
static float t[31] = {
7.673828E-4,2.30687E-3,3.860618E-3,5.438454E-3,7.0507E-3,8.708396E-3,
1.042357E-2,1.220953E-2,1.408125E-2,1.605579E-2,1.81529E-2,2.039573E-2,
2.281177E-2,2.543407E-2,2.830296E-2,3.146822E-2,3.499233E-2,3.895483E-2,
4.345878E-2,4.864035E-2,5.468334E-2,6.184222E-2,7.047983E-2,8.113195E-2,
9.462444E-2,0.1123001,0.136498,0.1716886,0.2276241,0.330498,0.5847031
};
float h[31] = {
static float h[31] = {
3.920617E-2,3.932705E-2,3.951E-2,3.975703E-2,4.007093E-2,4.045533E-2,
4.091481E-2,4.145507E-2,4.208311E-2,4.280748E-2,4.363863E-2,4.458932E-2,
4.567523E-2,4.691571E-2,4.833487E-2,4.996298E-2,5.183859E-2,5.401138E-2,
5.654656E-2,5.95313E-2,6.308489E-2,6.737503E-2,7.264544E-2,7.926471E-2,
8.781922E-2,9.930398E-2,0.11556,0.1404344,0.1836142,0.2790016,0.7010474
};
long i;
float snorm,u,s,ustar,aa,w,y,tt;
static long i;
static float snorm,u,s,ustar,aa,w,y,tt;
u = ranf();
s = 0.0;
if(u > 0.5) s = 1.0;