User defined C or C++ functions for graphical presentation of ordinary and parametric functions and for parameter fits are used by Kpl as shared libraries. These functions return double values and expect a double function argument and a pointer to a double array of up to 20 parameters:
double myfunction(double x, const double *p); |
Module definition files (of the type .def and the same name as source and library files) are used as a lookup table by Kpl. They correspond to the output of the program nm.
In the directory $KDEDIR/share/apps/kpl a shared library fkt.so as well as the source file fkt.c, the module definition file fkt.def, and a make file Makefile.fkt are already installed. The files fkt.c and Makefile.fkt may be used as examples and have to be customized in this case.
As an example for multidimensional parameter fits, a C++ source file fcompl.cpp as well as the corresponding files fcompl.so, fcompl.def, and Makefile.fcompl are provided in the same directory. Here two double valued functions make use of the real and imaginary part of a complex function, implemented with the class complex.