if (j >= jmax) jmax=j;\r
if (j <= jmin) jmin=j;\r
sum=sum+j;\r
- /* if (j<10) printf("j=%d num=%d ",j,i); */\r
+ /*if (j<0) printf("j=%d num=%d \n",j,i); */\r
}\r
}\r
else{\r
k=k+1;\r
if (j >= jmax) jmax=j;\r
else if (j <= jmin)jmin=j;\r
- /* if (j<10) printf("j=%d jmin=%d num=%d ",j,jmin,i); */\r
+ /* if (j<10) printf("j=%d jmin=%d num=%d ",j,jmin,i); */\r
sum=sum+j;\r
}\r
jk= j/stepm;\r
/* nhstepm age range expressed in number of stepm */\r
nhstepm=(int) rint((agelim-age)*YEARM/stepm); \r
/* Typically if 20 years = 20*12/6=40 stepm */ \r
- if (stepm >= YEARM) hstepm=1;\r
+ /*if (stepm >= YEARM) hstepm=1;*/\r
+hstepm=1;\r
nhstepm = nhstepm/hstepm;/* Expressed in hstepm, typically 40/4=10 */\r
p3mat=ma3x(1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
/* Computed by stepm unit matrices, product of hstepm matrices, stored\r
in an array of nhstepm length: nhstepm=10, hstepm=4, stepm=6 months */\r
hpxij(p3mat,nhstepm,age,hstepm,x,nlstate,stepm,oldm, savm, ij); \r
-\r
-\r
+hf=stepm/YEARM;\r
+/*printf("stepm=%d nhstepm=%d hstepm=%d age=%lf ",stepm, nhstepm, hstepm, age);*/\r
for(i=1; i<=nlstate;i++)\r
for(j=1; j<=nlstate;j++)\r
for (h=0, eij[i][j][(int)age]=0; h<=nhstepm-1; h++){\r
- eij[i][j][(int)age] +=(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0;\r
+ eij[i][j][(int)age] +=hf*(p3mat[i][j][h]+p3mat[i][j][h+1])/2.0;\r
}\r
\r
- hf=1;\r
- if (stepm >= YEARM) hf=stepm/YEARM;\r
-\r
- for(i=1; i<=nlstate;i++)\r
- for(j=1; j<=nlstate;j++){\r
- if (j==i) eij[i][j][(int)age]= (eij[i][j][(int)age]-0.5*stepm/12./hf);\r
- }\r
-\r
+ /* hf=1;\r
+ if (stepm >= YEARM) hf=stepm/YEARM;*/\r
+hf=stepm/YEARM;\r
+ \r
fprintf(ficreseij,"%3.0f",age );\r
for(i=1; i<=nlstate;i++)\r
for(j=1; j<=nlstate;j++){\r
- fprintf(ficreseij," %9.4f", hf*eij[i][j][(int)age]);\r
+ fprintf(ficreseij," %9.4f", eij[i][j][(int)age]);\r
}\r
fprintf(ficreseij,"\n");\r
free_ma3x(p3mat,1,nlstate+ndeath,1, nlstate+ndeath, 0,nhstepm);\r
\r
\r
/*---------- Forecasting ------------------*/\r
- if(stepm == 1) {\r
+ if((stepm == 1) && (model==".")){\r
prevforecast(fileres, anproj1,mproj1,jproj1, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anproj2,p, i1);\r
if (popforecast==1) populforecast(fileres, anpyram,mpyram,jpyram, agemin,agemax, dateprev1, dateprev2,mobilav, agedeb, fage, popforecast, popfile, anpyram1,p, i1);\r
free_matrix(mint,1,maxwav,1,n);\r