Multi-dimensional adaptive integration

Hi,

Thanks for your reply. It works with CINT but it doesn’t work with ACLiC now. How can I fix it so that it works with both?

#ifndef __CINT__
#include "TMath.h"
#include "Math/Functor.h"
#include "Math/IntegratorMultiDim.h"
#include <iostream>
#endif

Double_t func(const Double_t *x){ 
    return x[0]*x[0]*TMath::Sin(x[1]);
}

void multiDimIntegration()
{
    Double_t R = 2.0;  // sphere radius
    // numeric integration
    ROOT::Math::Functor f1(func,3); 
    ROOT::Math::IntegratorMultiDim ig(f1);
    Double_t xmin[3] = {0.0, 0.0, 0.0};
    Double_t xmax[3] = {R, TMath::Pi(), 2*TMath::Pi()};
    Double_t volume1 = ig.Integral(xmin, xmax);
    // analytic formula
    Double_t volume2 = 4.0/3*TMath::Pi()*R*R*R;
    
    std::cout << scientific;
    std::cout << "volume1 = " << volume1 << std::endl;
    std::cout << "volume2 = " << volume2 << std::endl;
}
root [] .x multiDimIntegration.C++
Info in <TUnixSystem::ACLiC>: creating shared library /home/malusek/work/root/./multiDimIntegration_C.so
/lw/root/5.22.00/include/Math/Functor.h: In instantiation of ‘ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t ()(const Double_t*)>’:
/lw/root/5.22.00/include/Math/Functor.h:370:   instantiated from ‘ROOT::Math::Functor::Functor(const Func&, unsigned int) [with Func = Double_t ()(const Double_t*)]’
/home/malusek/work/root/./multiDimIntegration.C:16:   instantiated from here
/lw/root/5.22.00/include/Math/Functor.h:99: error: field ‘ROOT::Math::FunctorHandler<ROOT::Math::Functor, Double_t ()(const Double_t*)>::fFunc’ invalidly declared function type
g++: /home/malusek/work/root/./multiDimIntegration_C_ACLiC_dict.o: není souborem ani adresářem
Error in <ACLiC>: Compilation failed!
Error: Function multiDimIntegration() is not defined in current scope  :0:
*** Interpreter error recovered ***
1 Like