#ifndef _CHISQMIN_H_ #define _CHISQMIN_H_ class residFunc { public: virtual ~residFunc(); virtual void resid(const HepVector *x, void *data, HepVector *f) = 0; virtual void deriv(const HepVector *x, void *data, HepMatrix *J) = 0; virtual void residAndDeriv(const HepVector *x, void *data, HepVector *f, HepMatrix *J) = 0; virtual unsigned getn() = 0; virtual unsigned getp() = 0; }; extern "C" { #include #include #include } class chisqMin { public: chisqMin(residFunc *f); ~chisqMin(); void setStartParams(HepVector &x); void fit(); HepVector getParams(); HepMatrix getCovar(); private: const gsl_multifit_fdfsolver_type *T; /* pointer to solver type */ gsl_multifit_fdfsolver *s; /* pointer to solver */ gsl_multifit_function_fdf f; /* function structure */ residFunc *residFuncPtr; unsigned int iter; /* fit iteration */ int status; /* status from fit */ gsl_matrix *covar; /* covariance matrix */ unsigned int p; /* number of parameters, local copy for convenience */ unsigned int n; /* number of data points, local copy for convenience */ }; extern "C" { int fGsl(const gsl_vector *x, void *data, gsl_vector *f); int dfGsl(const gsl_vector *x, void *data, gsl_matrix *J); int fdfGsl(const gsl_vector *x, void *data, gsl_vector *f, gsl_matrix *J); } #endif // _CHISQMIN_H_