14 #ifndef ROOT_Math_IntegratorMultiDim
15 #define ROOT_Math_IntegratorMultiDim
50 class IntegratorMultiDim {
54 typedef IntegrationMultiDim::Type Type;
67 IntegratorMultiDim(IntegrationMultiDim::Type type = IntegrationMultiDim::kDEFAULT,
double absTol = -1,
double relTol = -1,
unsigned int ncall = 0) :
70 fIntegrator = CreateIntegrator(type, absTol, relTol, ncall);
82 IntegratorMultiDim(
const IMultiGenFunction &f, IntegrationMultiDim::Type type = IntegrationMultiDim::kDEFAULT,
double absTol = -1,
double relTol = -1,
unsigned int ncall = 0) :
85 fIntegrator = CreateIntegrator(type, absTol, relTol, ncall);
108 virtual ~IntegratorMultiDim() {
109 if (fIntegrator)
delete fIntegrator;
116 IntegratorMultiDim(
const IntegratorMultiDim &) : fIntegrator(0), fFunc(nullptr) {}
117 IntegratorMultiDim & operator=(
const IntegratorMultiDim &) {
return *
this; }
125 double Integral(
const double* xmin,
const double * xmax) {
126 return fIntegrator == 0 ? 0 : fIntegrator->Integral(xmin,xmax);
130 double Integral(
const IMultiGenFunction &f,
const double* xmin,
const double * xmax) {
132 return Integral(xmin,xmax);
136 template<
class Function>
137 double Integral(Function & f ,
unsigned int dim,
const double* xmin,
const double * xmax) {
138 SetFunction<Function>(f,dim);
139 return Integral(xmin, xmax);
147 template <
class Function>
148 void SetFunction(Function & f,
unsigned int dim) {
149 fFunc.reset(
new WrappedMultiFunction<Function &> (f, dim) );
150 fIntegrator->SetFunction(*fFunc);
154 void SetFunction(
const IMultiGenFunction &f) {
155 if (fIntegrator) fIntegrator->SetFunction(f);
159 double Result()
const {
return fIntegrator == 0 ? 0 : fIntegrator->Result(); }
162 double Error()
const {
return fIntegrator == 0 ? 0 : fIntegrator->Error(); }
165 int Status()
const {
return fIntegrator == 0 ? -1 : fIntegrator->Status(); }
171 void SetRelTolerance(
double relTol) {
if (fIntegrator) fIntegrator->SetRelTolerance(relTol); }
174 void SetAbsTolerance(
double absTol) {
if (fIntegrator) fIntegrator->SetAbsTolerance(absTol); }
177 void SetOptions(
const ROOT::Math::IntegratorMultiDimOptions & opt) {
if (fIntegrator) fIntegrator->SetOptions(opt); }
180 ROOT::Math::IntegratorMultiDimOptions Options()
const {
return (fIntegrator) ? fIntegrator->Options() : IntegratorMultiDimOptions(); }
183 VirtualIntegratorMultiDim * GetIntegrator() {
return fIntegrator; }
186 std::string Name()
const {
return (fIntegrator) ? Options().Integrator() : std::string(
""); }
189 static IntegrationMultiDim::Type GetType(
const char * name);
192 static std::string GetName(IntegrationMultiDim::Type);
196 VirtualIntegratorMultiDim * CreateIntegrator(IntegrationMultiDim::Type type ,
double absTol,
double relTol,
unsigned int ncall);
200 VirtualIntegratorMultiDim * fIntegrator;
201 std::unique_ptr<IMultiGenFunction> fFunc;