Wrappers for GSL functions. More...
Classes | |
class | julian::GslFunctionAdapter< F > |
Class implements adapter for gsl_function. More... | |
class | julian::GslFunctionFdfAdapter< F, dF > |
Class implements adapter for gsl_function_fdf. More... | |
class | julian::GslMultiminFunctionAdapter< F > |
Class implements adapter for gsl_multimin_function. More... | |
class | julian::GslMultiminFunctionFdfAdapter< F, dF, FdF > |
Class implements adapter for gsl_multimin_function. More... | |
Detailed Description
Wrappers for GSL functions.
The most important aspect of numerical routines is providing the function to the numerical algorithm. The GSL is a library written in C, so it does not take of the advantages of OOP. Instead of objects, GSL is using structures containing pointer to functions. The C functions are free functions and can't hold state. The fact that C functions can't hold state, makes parametrization of the function harder. In GSL this problem was solved by adding the void pointer to interface of the functions that are passed to numerical routines.
Those void pointers reference the structure holding the function's parameters. The numerical algorithm does not have any information about the structure pointed to void pointer, it just passed is to function, where pointer is casted to proper structure and dereferenced.
As this mechanism is quite complicated and hard to use, we provided the wrapper objects that map C++ functors (structure/classes with overloaded operator() method) to GSL functions. Wrapper decouples data and method of functor and passes them as void pointer and free function.
Simple example below:
Output
Numerical algorithm - using pointer to function Quadratic function 10 Sin function 1.92034 Numerical algorithm - using wrapper Quadratic function 10 Sin function 1.92034