For a physics related calculation, I need to evaluate numerically a four dimensional integral that depends on several parameters that need to be varied; such that they can't be globally defined. I am using the Cuba package which provides the following function:
Cuhre(NDIM, NCOMP, Integrand , USERDATA, NVEC,EPSREL, EPSABS, VERBOSE | LAST,MINEVAL,
MAXEVAL, KEY,STATEFILE, SPIN,&nregions, &neval, &fail, integral, error, prob);
The argument "Integrand" is a function that is expected to be defined in the following fashion:
int Integrand(const int *ndim, const cubareal xx[],const int *ncomp,
cubareal ff[], void *userdata) ;
My problem is that I would like to integrate a function that depends on continuous parameters that I would like to vary within the program. What I mean by this is that my integrand function depends on several extra parameters, say a,b,c.
I would then like to define something like the Integrand function locally, i.e. in a scope where the parameters a, b and c are fixed, so that it will have the correct form to be passed as an argument to the Cuhre function.
I then thought that I could perhaps put everything into a class such as:
class integrate{
private: // parameters
public:
//constructor
int Integrand(...){
// calculation involving the parameters
}
};
and define the function as a method for that class. This however didn't work because I can't pass non-static object methods to a function, and, making the method static would also force me to make the parameters static which means I would not be able to initialise them within the program.
Is there any workaround to this?