Problem using Minimizer

I am trying to use the Minimizer framework. I have uploaded a very simple class that uses a member function as the function that I wish to minimize. This is passed in using a functor, following the mult-dimensional example here: … nimization

I get an error that I don’t quite understand when I try to compile. I’ve pasted the error below.

I know that if I make the function to be minimised static, then it will compile. However, I don’t want the function to be static as it needs to modify a non-static member variable. I don’t want this variable to be static as I will have multiple instances of the class that need to have independent variables.

/Users/peter/code/root_install//include/root/Math/Functor.h: In member function ‘double ROOT::Math::FunctorHandler<ParentFunctor, Func>::DoEval(const double*) const [with ParentFunctor = ROOT::Math::Functor, Func = double (myClass::)(const double)]’:
testMin.cpp:12: instantiated from here
/Users/peter/code/root_install//include/root/Math/Functor.h:86: error: must use ‘.’ or ‘->’ to call pointer-to-member function in ‘((const ROOT::Math::FunctorHandler<ROOT::Math::Functor, double (myClass::)(const double)>)this)->ROOT::Math::FunctorHandler<ROOT::Math::Functor, double (myClass::)(const double*)>::fFunc (…)’

I am using root version 5.25/02 and gcc 4.2.1 on OS X 10.6.1

I attempt to compile the code using the following command:
g++ -o testMin.o -c root-config --cflags testMin.cpp

thanks in advance for any help
testMin.h (165 Bytes)
testMin.cpp (271 Bytes)


when using a class member function you must pass in addition to the member function pointer a pointer to the class itself.
The other constructor is for free function or C++ callable object (classes implementing the operator() ).
See … nctor.html

So, in your case you have to do:

  myClass cl;
  ROOT::Math::Functor f(&cl,&myClass::functionToBeMinimised, 1);

Best Regards


Hi Lorenzo

perfect - thanks!