=================================================================== RCS file: /home/cvs/OpenXM/src/hgm/mh/src/mh.c,v retrieving revision 1.5 retrieving revision 1.12 diff -u -p -r1.5 -r1.12 --- OpenXM/src/hgm/mh/src/mh.c 2013/02/25 12:11:23 1.5 +++ OpenXM/src/hgm/mh/src/mh.c 2013/03/08 04:54:01 1.12 @@ -1,10 +1,10 @@ -/* $OpenXM: OpenXM/src/hgm/mh/src/mh.c,v 1.4 2013/02/24 21:36:49 takayama Exp $ */ +/* $OpenXM: OpenXM/src/hgm/mh/src/mh.c,v 1.11 2013/03/07 07:02:18 takayama Exp $ */ #include #include "sfile.h" #include "mh.h" #define WSIZE 1024 extern int MH_DEBUG; -static imypower(int x,int n) { +static int imypower(int x,int n) { int a,i; a = 1; 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. */ @@ -107,7 +112,6 @@ struct cWishart *mh_cwishart_gen(int m,int n,double be cw->aux = (char *) mh_malloc(sfp->len+1); mh_outstr((char *)cw->aux,sfp->len+1,sfp); } - sfp = (rp->sfpp)[1]; if (sfp) { cw->aux2 = (char *) mh_malloc(sfp->len+1); @@ -121,31 +125,63 @@ struct cWishart *mh_cwishart_gen(int m,int n,double be /* Cumulative probability distribution function of the first eigenvalue of 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 approxDeg,double h, int dp, double x) { + 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 Wishart matrix by HGM */ struct cWishart *mh_cwishart_hgm(int m,int n,double beta[],double x0, - int approxDeg, double h, int dp , double x) + 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 -main() { +main(int argc,char *argv[]) { double beta[5]={1.0,2.0,3.0,4.0,5.0}; struct cWishart *cw; + struct SFILE *sfp; + char *s; + char str[1024]; + double x; + int i,show; + int strategy=0; + double err[2]={-1.0,-1.0}; + show=1; + for (i=1; ix,(cw->f)[0]); /* printf("%s",(char *)cw->aux); */ - } + } cw=mh_cwishart_hgm(4,5,beta,0.3,7, 0.01,1,10); if (cw != NULL) { printf("x=%lf, y=%lf\n",cw->x,(cw->f)[0]); + s = (char *)cw->aux; /* printf("%s",(char *)cw->aux); */ + if (show) { + sfp = mh_fopen(s,"r",0); + while (mh_fgets(str,1024,sfp)) { + sscanf(str,"%lg",&x); printf("%lg\n",x); + } + mh_fclose(sfp); + } } } main1() {