I want to get one of the NAG numerical integration functions (d01amc) to work in ROOT. I am following the first method and have managed to complete the first two steps however I am completely confused on the third step:
[quote]3. Compile and link
Modify your Makefile to include the files above and reference the libraries. Below is an example valid on HPUX with the CC compiler. Examples of linking a Root application are given for your platform in ${ROOTSYS}/test/Makefile.
The examples didn’t really help me either. Would anybody be able to explain to a beginner what should be done here? I am trying to run this on lxplus which is running root version 5.16. The NAG libraries are located:
/afs/cern.ch/sw/lhcxx/@sys/Nag_C/5.0
You would need to set the include PATH and the linking PATH to the nag location of the include and library files.
However, I have doubts it will work on lxplus, since this Nag version has been compiled for a very old Linux (I think RedHad 7). You probably nneed to get more recent binaries for Nag, I think you can download directly from their web site.
Have you tried to use the numerical integration in MathMore ?
It is based on GSL and as Nag implements the same alghorithms from QUADPACK.
It is documented in cern.ch/mathlibs/sw/MathMore … ation.html
Thanks for the suggestion Lornezo it looks like the Mathmore libraries should do everything I need.
Unfortunately I ran into a problem with the example code you linked me too. It seems that in the version of ROOT I have the functor.h file does not exist. What version of ROOT is required I am running 5.12 currently.
I have changed in the mean time the way the functions are passed to the integrator algorithm.
With 5.12 you need to pass a function of a type used by GSL (signature like struct gsl_function) or implementing the ROOT::Math::IGenFunction interface,
I seem to be having problems implementing my own function as an IGenFunction. I have not been able to find any examples in the code either. I was able to comment out the line #include “Math/WrappedFunction.h” and the (5.12) example code will still run without problems!
Thanks Lorenzo that example code is now working. Unfortunately I have now realised that although I only need to integrate over 1 dimension I would like to be able to set the values of some constants in my functions.
I assume the best way to do this is to create an object and then use the WrappedMemFunction command however I am unable to get this to work!
I am assuming I am simply using the incorrect syntax but I have so far been unable to figure out what I should put in. Is this the recommended way of doing this? In my actual problem I will have 6 or so constants that I would like to be able to change if required but then I will be integrating over just one dimension still.
The WrappedMemFunction is not available in 5.12 and is for member functions with different name than operator().
It is however recommended (in 5.14) to use the ROOT::Math::Functor class since the syntax for using WrappedMemFunction is ugly to to the complex way of defining types of member functions in C++.
I seem to be having some trouble getting this to run still.
If I try
ROOT::Math::WrappedFunction<formula> wf;
I get an error, however if do
ROOT::Math::WrappedFunction<formula> *wf;
It does compile however it says that wf is unused. If I try and use wf (by passing it to the integrator) it gives:
/home/atlas/ad/Fitter/convFitter/./testIntegration.cxx:46: warning: ‘wf’ might be used uninitialized in this function
and then a segmenation error.
If I try
formula test(2);
ROOT::Math::WrappedFunction<formula> *wf(test);
or any variation with /& it doesn’t compile giving this kind of error:
/home/atlas/ad/Fitter/convFitter/./testIntegration.cxx:46: error: cannot convert formula' toROOT::Math::WrappedFunction’ in initialization
So I am still unable to use my class with the integrator.
I think you had a problem in your formula class. Your class, in order to be used by the WrappedFunction class needs to be a callable object, i.e. to implement the operator()(double ).
You defined instead a method call Operator(double x).
You can see in the attached code an example on how to use the Integrator with your formula class. I have tested that the code works with 5.12 (remember to compile it using Aclic).
I showed you the possibility two use the WrappedFunction in two different ways: by wrapping the callable object by value or by reference.
As far as I am aware the word “operator” is a reserved word in C++ but not in C. Does this mean I will have to compile everything as C rather than C++? Is this not likely to cause problems?