Hi,
The NumericalMinimization.C code in the fit tutorial section is a nice example. What I would like to do is use the tools from this example in a larger project. So, as a first test I added a main function to create the attached “NumericalMinimization.cpp”. This compiled fine for me with g++. Now, what I really want to do is implement this in a class. So, I further modified the example, resulting in the attached “NM2.cpp”. The problem is that this fails when compiling, giving the error message:
g++ -o NM2 -O3 -Wall -pthread -m64 -I/usr/local/root/include NM2.cpp -L/usr/local/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic -L/usr/local/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lGui -pthread -lm -ldl -rdynamic -lMathMore
/usr/local/root/include/Math/Functor.h: In member function ‘double ROOT::Math::FunctorHandler<ParentFunctor, Func>::DoEval(const double*) const [with ParentFunctor = ROOT::Math::Functor, Func = double (Test::)(const double)]’:
NM2.cpp:106: instantiated from here
/usr/local/root/include/Math/Functor.h:86: error: must use ‘.’ or '->’ to call pointer-to-member function in ‘((const ROOT::Math::FunctorHandler<ROOT::Math::Functor, double (Test::)(const double)>)this)->ROOT::Math::FunctorHandler<ROOT::Math::Functor, double (Test::)(const double*)>::fFunc (…)’
It is very likely that I’m missing a key idea in how the inheritance is implemented for Functor, and hopefully the solution is simple. Help with fixing my “NM2.cpp” code to allow using the Functor and Minimizer Factory within a class will be greatly appreciated.
cheers,
Jeff
NM2.cpp (2.57 KB)
NumericalMinimization.cpp (2.48 KB)