31 #ifndef ROOT_Math_GSLMultiMinFunctionWrapper
32 #define ROOT_Math_GSLMultiMinFunctionWrapper
34 #include "gsl/gsl_multimin.h"
46 typedef double ( * GSLMultiMinFuncPointer ) (
const gsl_vector *,
void *);
47 typedef void ( * GSLMultiMinDfPointer ) (
const gsl_vector *,
void *, gsl_vector *);
48 typedef void ( * GSLMultiMinFdfPointer ) (
const gsl_vector *,
void *,
double *, gsl_vector *);
58 class GSLMultiMinFunctionWrapper {
62 GSLMultiMinFunctionWrapper()
69 void SetFuncPointer( GSLMultiMinFuncPointer f) { fFunc.f = f; }
70 void SetDim (
unsigned int n ) { fFunc.n = n; }
71 void SetParams (
void * p) { fFunc.params = p; }
74 template<
class FuncType>
75 void SetFunction(
const FuncType &f) {
78 SetFuncPointer(&GSLMultiMinFunctionAdapter<FuncType >::F);
80 SetParams(const_cast<void *>(p));
83 gsl_multimin_function * GetFunc() {
return &fFunc; }
86 return (fFunc.f != 0) ?
true :
false;
92 gsl_multimin_function fFunc;
104 class GSLMultiMinDerivFunctionWrapper {
108 GSLMultiMinDerivFunctionWrapper()
118 void SetFuncPointer( GSLMultiMinFuncPointer f) { fFunc.f = f; }
119 void SetDerivPointer( GSLMultiMinDfPointer f) { fFunc.df = f; }
120 void SetFdfPointer( GSLMultiMinFdfPointer f) { fFunc.fdf = f; }
121 void SetDim (
unsigned int n ) { fFunc.n = n; }
122 void SetParams (
void * p) { fFunc.params = p; }
125 template<
class FuncType>
126 void SetFunction(
const FuncType &f) {
129 SetFuncPointer(&GSLMultiMinFunctionAdapter<FuncType >::F);
130 SetDerivPointer(&GSLMultiMinFunctionAdapter<FuncType >::Df);
131 SetFdfPointer(&GSLMultiMinFunctionAdapter<FuncType >::Fdf);
133 SetParams(const_cast<void *>(p));
136 gsl_multimin_function_fdf * GetFunc() {
return &fFunc; }
140 double operator() (
const double * x) {
142 return GSL_MULTIMIN_FN_EVAL(&fFunc, vx);
148 return (fFunc.f != 0) ?
true :
false;
153 gsl_multimin_function_fdf fFunc;