--- imach/src/imach.c 2002/03/06 19:02:50 1.29 +++ imach/src/imach.c 2002/03/08 16:17:18 1.30 @@ -1,4 +1,4 @@ -/* $Id: imach.c,v 1.29 2002/03/06 19:02:50 lievre Exp $ +/* $Id: imach.c,v 1.30 2002/03/08 16:17:18 lievre Exp $ Interpolated Markov Chain Short summary of the programme: @@ -1443,7 +1443,7 @@ void concatwav(int wav[], int **dh, int if (j >= jmax) jmax=j; if (j <= jmin) jmin=j; sum=sum+j; - /* if (j<10) printf("j=%d num=%d ",j,i); */ + /*if (j<0) printf("j=%d num=%d \n",j,i); */ } } else{ @@ -1451,7 +1451,7 @@ void concatwav(int wav[], int **dh, int k=k+1; if (j >= jmax) jmax=j; else if (j <= jmin)jmin=j; - /* if (j<10) printf("j=%d jmin=%d num=%d ",j,jmin,i); */ + /* if (j<10) printf("j=%d jmin=%d num=%d ",j,jmin,i); */ sum=sum+j; } jk= j/stepm; @@ -1546,32 +1546,29 @@ void evsij(char fileres[], double ***eij /* nhstepm age range expressed in number of stepm */ nhstepm=(int) rint((agelim-age)*YEARM/stepm); /* Typically if 20 years = 20*12/6=40 stepm */ - if (stepm >= YEARM) hstepm=1; + /*if (stepm >= YEARM) hstepm=1;*/ +hstepm=1; nhstepm = nhstepm/hstepm;/* Expressed in hstepm, typically 40/4=10 */ p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); /* Computed by stepm unit matrices, product of hstepm matrices, stored in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */ hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, ij); - - +hf=stepm/YEARM; +/*printf("stepm=%d nhstepm=%d hstepm=%d age=%lf ",stepm, nhstepm, hstepm, age);*/ for(i=1; i<=nlstate;i++) for(j=1; j<=nlstate;j++) for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){ - eij[i][j][(int)age] +=(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0; + eij[i][j][(int)age] +=hf*(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0; } - hf=1; - if (stepm >= YEARM) hf=stepm/YEARM; - - for(i=1; i<=nlstate;i++) - for(j=1; j<=nlstate;j++){ - if (j==i) eij[i][j][(int)age]= (eij[i][j][(int)age]-0.5*stepm/12./hf); - } - + /* hf=1; + if (stepm >= YEARM) hf=stepm/YEARM;*/ +hf=stepm/YEARM; + fprintf(ficreseij,"%3.0f",age ); for(i=1; i<=nlstate;i++) for(j=1; j<=nlstate;j++){ - fprintf(ficreseij," %9.4f", hf*eij[i][j][(int)age]); + fprintf(ficreseij," %9.4f", eij[i][j][(int)age]); } fprintf(ficreseij,"\n"); free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm); @@ -3171,7 +3168,7 @@ while((c=getc(ficpar))=='#' && c!= EOF){ /*---------- Forecasting ------------------*/ - if(stepm == 1) { + if((stepm == 1) && (model==".")){ prevforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anproj2,p, i1); if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1); free_matrix(mint,1,maxwav,1,n);