34 #ifndef ROOT_Math_GSLFunctionAdapter
35 #define ROOT_Math_GSLFunctionAdapter
45 typedef double ( * GSLFuncPointer ) ( double,
void *);
62 template<
class UserFunc>
63 class GSLFunctionAdapter {
67 GSLFunctionAdapter() {}
68 virtual ~GSLFunctionAdapter() {}
70 static double F(
double x,
void * p) {
72 UserFunc *
function =
reinterpret_cast< UserFunc *
> (p);
73 return (*
function)( x );
77 static double Df(
double x,
void * p) {
79 UserFunc *
function =
reinterpret_cast< UserFunc *
> (p);
80 return (*function).Derivative( x );
83 static void Fdf(
double x,
void * p,
double *f,
double *df ) {
85 UserFunc *
function =
reinterpret_cast< UserFunc *
> (p);
86 *f = (*function) ( x );
87 *df = (*function).Derivative( x );