This program must be compiled and executed with Aclic as follows.
it is an extension of tutorials foam_kanwa.C to compare generation of a 2D distribution with unuran and Foam
#include <iostream>
}
public:
virtual ~FoamFunction() {}
double Density(
int nDim,
double * x) {
return Camel2(nDim,x);
}
};
cout<<"--- kanwa started ---"<<endl;
TH2D *hst_xy =
new TH2D(
"foam_hst_xy" ,
"FOAM x-y plot", 50,0,1.0, 50,0,1.0);
hFoam = hst_xy;
FoamX->
SetRho(
new FoamFunction() );
int nshow=nev;
for(long loop=0; loop<nev; loop++){
if(loop == nshow){
nshow += 5000;
}
}
double time = w.
CpuTime()*1.E9/nev;
cout << "Time using FOAM \t\t " << " \t=\t " << time << "\tns/call" << endl;
cout << " MCresult= " << MCresult << " +- " << MCerror <<endl;
cout<<"--- kanwa ended ---"<<endl;
return 0;
}
double UCamel2(double * x, double *) {
return Camel2(2,x);
}
int run_unuran(int nev, std::string method = "hitro") {
std::cout << "run unuran " << std::endl;
TH2D *h1 =
new TH2D(
"unr_hst_xy" ,
"UNURAN x-y plot", 50,0,1.0, 50,0,1.0);
TF2 * f =
new TF2(
"f",UCamel2,0,1,0,1,0);
if (!ret) {
std::cerr <<
"Error initializing unuran with method " << unr.
MethodName() << endl;
return -1;
}
double x[2];
for (int i = 0; i < nev; ++i) {
}
double time = w.
CpuTime()*1.E9/nev;
cout <<
"Time using Unuran " << unr.
MethodName() <<
" \t=\t " << time <<
"\tns/call" << endl;
return 0;
}
TCanvas *cKanwa =
new TCanvas(
"cKanwa",
"Canvas for plotting",600,1000);
int n = 100000;
run_unuran(n,"hitro");
run_foam(n);
std::cout <<"\nChi2 Test Results (UNURAN-FOAM):\t";
return 0;
}
- Author
- Lorenzo Moneta
Definition in file unuranFoamTest.C.