34 #ifndef ROOT_Math_GSLMultiFitFunctionAdapter 35 #define ROOT_Math_GSLMultiFitFunctionAdapter 37 #include "gsl/gsl_vector.h" 38 #include "gsl/gsl_matrix.h" 70 template<
class FuncVector>
75 static int F(
const gsl_vector *
x,
void * p, gsl_vector *
f ) {
77 unsigned int n = f->size;
79 FuncVector & funcVec = *(
reinterpret_cast< FuncVector *
> (p) );
80 if (n == 0)
return -1;
81 for (
unsigned int i = 0; i <
n ; ++i) {
82 gsl_vector_set(f, i, (funcVec[i])(x->data) );
88 static int Df(
const gsl_vector *
x,
void * p, gsl_matrix *
h) {
91 unsigned int n = h->size1;
92 unsigned int npar = h->size2;
93 if (n == 0)
return -1;
94 if (npar == 0)
return -2;
95 FuncVector & funcVec = *(
reinterpret_cast< FuncVector *
> (p) );
96 for (
unsigned int i = 0; i <
n ; ++i) {
97 double * g = (h->data)+i*npar;
98 assert ( npar == (funcVec[i]).NDim() );
99 (funcVec[i]).Gradient(x->data, g);
105 static int FDf(
const gsl_vector *
x,
void * p, gsl_vector *
f, gsl_matrix *
h) {
108 unsigned int n = h->size1;
109 unsigned int npar = h->size2;
110 if (n == 0)
return -1;
111 if (npar == 0)
return -2;
112 FuncVector & funcVec = *(
reinterpret_cast< FuncVector *
> (p) );
113 assert ( f->size == n);
114 for (
unsigned int i = 0; i <
n ; ++i) {
115 assert ( npar == (funcVec[i]).NDim() );
117 double * g = (h->data)+i*npar;
118 (funcVec[i]).FdF(x->data, fval, g);
119 gsl_vector_set(f, i, fval );
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
static int F(const gsl_vector *x, void *p, gsl_vector *f)
static int FDf(const gsl_vector *x, void *p, gsl_vector *f, gsl_matrix *h)
evaluate derivative and function at the same time
static int Df(const gsl_vector *x, void *p, gsl_matrix *h)
Class for adapting a C++ functor class to C function pointers used by GSL MultiFit Algorithm The temp...
Namespace for new Math classes and functions.