regn[3]=4.0;
regn[4]=4.0;
regn[5]=1.0;
// Test #1: Compute volume of hemitorus
VEGAS vegas = new VEGAS() {
public double fxn(final double[] x, final double wgt){
return torusfunc1(x, wgt);
}
};
vegas.vegas(regn,0,1000,100,-1,tgral,sd,chi2a);
// System.out.printf(chi2a);
localflag = chi2a.val > 1.2;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** vegas: chi-square for test #1 is too high");
}
vegas.vegas(regn,1,100000,1,-1,tgral,sd,chi2a);
// System.out.printf(tgral << " %f\n", sd << " %f\n", chi2a);
// System.out.printf(SQR(PI)*R1*SQR(R2));
localflag = abs(tgral.val-SQR(PI)*R1*SQR(R2)) > 2.0*sd.val;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** vegas: Computation of hemitoroid volume is inaccurate");
}
// Test #2: Weight the integral by x
vegas = new VEGAS() {
public double fxn(final double[] x, final double wgt){
return torusfunc2(x, wgt);
}
};
vegas.vegas(regn,0,1000,100,-1,tgral,sd,chi2a);
// System.out.printf(chi2a);
localflag = chi2a.val > 1.2;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** vegas: chi-square for test #2 is too high");
}
vegas.vegas(regn,1,100000,1,-1,tgral,sd,chi2a);
// System.out.printf(tgral << " %f\n", sd << " %f\n", chi2a);
// System.out.printf(2.0*PI*SQR(R1)*SQR(R2)*(1+SQR(R2/R1)/4.0));
localflag = abs(tgral.val-2.0*PI*SQR(R1)*SQR(R2)*(1+SQR(R2/R1)/4.0)) > 2.0*sd.val;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** vegas: Computation of hemitoroid weighted by x is inaccurate");
}
// Test #3: Weight the integral by z^2
vegas = new VEGAS() {
public double fxn(final double[] x, final double wgt){
return torusfunc3(x, wgt);
}
};
vegas.vegas(regn,0,1000,100,-1,tgral,sd,chi2a);
// System.out.printf(chi2a);
localflag = chi2a.val > 1.2;
globalflag = globalflag || localflag;
if (localflag) {
fail("*** vegas: chi-square for test #3 is too high");
}
vegas.vegas(regn,1,100000,1,-1,tgral,sd,chi2a);
// System.out.printf(tgral << " %f\n", sd << " %f\n", chi2a);
// System.out.printf(SQR(PI)*R1*SQR(SQR(R2))/4.0);
localflag = abs(tgral.val-SQR(PI)*R1*SQR(SQR(R2))/4.0) > 2.0*sd.val;
globalflag = globalflag || localflag;