version 1.10, 2013/03/07 03:00:43 |
version 1.16, 2014/03/11 05:20:45 |
|
|
/* |
/* |
$OpenXM: OpenXM/src/hgm/mh/src/wmain.c,v 1.9 2013/03/05 05:26:07 takayama Exp $ |
$OpenXM: OpenXM/src/hgm/mh/src/wmain.c,v 1.15 2014/03/10 04:38:23 takayama Exp $ |
License: LGPL |
License: LGPL |
*/ |
*/ |
#include <stdio.h> |
#include <stdio.h> |
|
|
#include <math.h> |
#include <math.h> |
#include <string.h> |
#include <string.h> |
#include "sfile.h" |
#include "sfile.h" |
|
#include "mh.h" |
#define SMAX 4096 |
#define SMAX 4096 |
#define inci(i) { i++; if (i >= argc) { fprintf(stderr,"Option argument is not given.\n"); return(NULL); }} |
#define inci(i) { i++; if (i >= argc) { fprintf(stderr,"Option argument is not given.\n"); return(NULL); }} |
int MH_deallocate=0; |
int MH_deallocate=0; |
Line 32 int MH_RawName = 0; |
|
Line 33 int MH_RawName = 0; |
|
static int Testrank=0; |
static int Testrank=0; |
extern int MH_Verbose; |
extern int MH_Verbose; |
|
|
|
|
extern int MH_P95; /* 95 % points */ |
extern int MH_P95; /* 95 % points */ |
int mh_gopen_file(void); |
int mh_gopen_file(void); |
static int setParamTest(void); |
static int setParamTest(void); |
Line 64 static int mypower(int x,int n) { |
|
Line 66 static int mypower(int x,int n) { |
|
} |
} |
#ifdef STANDALONE2 |
#ifdef STANDALONE2 |
main(int argc,char *argv[]) { |
main(int argc,char *argv[]) { |
|
int strategy=STRATEGY_DEFAULT; |
|
double err[2]={-1.0,-1.0}; |
|
int i; |
|
for (i=1; i<argc; i++) { |
|
if (strcmp(argv[i],"--strategy")==0) { |
|
i++; sscanf(argv[i],"%d",&strategy); |
|
}else if (strcmp(argv[i],"--abserr")==0) { |
|
i++; sscanf(argv[i],"%lg",&(err[0])); |
|
}else if (strcmp(argv[i],"--relerr")==0) { |
|
i++; sscanf(argv[i],"%lg",&(err[1])); |
|
}else ; |
|
} |
|
mh_set_strategy(strategy,err); |
mh_exit(MH_RESET_EXIT); /* standalone mode */ |
mh_exit(MH_RESET_EXIT); /* standalone mode */ |
/* mh_main(argc,argv); |
/* mh_main(argc,argv); |
mh_freeWorkArea(); */ |
mh_freeWorkArea(); */ |
mh_main(argc,argv); |
mh_main(argc,argv); |
|
/* showParam(); */ |
} |
} |
#endif |
#endif |
struct MH_RESULT *mh_main(int argc,char *argv[]) { |
struct MH_RESULT *mh_main(int argc,char *argv[]) { |
static double *y0; |
static double *y0=NULL; |
double x0,xn; |
double x0,xn; |
double ef; |
double ef; |
int i,rank; |
int i,rank; |
Line 113 struct MH_RESULT *mh_main(int argc,char *argv[]) { |
|
Line 129 struct MH_RESULT *mh_main(int argc,char *argv[]) { |
|
MH_Verbose=1; |
MH_Verbose=1; |
}else if (strcmp(argv[i],"--bystring")==0) { |
}else if (strcmp(argv[i],"--bystring")==0) { |
MH_byFile = 0; |
MH_byFile = 0; |
|
}else if (strcmp(argv[i],"--strategy")==0) { |
|
i++; /* ignore */ |
|
}else if (strcmp(argv[i],"--abserr")==0) { |
|
i++; /* ignore */ |
|
}else if (strcmp(argv[i],"--relerr")==0) { |
|
i++; /* ignore */ |
}else { |
}else { |
fprintf(stderr,"Unknown option %s\n",argv[i]); |
fprintf(stderr,"Unknown option %s\n",argv[i]); |
mh_usage(); |
mh_usage(); |
Line 129 struct MH_RESULT *mh_main(int argc,char *argv[]) { |
|
Line 151 struct MH_RESULT *mh_main(int argc,char *argv[]) { |
|
mh_gopen_file(); |
mh_gopen_file(); |
if (MH_Verbose) {for (i=0; i<rank; i++) printf("%lf\n",y0[i]); } |
if (MH_Verbose) {for (i=0; i<rank; i++) printf("%lf\n",y0[i]); } |
rp = (struct MH_RESULT*) mh_malloc(sizeof(struct MH_RESULT)); |
rp = (struct MH_RESULT*) mh_malloc(sizeof(struct MH_RESULT)); |
|
rp->message = NULL; |
*rp=mh_rkmain(x0,y0,xn); |
*rp=mh_rkmain(x0,y0,xn); |
return(rp); |
return(rp); |
} |
} |
|
|
int mh_usage() { |
int mh_usage() { |
fprintf(stderr,"Usages:\n"); |
fprintf(stderr,"Usages:\n"); |
fprintf(stderr,"w-m [--idata input_data_file --gnuplotf gnuplot_file_name\n"); |
fprintf(stderr,"hgm_w-n [--idata input_data_file --gnuplotf gnuplot_file_name\n"); |
fprintf(stderr," --dataf output_data_file --raw --xmax xmax --test m --step h]\n"); |
fprintf(stderr," --dataf output_data_file --raw --xmax xmax --test m --step h]\n"); |
fprintf(stderr,"[ --95 --verbose] \n"); |
fprintf(stderr,"[ --95 --verbose] \n"); |
fprintf(stderr,"--raw does not add data parameters to the output_data_file.\n"); |
fprintf(stderr,"--raw does not add data parameters to the output_data_file.\n"); |
fprintf(stderr,"\nThe command w-m [options] evaluates Pr({y | y<xmax}), which is the cumulative distribution function of the largest root of the m by m Wishart matrix with n degrees of freedom and the covariantce matrix sigma.\n"); |
fprintf(stderr,"\nThe command hgm_w-n [options] evaluates Pr({y | y<xmax}), which is the cumulative distribution function of the largest root of the m by m Wishart matrix with n degrees of freedom and the covariantce matrix sigma.\n"); |
fprintf(stderr,"All the eigenvalues of sigma must be simple.\n"); |
fprintf(stderr,"All the eigenvalues of sigma must be simple.\n"); |
fprintf(stderr,"Parameters are specified by the input_data_file.\n"); |
fprintf(stderr,"Parameters are specified by the input_data_file.\n"); |
fprintf(stderr,"The format of the input_data_file.\n"); |
fprintf(stderr,"The format of the input_data_file, which should be generated by the command hgm_jack-n.\n"); |
fprintf(stderr," MH_Mg: m, MH_Beta: beta=sigma^(-1)/2 (diagonized), MH_Ng: n, Iv: initial values at MH_X0g*MH_Beta (see our paper how to order them), \n"); |
fprintf(stderr," MH_Mg: m, MH_Beta: beta=sigma^(-1)/2 (diagonized), MH_Ng: n, MH_X0g: starting value of x,\n"); |
|
fprintf(stderr," Iv: initial values at MH_X0g*MH_Beta (see our paper how to order them), \n"); |
fprintf(stderr," Ef: a scalar factor to the initial value. It may set to 1.\n"); |
fprintf(stderr," Ef: a scalar factor to the initial value. It may set to 1.\n"); |
fprintf(stderr," MH_Hg: h (step size), MH_X0g: starting value of x, Xng: terminating value of x\n"); |
fprintf(stderr," MH_Hg: h (step size),\n"); |
fprintf(stderr," MH_Dp: output data is stored in every MH_Dp steps when output_data_file is specified.\n"); |
fprintf(stderr," MH_Dp: output data is stored in every MH_Dp steps when output_data_file is specified.\n"); |
|
fprintf(stderr," Xng: terminating value of x.\n"); |
fprintf(stderr," --95: output the 95%% point. --verbose: verbose mode.\n"); |
fprintf(stderr," --95: output the 95%% point. --verbose: verbose mode.\n"); |
fprintf(stderr," The line started with %% is a comment line.\n"); |
fprintf(stderr," The line started with %% is a comment line.\n"); |
fprintf(stderr," An example format of the input_data_file can be obtained by executing w-2 with no option.\n"); |
fprintf(stderr," An example format of the input_data_file can be obtained by executing hgm_jack-n with no option.\n"); |
|
fprintf(stderr,"When --idata option is used, this command is quiet. Use --verbose option if you want to see some messages.\n"); |
fprintf(stderr,"\nExamples:\n"); |
fprintf(stderr,"\nExamples:\n"); |
fprintf(stderr,"[1] ./w-2 \n"); |
fprintf(stderr,"[1] ./hgm_w-n \n"); |
fprintf(stderr,"[2] ./w-2 --xmax 20\n"); |
fprintf(stderr,"[2] ./hgm_w-n --xmax 20\n"); |
fprintf(stderr,"[3] ./w-6 --test 6\n"); |
fprintf(stderr,"[3] ./hgm_w-n --test 6\n"); |
fprintf(stderr," A test run of w-6.\n"); |
fprintf(stderr," A test run in Mg=6.\n"); |
fprintf(stderr," The number m and mm must agree for ./w-m --test mm.\n"); |
fprintf(stderr,"[4] ./hgm_jack-n --idata Testdata/tmp-idata3.txt --degree 15 >t.txt\n"); |
fprintf(stderr,"[4] ./w-5 --idata tmp-inm-m5* --gnuplot tmp-graph\n"); |
fprintf(stderr," ./hgm_w-n --idata t.txt --gnuplotf test-g\n"); |
fprintf(stderr," tmp-inm-m5* is a sample input data distributed with this file.\n"); |
fprintf(stderr," gnuplot -persist <test-g-gp.txt\n"); |
fprintf(stderr," tmp-graph-gp.txt is an input file of the gnuplot\n"); |
fprintf(stderr," tmp-idata3.txt is a sample input data distributed with this file.\n"); |
fprintf(stderr," It can be executed with the load command in the gnuplot.\n"); |
fprintf(stderr," test-g-gp.txt is an input file of the gnuplot\n"); |
fprintf(stderr," tmp-graph is the table of x and the values of Pr({y | y<x}).\n"); |
fprintf(stderr," test-g is the table of x and the values of Pr({y | y<x}).\n"); |
} |
} |
|
|
static int setParamTest() { |
static int setParamTest() { |
Line 270 static int setParam(char *fname) { |
|
Line 296 static int setParam(char *fname) { |
|
|
|
int showParam() { |
int showParam() { |
int rank,i; |
int rank,i; |
|
extern int MH_strategy; |
|
extern double MH_abserr; |
|
extern double MH_relerr; |
rank = mypower(2,MH_Mg); |
rank = mypower(2,MH_Mg); |
printf("%%MH_Mg=\n%d\n",MH_Mg); |
printf("%%MH_Mg=\n%d\n",MH_Mg); |
for (i=0; i<MH_Mg; i++) { |
for (i=0; i<MH_Mg; i++) { |
Line 284 int showParam() { |
|
Line 313 int showParam() { |
|
printf("%%MH_Hg=\n%lf\n",MH_Hg); |
printf("%%MH_Hg=\n%lf\n",MH_Hg); |
printf("%%MH_Dp=\n%d\n",MH_Dp); |
printf("%%MH_Dp=\n%d\n",MH_Dp); |
printf("%%Xng=\n%lf\n",Xng); |
printf("%%Xng=\n%lf\n",Xng); |
|
printf("%%strategy=%d\n",MH_strategy); |
|
printf("%%abserr=%lg, relerr=%lg\n",MH_abserr,MH_relerr); |
} |
} |
|
|