From 729e30d85376db2979f153146772cb7daebbec06 Mon Sep 17 00:00:00 2001 From: "N. Brouard" Date: Tue, 16 Dec 2014 10:52:11 +0000 Subject: [PATCH] Summary: Merging with Visual C after suppressing some warnings for unused variables. Also fixing Saito's bug 0.98Xn * imach.c (Module): Merging 1.61 to 1.162 --- src/imach.c | 117 +++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 60 deletions(-) diff --git a/src/imach.c b/src/imach.c index 1aaee1b..b0aa4a0 100644 --- a/src/imach.c +++ b/src/imach.c @@ -1,6 +1,9 @@ /* $Id$ $State$ $Log$ + Revision 1.163 2014/12/16 10:30:11 brouard + * imach.c (Module): Merging 1.61 to 1.162 + Revision 1.162 2014/09/25 11:43:39 brouard Summary: temporary backup 0.99! @@ -554,7 +557,7 @@ typedef struct { #define YEARM 12. /**< Number of months per year */ #define AGESUP 130 #define AGEBASE 40 -#define AGEGOMP 10. /**< Minimal age for Gompertz adjustment */ +#define AGEGOMP 10 /**< Minimal age for Gompertz adjustment */ #ifdef _WIN32 #define DIRSEPARATOR '\\' #define CHARSEPARATOR "\\" @@ -1146,7 +1149,7 @@ double brent(double ax, double bx, double cx, double (*f)(double), double tol, int iter; double a,b,d,etemp; double fu=0,fv,fw,fx; - double ftemp; + double ftemp=0.; double p,q,r,tol1,tol2,u,v,w,x,xm; double e=0.0; @@ -1380,8 +1383,8 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret for (j=1;j<=n;j++) xit[j]=xi[j][i]; fptt=(*fret); #ifdef DEBUG - printf("fret=%lf \n",*fret); - fprintf(ficlog,"fret=%lf \n",*fret); + printf("fret=%lf, %lf, %lf \n", *fret, *fret, *fret); + fprintf(ficlog, "fret=%lf, %lf, %lf \n", *fret, *fret, *fret); #endif printf("%d",i);fflush(stdout); fprintf(ficlog,"%d",i);fflush(ficlog); @@ -1478,6 +1481,8 @@ void powell(double p[], double **xi, int n, double ftol, int *iter, double *fret fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction :\n",n,ibig); #ifdef DEBUG + printf("Direction changed last moved %d in place of ibig=%d, new last is the average:\n",n,ibig); + fprintf(ficlog,"Direction changed last moved %d in place of ibig=%d, new last is the average:\n",n,ibig); for(j=1;j<=n;j++){ printf(" %.12e",xit[j]); fprintf(ficlog," %.12e",xit[j]); @@ -1574,7 +1579,7 @@ double **pmij(double **ps, double *cov, int ncovmodel, double *x, int nlstate ) */ double s1, lnpijopii; /*double t34;*/ - int i,j,j1, nc, ii, jj; + int i,j, nc, ii, jj; for(i=1; i<= nlstate; i++){ for(j=1; jkhi/nkhif) || (k2 >khi/nkhif)){ /* Keeps lastvalue before 3.84/2 KHI2 5% 1d.f. */ - k=kmax; l=lmax*10.; + k=kmax; l=lmax*10; } else if((k1 >khi/nkhi) || (k2 >khi/nkhi)){ delts=delt; @@ -2362,7 +2367,7 @@ double hessii(double x[], double delta, int theta, double delti[], double (*func double hessij( double x[], double delti[], int thetai,int thetaj,double (*func)(double []),int npar) { int i; - int l=1, l1, lmax=20; + int l=1, lmax=20; double k1,k2,k3,k4,res,fx; double p2[MAXPARM+1]; int k; @@ -2477,7 +2482,7 @@ void pstamp(FILE *fichier) void freqsummary(char fileres[], int iagemin, int iagemax, int **s, double **agev, int nlstate, int imx, int *Tvaraff, int **nbcode, int *ncodemax,double **mint,double **anint, char strstart[]) { /* Some frequencies */ - int i, m, jk, k1,i1, j1, bool, z1,j; + int i, m, jk, j1, bool, z1,j; int first; double ***freq; /* Frequencies */ double *pp, **prop; @@ -2658,10 +2663,10 @@ void prevalence(double ***probs, double agemin, double agemax, int **s, double * We still use firstpass and lastpass as another selection. */ - int i, m, jk, k1, i1, j1, bool, z1,j; - double ***freq; /* Frequencies */ - double *pp, **prop; - double pos,posprop; + int i, m, jk, j1, bool, z1,j; + + double **prop; + double posprop; double y2; /* in fractional years */ int iagemin, iagemax; int first; /** to stop verbosity which is redirected to log file */ @@ -2752,7 +2757,7 @@ void concatwav(int wav[], int **dh, int **bh, int **mw, int **s, double *agedc int j, k=0,jk, ju, jl; double sum=0.; first=0; - jmin=1e+5; + jmin=100000; jmax=-1; jmean=0.; for(i=1; i<=imx; i++){ @@ -2992,7 +2997,7 @@ void evsij(double ***eij, double x[], int nlstate, int stepm, int bage, int fage { /* Health expectancies, no variances */ - int i, j, nhstepm, hstepm, h, nstepm, k, cptj, cptj2, i2, j2; + int i, j, nhstepm, hstepm, h, nstepm; int nhstepma, nstepma; /* Decreasing with age */ double age, agelim, hf; double ***p3mat; @@ -3314,7 +3319,7 @@ void varevsij(char optionfilefiname[], double ***vareij, double **matcov, double double **dnewm,**doldm; double **dnewmp,**doldmp; int i, j, nhstepm, hstepm, h, nstepm ; - int k, cptcode; + int k; double *xp; double **gp, **gm; /* for var eij */ double ***gradg, ***trgradg; /*for var eij */ @@ -3614,10 +3619,9 @@ void varprevlim(char fileres[], double **varpl, double **matcov, double x[], dou { /* Variance of prevalence limit */ /* double **prevalim(double **prlim, int nlstate, double *xp, double age, double **oldm, double **savm,double ftolpl);*/ - double **newm; + double **dnewm,**doldm; int i, j, nhstepm, hstepm; - int k, cptcode; double *xp; double *gp, *gm; double **gradg, **trgradg; @@ -3696,9 +3700,9 @@ void varprevlim(char fileres[], double **varpl, double **matcov, double x[], dou /************ Variance of one-step probabilities ******************/ void varprob(char optionfilefiname[], double **matcov, double x[], double delti[], int nlstate, double bage, double fage, int ij, int *Tvar, int **nbcode, int *ncodemax, char strstart[]) { - int i, j=0, i1, k1, l1, t, tj; + int i, j=0, k1, l1, tj; int k2, l2, j1, z1; - int k=0,l, cptcode; + int k=0, l; int first=1, first1, first2; double cv12, mu1, mu2, lc1, lc2, v12, v21, v11, v22,v1,v2, c12, tnalp; double **dnewm,**doldm; @@ -3706,7 +3710,7 @@ void varprob(char optionfilefiname[], double **matcov, double x[], double delti[ double *gp, *gm; double **gradg, **trgradg; double **mu; - double age,agelim, cov[NCOVMAX+1]; + double age, cov[NCOVMAX+1]; double std=2.0; /* Number of standard deviation wide of confidence ellipsoids */ int theta; char fileresprob[FILENAMELENGTH]; @@ -4078,7 +4082,7 @@ fprintf(fichtm," \n