[BACK]Return to mh-r.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / hgm / mh / src

File: [local] / OpenXM / src / hgm / mh / src / mh-r.c (download)

Revision 1.7, Fri Mar 8 04:54:01 2013 UTC (11 years, 3 months ago) by takayama
Branch: MAIN
Changes since 1.6: +7 -1 lines

New options: --strategy n --abserr e1 --relerr e2
 If n==0, then the 4th Runge-Kutta is used.
If n==1, then the adaptive 4th Runge-Kutta is used where e1 is the absolute error and e2 is the relative error
to control the step size.

/* $OpenXM: OpenXM/src/hgm/mh/src/mh-r.c,v 1.7 2013/03/08 04:54:01 takayama Exp $
 R interface module
*/

#include <stdio.h>
#include "sfile.h"
#include "mh.h"
#define WSIZE 1024

int Rmh_cwishart_gen(int *mp,int *np,double *beta,double *x0p,
		int *approxDegp,double *hp, int *dpp, double *xp,
		 int *modep,int *rankp,double *xy) {
  struct cWishart *cw;
  int rank;
  int i;
  rank = *rankp;
  cw = mh_cwishart_gen(*mp,*np,beta,*x0p,*approxDegp,*hp,*dpp,*xp,modep);
  xy[0] = cw->x;
  for (i=1; i<=rank; i++) xy[i] = (cw->f)[i-1];

  if ((modep[2] > 0) && cw->aux) {
    struct SFILE *sfp3;
    char *s3;
    char str[1024];
    double x;
    s3 = (char *)cw->aux;
    sfp3 = mh_fopen(s3,"r",0);
    for (i=cw->rank+1; i<modep[2]+(cw->rank)+1; i++) xy[i] = 0.0;
    for (i=cw->rank+1; i<modep[2]+(cw->rank)+1; i++) {
      if (!mh_fgets(str,1024,sfp3)) break;
      sscanf(str,"%lg",&x); 
      xy[i] = x;
    }
  }
  return(0);
}

int Rmh_set_strategy(int *m,double *err,double *ans) {
  mh_set_strategy(*m,err);
  ans[0] = 0.0;
  return(0);
}