/* written to show that Cuba library runs through, properly */

/* include common header */
#include "integrateCubaCommon.c"

/* MATLAB caller */
void mexFunction( int nlhs,       mxArray *plhs[], 
                  int nrhs, const mxArray *prhs[] )
{
  /* there is no input and no output */
  /* the whole procedure is taken from the Cuba demo */

  int verbose, comp, nregions, neval, fail;
  double integral[1], error[1], prob[1];

  mexPrintf("-------------------- Vegas test --------------------\n");

  Vegas(3, 1, testIntegrand, NULL,
    1e-3, 1e-12, 3, 0,
    0, 50000, 10000, 500, 1000,
    0, NULL,
    &neval, &fail, integral, error, prob, noBatchmode);

  mexPrintf("VEGAS RESULT:\tneval %d\tfail %d\n",
            neval, fail);
  for( comp = 0; comp < 1; ++comp ) 
    mexPrintf("VEGAS RESULT:\t%.8f +- %.8f\tp = %.3f\n",
              integral[comp], error[comp], prob[comp]);

  return 0;
}
