=================================================================== RCS file: /home/cvs/OpenXM/src/hgm/mh/src/code-n.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- OpenXM/src/hgm/mh/src/code-n.c 2013/02/19 03:06:19 1.1 +++ OpenXM/src/hgm/mh/src/code-n.c 2013/02/19 08:03:14 1.2 @@ -1,15 +1,21 @@ /* +$OpenXM$ License: LGPL +Ref: Copied from this11/misc-2011/A1/wishart/Prog cf. @s/2011/12/01-my-note-code-n.pdf */ #include #include #include +static void error_code(char *s); +static void showf(char *s,double *v,int m); +static void showd(char *s,int *v,int m); + extern int MH_M; extern int MH_RANK; -int bitcount(int n) {int c; c=0; while (n) { ++c; n &= (n-1); } return(c);} +static int bitcount(int n) {int c; c=0; while (n) { ++c; n &= (n-1); } return(c);} #define join(k,jj) ( (1 << k) | jj) #define delete(k,jj) ( (~(1 << k)) & jj) #define member(k,ii) ( (1 << k) & ii) @@ -22,9 +28,9 @@ int bitcount(int n) {int c; c=0; while (n) { ++c; n &= p(x) = exp(-bsum*x)*x^(MH_M*(c-a)) f is p(x)*pd{J}F */ -void rf(double x, double *f, int rank_not_used, double *val, int n_not_used) +void mh_rf(double x, double *f, int rank_not_used, double *val, int n_not_used) { extern double *MH_Beta; /* beta = (1/2)*\simga^(-1) */ - extern double *Ng; /* freedom */ + extern double *MH_Ng; /* freedom */ extern int MH_Mg; /* number of variables, MH_Mg=MH_M */ static int initialized = 0; /* static double b[MH_M]; */ @@ -54,14 +60,14 @@ void rf(double x, double *f, int rank_not_used, double static double *f2=NULL; if (!initialized) { - b = (double *)mymalloc(sizeof(double)*MH_M); - bitSize = (int *)mymalloc(sizeof(int)*MH_RANK); - invbitSize = (int *)mymalloc(sizeof(int)*MH_RANK); + b = (double *)mh_malloc(sizeof(double)*MH_M); + bitSize = (int *)mh_malloc(sizeof(int)*MH_RANK); + invbitSize = (int *)mh_malloc(sizeof(int)*MH_RANK); - f2 = (double *)mymalloc(sizeof(double)*MH_M*MH_RANK); - yik = (double *)mymalloc(sizeof(double)*MH_M*MH_M); - yik2 = (double *)mymalloc(sizeof(double)*MH_M*MH_M); - y = (double *)mymalloc(sizeof(double)*MH_M); + f2 = (double *)mh_malloc(sizeof(double)*MH_M*MH_RANK); + yik = (double *)mh_malloc(sizeof(double)*MH_M*MH_M); + yik2 = (double *)mh_malloc(sizeof(double)*MH_M*MH_M); + y = (double *)mh_malloc(sizeof(double)*MH_M); m = MH_Mg; if (m != MH_M) error_code("MH_M != m. MH_M is given by -DMH_M..."); @@ -69,8 +75,8 @@ void rf(double x, double *f, int rank_not_used, double if(MH_Beta != NULL) for (i=0;i