=================================================================== RCS file: /home/cvs/OpenXM/src/hgm/mh/src/mh.c,v retrieving revision 1.4 retrieving revision 1.6 diff -u -p -r1.4 -r1.6 --- OpenXM/src/hgm/mh/src/mh.c 2013/02/24 21:36:49 1.4 +++ OpenXM/src/hgm/mh/src/mh.c 2013/03/05 06:00:52 1.6 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/hgm/mh/src/mh.c,v 1.3 2013/02/23 07:00:21 takayama Exp $ */ +/* $OpenXM: OpenXM/src/hgm/mh/src/mh.c,v 1.5 2013/02/25 12:11:23 takayama Exp $ */ #include #include "sfile.h" #include "mh.h" @@ -22,7 +22,12 @@ struct cWishart *new_cWishart(int rank) { } struct cWishart *mh_cwishart_gen(int m,int n,double beta[],double x0, - int approxDeg,double h, int dp, double x,int mode) { + int approxDeg,double h, int dp, double x,int modep[]) { + /* + modep[0]. Do Koev-Edelman (ignored for now). + modep[1]. Do the HGM + modep[2]. Return modep[2] intermediate data. + */ struct SFILE *fp; char swork[WSIZE]; char *argv[WSIZE]; @@ -75,16 +80,21 @@ struct cWishart *mh_cwishart_gen(int m,int n,double be cw = new_cWishart(rank); cw->x = rp->x; cw->rank = rp->rank; - /* todo, the following line seems to cause seg fault. */ + if (rank != cw->rank) { + fprintf(stderr,"Rank error.\n"); return(NULL); + } for (i=0; irank; i++) (cw->f)[i] = (rp->y)[i]; sfp = (rp->sfpp)[0]; - cw->aux = (char *) mh_malloc(sfp->len+1); - mh_outstr((char *)cw->aux,sfp->len+1,sfp); + cw->aux = (char *) mh_malloc((sfp->len)+1); + mh_outstr((char *)(cw->aux),(sfp->len)+1,sfp); + /* todo, the following line seems to cause seg fault. */ /* deallocate the memory */ for (i=0; isize; i++) mh_fclose((rp->sfpp)[i]); /* todo, mh_free_??(rp); free Iv's */ - if (mode == 0) return(cw); + if (!modep[1]) return(cw); + if (MH_DEBUG) printf("\n\n%s\n",(char *)cw->aux); + /* This output is strange. */ /* Starting HGM */ argv[3] = (char *)cw->aux; argv[4] = "--dataf"; @@ -117,7 +127,8 @@ struct cWishart *mh_cwishart_gen(int m,int n,double be Wishart matrix by Series */ struct cWishart *mh_cwishart_s(int m,int n,double beta[],double x0, int approxDeg,double h, int dp, double x) { - return(mh_cwishart_gen(m,n,beta,x0,approxDeg,h,dp,x,0)); + int modep[]={1,0,0}; + return(mh_cwishart_gen(m,n,beta,x0,approxDeg,h,dp,x,modep)); } /* Cumulative probability distribution function of the first eigenvalue of @@ -125,7 +136,8 @@ struct cWishart *mh_cwishart_s(int m,int n,double beta struct cWishart *mh_cwishart_hgm(int m,int n,double beta[],double x0, int approxDeg, double h, int dp , double x) { - return(mh_cwishart_gen(m,n,beta,x0,approxDeg,h,dp,x,1)); + int modep[]={1,1,0}; + return(mh_cwishart_gen(m,n,beta,x0,approxDeg,h,dp,x,modep)); } #ifdef STANDALONE