Diff for /imach/src/imach.c between versions 1.160 and 1.161

version 1.160, 2014/09/02 09:24:05 version 1.161, 2014/09/15 20:41:41
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.161  2014/09/15 20:41:41  brouard
     Summary: Problem with macro SQR on Intel compiler
   
   Revision 1.160  2014/09/02 09:24:05  brouard    Revision 1.160  2014/09/02 09:24:05  brouard
   *** empty log message ***    *** empty log message ***
   
Line 1400  void powell(double p[], double **xi, int Line 1403  void powell(double p[], double **xi, int
       return;         return; 
     }       } 
     if (*iter == ITMAX) nrerror("powell exceeding maximum iterations.");       if (*iter == ITMAX) nrerror("powell exceeding maximum iterations."); 
     for (j=1;j<=n;j++) {       for (j=1;j<=n;j++) { /* Computes an extrapolated point */
       ptt[j]=2.0*p[j]-pt[j];         ptt[j]=2.0*p[j]-pt[j]; 
       xit[j]=p[j]-pt[j];         xit[j]=p[j]-pt[j]; 
       pt[j]=p[j];         pt[j]=p[j]; 
     }       } 
     fptt=(*func)(ptt);       fptt=(*func)(ptt); 
     if (fptt < fp) {       if (fptt < fp) { /* If extrapolated point is better, decide if we keep that new direction or not */
       t=2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del)-del*SQR(fp-fptt);         /* x1 f1=fp x2 f2=*fret x3 f3=fptt, xm fm */
       if (t < 0.0) {         /* From x1 (P0) distance of x2 is at h and x3 is 2h */
         linmin(p,xit,n,fret,func);         /* Let f"(x2) be the 2nd derivative equal everywhere. Then the parabolic through (x1,f1), (x2,f2) and (x3,f3)
            will reach at f3 = fm + h^2/2 f''m  ; f" = (f1 -2f2 +f3 ) / h**2 */
         /* f1-f3 = delta(2h) = 2 h**2 f'' = 2(f1- 2f2 +f3) */
         /* Thus we compare delta(2h) with observed f1-f3 */
         /* or best gain on one ancient line 'del' with total gain f1-f2 = f1 - f2 - 'del' with del */ 
         /* t=2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del)-del*SQR(fp-fptt); */
         t=2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del);
         t= t- del*SQR(fp-fptt);
         printf("t1= %.12lf, t2= %.12lf, t=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t);
         fprintf(ficlog,"t1= %.12lf, t2= %.12lf, t=%.12lf\n", 2.0*(fp-2.0*(*fret)+fptt)*SQR(fp-(*fret)-del),del*SQR(fp-fptt),t);
   #ifdef DEBUG
         printf("t3= %.12lf, t4= %.12lf, t3*= %.12lf, t4*= %.12lf\n",SQR(fp-(*fret)-del),SQR(fp-fptt),
                (fp-(*fret)-del)*(fp-(*fret)-del),(fp-fptt)*(fp-fptt));
         fprintf(ficlog,"t3= %.12lf, t4= %.12lf, t3*= %.12lf, t4*= %.12lf\n",SQR(fp-(*fret)-del),SQR(fp-fptt),
                (fp-(*fret)-del)*(fp-(*fret)-del),(fp-fptt)*(fp-fptt));
         printf("tt= %.12lf, t=%.12lf\n",2.0*(fp-2.0*(*fret)+fptt)*(fp-(*fret)-del)*(fp-(*fret)-del)-del*(fp-fptt)*(fp-fptt),t);
         fprintf(ficlog, "tt= %.12lf, t=%.12lf\n",2.0*(fp-2.0*(*fret)+fptt)*(fp-(*fret)-del)*(fp-(*fret)-del)-del*(fp-fptt)*(fp-fptt),t);
   #endif
         if (t < 0.0) { /* Then we use it for last direction */
           linmin(p,xit,n,fret,func); /* computes mean on the extrapolated direction.*/
         for (j=1;j<=n;j++) {           for (j=1;j<=n;j++) { 
           xi[j][ibig]=xi[j][n];             xi[j][ibig]=xi[j][n]; /* Replace the direction with biggest decrease by n */
           xi[j][n]=xit[j];             xi[j][n]=xit[j];      /* and nth direction by the extrapolated */
         }          }
           printf("Gaining to use average direction of P0 P%d instead of biggest increase direction %d :\n",n,ibig);
           fprintf(ficlog,"Gaining to use average direction of P0 P%d instead of biggest increase direction :\n",n,ibig);
   
 #ifdef DEBUG  #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++){          for(j=1;j<=n;j++){
           printf(" %.12e",xit[j]);            printf(" %.12e",xit[j]);
           fprintf(ficlog," %.12e",xit[j]);            fprintf(ficlog," %.12e",xit[j]);
Line 6569  Interval (in months) between two waves: Line 6592  Interval (in months) between two waves:
   
         for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/          for(vpopbased=0; vpopbased <= popbased; vpopbased++){ /* Done for vpopbased=0 and vpopbased=1 if popbased==1*/
           oldm=oldms;savm=savms; /* Segmentation fault */            oldm=oldms;savm=savms; /* Segmentation fault */
           varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,vpopbased,mobilav, strstart);            cptcod= 0; /* To be deleted */
             varevsij(optionfilefiname, vareij, matcov, p, delti, nlstate, stepm, (int) bage, (int) fage, oldm, savm, prlim, ftolpl,k, estepm, cptcov,cptcod,vpopbased,mobilav, strstart); /* cptcod not initialized Intel */
           fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n#  (weighted average of eij where weights are ");            fprintf(ficrest,"# Total life expectancy with std error and decomposition into time to be expected in each health state\n#  (weighted average of eij where weights are ");
           if(vpopbased==1)            if(vpopbased==1)
             fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav);              fprintf(ficrest,"the age specific prevalence observed (cross-sectionally) in the population i.e cross-sectionally\n in each health state (popbased=1) (mobilav=%d)\n",mobilav);

Removed from v.1.160  
changed lines
  Added in v.1.161


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>