Fitting routines in C++

Hi there,

I am trying to find a C++ library which I can use to very efficiently fit a variety of user-defined functions (e.g. A + Bt + Ct^2sin(Dt+E)) to a set of data (essentially numbers as a function of time). I know there are the ROOT TF1, but was wondering where I can find a pure C++ library with such functions.

Many thanks.
Wolf

You can (fairly easily) hook up a TF1 to an arbitrary C++ function. See root.cern.ch/root/html520/TF1.html#TF1:TF1.

Cheers,
Charles

Hi Charles,

Many thanks again.

I now included TF1.h at the beginning of my C++ application and copied TF1.h file into the appropriate directory for my C++ application, but I am still missing the source file for the functions in TF1.h. Do you know where I can find it?

Many thanks.
Wolf

Hi,

What do you mean “missing the source file for the functions”? You should only need the library that contain they compiled version and link against them/

Philippe

Hi,

Note that TF1 is implemented in the library named libHist
In visual studio you will need add this library to the list of library linked to your executable.

Cheers,
Philippe.

Many thanks, Philippe.

Cheers,
Wolf

Hi there,

I tried including the TF1.h as well as all the other header-files that are required by TF1.h in my application. I also copied the libHist.lib to the lib/ folder of visual studio. However, when I try to compile, I get the following error:

test.obj : error LNK2019: unresolved external symbol “public: __thiscall TVersionCheck::TVersionCheck(int)” (??0TVersionCheck@@QAE@H@Z) referenced in function “void __cdecl `dynamic initializer for ‘gVersionCheck’’(void)” (??__EgVersionCheck@@YAXXZ)
test.exe : fatal error LNK1120: 1 unresolved externals

I don’t understand this error message. Any clarification would be much appreciated.

Kind regards,
Wolf

Hi,

[quote]I also copied the libHist.lib to the lib/ folder of visual studio. [/quote]I would not do that. This makes upgrading to new version of ROOT harder (you will need to remember to update those libraries too). In visual studio, I am pretty sure you can link against library in any directory and add directories to the list of dir used to search library

The error message you have seem to indicate that you do not have libCore linked against your library.

Cheers,
Philippe.