Diff for /imach/src/imach.c between versions 1.291 and 1.292

version 1.291, 2019/05/09 13:44:18 version 1.292, 2019/05/09 14:17:20
Line 1 Line 1
 /* $Id$  /* $Id$
   $State$    $State$
   $Log$    $Log$
     Revision 1.292  2019/05/09 14:17:20  brouard
     Summary: Some updates
   
   Revision 1.291  2019/05/09 13:44:18  brouard    Revision 1.291  2019/05/09 13:44:18  brouard
   Summary: Before ncovmax    Summary: Before ncovmax
   
Line 2992  double **pmij(double **ps, double *cov, Line 2995  double **pmij(double **ps, double *cov,
   double **out, **pmij();    double **out, **pmij();
   double sumnew=0.;    double sumnew=0.;
   double agefin;    double agefin;
   double k3=0.; /* constant of the w_x diagonal matrixe (in order for B to sum to 1 even for death state) */    double k3=0.; /* constant of the w_x diagonal matrix (in order for B to sum to 1 even for death state) */
   double **dnewm, **dsavm, **doldm;    double **dnewm, **dsavm, **doldm;
   double **bbmij;    double **bbmij;
       
Line 3011  double **pmij(double **ps, double *cov, Line 3014  double **pmij(double **ps, double *cov,
   /* outputs pmmij which is a stochastic matrix in row */    /* outputs pmmij which is a stochastic matrix in row */
   
   /* Diag(w_x) */    /* Diag(w_x) */
   /* Problem with prevacurrent which can be zero */    /* Rescaling the cross-sectional prevalence: Problem with prevacurrent which can be zero */
   sumnew=0.;    sumnew=0.;
   /*for (ii=1;ii<=nlstate+ndeath;ii++){*/    /*for (ii=1;ii<=nlstate+ndeath;ii++){*/
   for (ii=1;ii<=nlstate;ii++){ /* Only on live states */    for (ii=1;ii<=nlstate;ii++){ /* Only on live states */
Line 3038  double **pmij(double **ps, double *cov, Line 3041  double **pmij(double **ps, double *cov,
   }    }
   /* End doldm, At the end doldm is diag[(w_i)] */    /* End doldm, At the end doldm is diag[(w_i)] */
       
   /* left Product of this diag matrix by pmmij=Px (dnewm=dsavm*doldm) */    /* Left product of this diag matrix by pmmij=Px (dnewm=dsavm*doldm): diag[(w_i)*Px */
   bbmij=matprod2(dnewm, doldm,1,nlstate+ndeath,1,nlstate+ndeath,1,nlstate+ndeath, pmmij); /* Bug Valgrind */    bbmij=matprod2(dnewm, doldm,1,nlstate+ndeath,1,nlstate+ndeath,1,nlstate+ndeath, pmmij); /* was a Bug Valgrind */
   
   /* Diag(Sum_i w^i_x p^ij_x */    /* Diag(Sum_i w^i_x p^ij_x, should be the prevalence at age x+stepm */
   /* w1 p11 + w2 p21 only on live states N1./N..*N11/N1. + N2./N..*N21/N2.=(N11+N21)/N..=N.1/N.. */    /* w1 p11 + w2 p21 only on live states N1./N..*N11/N1. + N2./N..*N21/N2.=(N11+N21)/N..=N.1/N.. */
   for (j=1;j<=nlstate+ndeath;j++){    for (j=1;j<=nlstate+ndeath;j++){
     sumnew=0.;      sumnew=0.;
Line 3059  double **pmij(double **ps, double *cov, Line 3062  double **pmij(double **ps, double *cov,
     } /*End ii */      } /*End ii */
   } /* End j, At the end dsavm is diag[1/(w_1p1i+w_2 p2i)] for ALL states even if the sum is only for live states */    } /* End j, At the end dsavm is diag[1/(w_1p1i+w_2 p2i)] for ALL states even if the sum is only for live states */
   
   ps=matprod2(ps, dnewm,1,nlstate+ndeath,1,nlstate+ndeath,1,nlstate+ndeath, dsavm); /* Bug Valgrind */    ps=matprod2(ps, dnewm,1,nlstate+ndeath,1,nlstate+ndeath,1,nlstate+ndeath, dsavm); /* was a Bug Valgrind */
   /* ps is now diag[w_i] * Px * diag [1/(w_1p1i+w_2 p2i)] */    /* ps is now diag[w_i] * Px * diag [1/(w_1p1i+w_2 p2i)] */
   /* end bmij */    /* end bmij */
   return ps; /*pointer is unchanged */    return ps; /*pointer is unchanged */
Line 3891  return -l; Line 3894  return -l;
   
   
 /*************** function likelione ***********/  /*************** function likelione ***********/
 void likelione(FILE *ficres,double p[], int npar, int nlstate, int *globpri, long *ipmx, double *sw, double *fretone, double (*funcone)(double []))  void likelione(FILE *ficres,double p[], int npar, int nlstate, int *globpri, long *ipmx, double *sw, double *fretone, double (*func)(double []))
 {  {
   /* This routine should help understanding what is done with     /* This routine should help understanding what is done with 
      the selection of individuals/waves and       the selection of individuals/waves and
Line 3915  void likelione(FILE *ficres,double p[], Line 3918  void likelione(FILE *ficres,double p[],
     fprintf(ficresilk," -2*gipw/gsw*weight*ll(total)\n");      fprintf(ficresilk," -2*gipw/gsw*weight*ll(total)\n");
   }    }
   
   *fretone=(*funcone)(p);    *fretone=(*func)(p);
   if(*globpri !=0){    if(*globpri !=0){
     fclose(ficresilk);      fclose(ficresilk);
     if (mle ==0)      if (mle ==0)
Line 6009  void  concatwav(int wav[], int **dh, int Line 6012  void  concatwav(int wav[], int **dh, int
        /**< Computes the shifted transition matrix \f$ {}{h}_p^{ij}_x\f$ at horizon h.         /**< Computes the shifted transition matrix \f$ {}{h}_p^{ij}_x\f$ at horizon h.
         */                                */                      
        hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij,nres);  /* Returns p3mat[i][j][h] for h=0 to nhstepm */         hpxij(p3mat,nhstepm,age,hstepm,xp,nlstate,stepm,oldm,savm, ij,nres);  /* Returns p3mat[i][j][h] for h=0 to nhstepm */
        /**< And for each alive state j, sums over i \f$ w^i_x {}{h}_p^{ij}_x\f$, which are the probability         /**< And for each alive state j, sums over i \f$ w^i_x {}{h}_p^{ij}x\f$, which are the probability
         * at horizon h in state j including mortality.          * at horizon h in state j including mortality.
         */          */
        for(j=1; j<= nlstate; j++){         for(j=1; j<= nlstate; j++){
Line 6931  divided by h: <sub>h</sub>P<sub>ij</sub> Line 6934  divided by h: <sub>h</sub>P<sub>ij</sub>
 <img src=\"%s_%d-3-%d.svg\">",stepm,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres);   <img src=\"%s_%d-3-%d.svg\">",stepm,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres,subdirf2(optionfilefiname,"PE_"),k1,nres); 
      /* Survival functions (period) in state j */       /* Survival functions (period) in state j */
      for(cpt=1; cpt<=nlstate;cpt++){       for(cpt=1; cpt<=nlstate;cpt++){
        fprintf(fichtm,"<br>\n- Survival functions in state %d. Or probability to survive in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \         fprintf(fichtm,"<br>\n- Survival functions in state %d. And probability to be observed in state %d being in state (1 to %d) at different ages. <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> \
 <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres);  <img src=\"%s_%d-%d-%d.svg\">", cpt, cpt, nlstate, subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJ_"),cpt,k1,nres);
      }       }
      /* State specific survival functions (period) */       /* State specific survival functions (period) */
      for(cpt=1; cpt<=nlstate;cpt++){       for(cpt=1; cpt<=nlstate;cpt++){
        fprintf(fichtm,"<br>\n- Survival functions from state %d in each live state and total.\         fprintf(fichtm,"<br>\n- Survival functions in state %d and in any other live state (total).\
  Or probability to survive in various states (1 to %d) being in state %d at different ages.     \   And probability to be observed in various states (up to %d) being in state %d at different ages.       \
  <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> <img src=\"%s_%d-%d-%d.svg\">", cpt, nlstate, cpt, subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres);   <a href=\"%s_%d-%d-%d.svg\">%s_%d-%d-%d.svg</a><br> <img src=\"%s_%d-%d-%d.svg\">", cpt, nlstate, cpt, subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres,subdirf2(optionfilefiname,"LIJT_"),cpt,k1,nres);
      }       }
      /* Period (forward stable) prevalence in each health state */       /* Period (forward stable) prevalence in each health state */
Line 10199  BOOL IsWow64() Line 10202  BOOL IsWow64()
 #endif  #endif
   
 void syscompilerinfo(int logged)  void syscompilerinfo(int logged)
  {  {
    /* #include "syscompilerinfo.h"*/  #include <stdint.h>
   
     /* #include "syscompilerinfo.h"*/
    /* command line Intel compiler 32bit windows, XP compatible:*/     /* command line Intel compiler 32bit windows, XP compatible:*/
    /* /GS /W3 /Gy     /* /GS /W3 /Gy
       /Zc:wchar_t /Zi /O2 /Fd"Release\vc120.pdb" /D "WIN32" /D "NDEBUG" /D        /Zc:wchar_t /Zi /O2 /Fd"Release\vc120.pdb" /D "WIN32" /D "NDEBUG" /D
Line 10235  void syscompilerinfo(int logged) Line 10240  void syscompilerinfo(int logged)
       /ManifestFile:"Release\IMaCh.exe.intermediate.manifest" /OPT:ICF        /ManifestFile:"Release\IMaCh.exe.intermediate.manifest" /OPT:ICF
       /NOLOGO /TLBID:1        /NOLOGO /TLBID:1
    */     */
   
   
 #if defined __INTEL_COMPILER  #if defined __INTEL_COMPILER
 #if defined(__GNUC__)  #if defined(__GNUC__)
         struct utsname sysInfo;  /* For Intel on Linux and OS/X */          struct utsname sysInfo;  /* For Intel on Linux and OS/X */
Line 10251  void syscompilerinfo(int logged) Line 10258  void syscompilerinfo(int logged)
    }     }
 #endif  #endif
   
 #include <stdint.h>  
   
    printf("Compiled with:");if(logged)fprintf(ficlog,"Compiled with:");     printf("Compiled with:");if(logged)fprintf(ficlog,"Compiled with:");
 #if defined(__clang__)  #if defined(__clang__)
    printf(" Clang/LLVM");if(logged)fprintf(ficlog," Clang/LLVM");       /* Clang/LLVM. ---------------------------------------------- */     printf(" Clang/LLVM");if(logged)fprintf(ficlog," Clang/LLVM");       /* Clang/LLVM. ---------------------------------------------- */
Line 10782  int main(int argc, char *argv[]) Line 10787  int main(int argc, char *argv[])
   
   int *tab;     int *tab; 
   int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */    int mobilavproj=0 , prevfcast=0 ; /* moving average of prev, If prevfcast=1 prevalence projection */
   int backcast=0;    /* int backcast=0; */ /* defined as global for mlikeli and mle */
   int mobilav=0,popforecast=0;    int mobilav=0,popforecast=0;
   int hstepm=0, nhstepm=0;    int hstepm=0, nhstepm=0;
   int agemortsup;    int agemortsup;
Line 11207  int main(int argc, char *argv[]) Line 11212  int main(int argc, char *argv[])
       for(jj=1; jj <=nlstate+ndeath; jj++){        for(jj=1; jj <=nlstate+ndeath; jj++){
         if(jj==i) continue;          if(jj==i) continue;
         j++;          j++;
           while((c=getc(ficpar))=='#' && c!= EOF){
             ungetc(c,ficpar);
             fgets(line, MAXLINE, ficpar);
             numlinepar++;
             fputs(line,stdout);
             fputs(line,ficparo);
             fputs(line,ficlog);
           }
           ungetc(c,ficpar);
         fscanf(ficpar,"%1d%1d",&i1,&j1);          fscanf(ficpar,"%1d%1d",&i1,&j1);
         if ((i1 != i) || (j1 != jj)){          if ((i1 != i) || (j1 != jj)){
           printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \            printf("Error in line parameters number %d, %1d%1d instead of %1d%1d \n \
Line 12821  Please run with mle=-1 to get a correct Line 12835  Please run with mle=-1 to get a correct
       
   sprintf(plotcmd,"%s %s",pplotcmd, optionfilegnuplot);    sprintf(plotcmd,"%s %s",pplotcmd, optionfilegnuplot);
   printf("Starting graphs with: '%s'\n",plotcmd);fflush(stdout);    printf("Starting graphs with: '%s'\n",plotcmd);fflush(stdout);
     strcpy(pplotcmd,plotcmd);
       
   if((outcmd=system(plotcmd)) != 0){    if((outcmd=system(plotcmd)) != 0){
     printf("gnuplot command might not be in your path: '%s', err=%d\n", plotcmd, outcmd);      printf("Error in gnuplot, command might not be in your path: '%s', err=%d\n", plotcmd, outcmd);
     printf("\n Trying if gnuplot resides on the same directory that IMaCh\n");      printf("\n Trying if gnuplot resides on the same directory that IMaCh\n");
     sprintf(plotcmd,"%sgnuplot %s", pathimach, optionfilegnuplot);      sprintf(plotcmd,"%sgnuplot %s", pathimach, optionfilegnuplot);
     if((outcmd=system(plotcmd)) != 0)      if((outcmd=system(plotcmd)) != 0){
       printf("\n Still a problem with gnuplot command %s, err=%d\n", plotcmd, outcmd);        printf("\n Still a problem with gnuplot command %s, err=%d\n", plotcmd, outcmd);
         strcpy(plotcmd,pplotcmd);
       }
   }    }
   printf(" Successful, please wait...");    printf(" Successful, please wait...");
   while (z[0] != 'q') {    while (z[0] != 'q') {

Removed from v.1.291  
changed lines
  Added in v.1.292


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