--- imach/src/imach.c 2004/09/15 10:38:38 1.101 +++ imach/src/imach.c 2005/09/30 15:54:49 1.103 @@ -1,6 +1,12 @@ -/* $Id: imach.c,v 1.101 2004/09/15 10:38:38 brouard Exp $ +/* $Id: imach.c,v 1.103 2005/09/30 15:54:49 lievre Exp $ $State: Exp $ $Log: imach.c,v $ + Revision 1.103 2005/09/30 15:54:49 lievre + (Module): sump fixed, loop imx fixed, and simplifications. + + Revision 1.102 2004/09/15 17:31:30 brouard + Add the possibility to read data file including tab characters. + Revision 1.101 2004/09/15 10:38:38 brouard Fix on curr_time @@ -241,11 +247,11 @@ #define ODIRSEPARATOR '/' #endif -/* $Id: imach.c,v 1.101 2004/09/15 10:38:38 brouard Exp $ */ +/* $Id: imach.c,v 1.103 2005/09/30 15:54:49 lievre Exp $ */ /* $State: Exp $ */ -char version[]="Imach version 0.97b, May 2004, INED-EUROREVES "; -char fullversion[]="$Revision: 1.101 $ $Date: 2004/09/15 10:38:38 $"; +char version[]="Imach version 0.97c, September 2004, INED-EUROREVES "; +char fullversion[]="$Revision: 1.103 $ $Date: 2005/09/30 15:54:49 $"; int erreur, nberr=0, nbwarn=0; /* Error number, number of errors number of warnings */ int nvar; int cptcovn=0, cptcovage=0, cptcoveff=0,cptcov; @@ -439,8 +445,8 @@ int nbocc(char *s, char occ) void cutv(char *u,char *v, char*t, char occ) { - /* cuts string t into u and v where u is ended by char occ excluding it - and v is after occ excluding it too : ex cutv(u,v,"abcdef2ghi2j",2) + /* cuts string t into u and v where u ends before first occurence of char 'occ' + and v starts after first occurence of char 'occ' : ex cutv(u,v,"abcdef2ghi2j",'2') gives u="abcedf" and v="ghi2j" */ int i,lg,j,p=0; i=0; @@ -3918,24 +3924,22 @@ double gompertz(double x[]) int i,n=0; /* n is the size of the sample */ for (i=0;i<=imx-1 ; i++) { sump=sump+weight[i]; - sump=sump+1; + /* sump=sump+1;*/ num=num+1; } - /* for (i=1; i<=imx; i++) + /* for (i=0; i<=imx; i++) if (wav[i]>0) printf("i=%d ageex=%lf agecens=%lf agedc=%lf cens=%d %d\n" ,i,ageexmed[i],agecens[i],agedc[i],cens[i],wav[i]);*/ - for (i=0;i<=imx-1 ; i++) + for (i=1;i<=imx ; i++) { if (cens[i]==1 & wav[i]>1) - A=-x[1]/(x[2])* - (exp(x[2]/YEARM*(agecens[i]*12-agegomp*12))-exp(x[2]/YEARM*(ageexmed[i]*12-agegomp*12))); + A=-x[1]/(x[2])*(exp(x[2]*(agecens[i]-agegomp))-exp(x[2]*(ageexmed[i]-agegomp))); if (cens[i]==0 & wav[i]>1) - A=-x[1]/(x[2])* - (exp(x[2]/YEARM*(agedc[i]*12-agegomp*12))-exp(x[2]/YEARM*(ageexmed[i]*12-agegomp*12))) - +log(x[1]/YEARM)+x[2]/YEARM*(agedc[i]*12-agegomp*12)+log(YEARM); + A=-x[1]/(x[2])*(exp(x[2]*(agedc[i]-agegomp))-exp(x[2]*(ageexmed[i]-agegomp))) + +log(x[1]/YEARM)+x[2]*(agedc[i]-agegomp)+log(YEARM); if (wav[i]>1 & agecens[i]>15) { L=L+A*weight[i]; @@ -4399,7 +4403,10 @@ int main(int argc, char *argv[]) i=1; while (fgets(line, MAXLINE, fic) != NULL) { if ((i >= firstobs) && (i <=lastobs)) { - + for(j=0; line[j] != '\n';j++){ /* Untabifies line */ + if(line[j] == '\t') + line[j] = ' '; + } for (j=maxwav;j>=1;j--){ cutv(stra, strb,line,' '); s[j][i]=atoi(strb); strcpy(line,stra);