23 #ifndef O2SCL_FIT_FIX_H 24 #define O2SCL_FIT_FIX_H 30 #include <boost/numeric/ublas/vector.hpp> 31 #include <boost/numeric/ublas/matrix.hpp> 33 #include <o2scl/fit_base.h> 34 #include <o2scl/fit_nonlin.h> 36 #ifndef DOXYGEN_NO_O2NS 64 template<
class bool_vec_t,
class func_t=gen_fit_funct<>,
65 class vec_t=boost::numeric::ublas::vector<
double>,
66 class mat_t=boost::numeric::ublas::matrix<
double> >
112 virtual int fit(
size_t np, vec_t &par, mat_t &covar,
double &chi2,
119 size_t nd=fitfun.get_ndata();
145 virtual int fit_fix(
size_t np, vec_t &par, mat_t &covar,
double &chi2,
146 func_t &fitfun, bool_vec_t &fix) {
152 size_t nd=fitfun.get_ndata();
156 for(
size_t i=0;i<np;i++) {
168 for(
size_t i=0;i<np;i++) {
183 for(
size_t i=0;i<np;i++) {
193 for(
int i=((
int)np)-1;i>=0;i--) {
195 for(
int k=((
int)np)-1;k>=0;k--) {
196 if (fix[i]==
false && fix[k]==
false) {
197 if (i_new<0 || k_new<0 ||
202 covar(i,k)=covar(i_new,k_new);
210 if (fix[i]==
false) i_new--;
235 return (*funcp).get_ndata();
243 size_t nd, vec_t &f) {
248 for(
size_t i=0;i<
u_np;i++) {
250 u_par[i]=(*x_par)[i];
252 u_par[i]=par_new[i_new];
257 O2SCL_ERR(
"Alignment failure 1 in fit_fix::operator().",
269 virtual void jac(
size_t np_new, vec_t &par_new,
size_t nd, vec_t &f,
273 for(
size_t i=0;i<
u_np;i++) {
275 u_par[i]=(*x_par)[i];
277 u_par[i]=par_new[i_new];
282 O2SCL_ERR(
"Alignment failure 2 in fit_fix::operator().",
287 (*funcp).jac(u_np,
u_par,nd,f,
J);
291 for(
size_t id=0;
id<nd;
id++) {
293 for(
size_t i=0;i<
u_np;i++) {
295 J_new(
id,i_new)=
J(
id,i);
305 #ifndef DOXYGEN_INTERNAL 346 #ifndef DOXYGEN_NO_O2NS int set_fit(base_fit_t &fitter)
Change the base fitter.
base_fit_t * fitp
The fitter.
def_fit_t def_fit
The default base fitter.
Generalized fitting function [abstract base].
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
mat_t J
Jacobian in the user space of size (nd,u_np)
sanity check failed - shouldn't happen
fit_fix_pars()
Specify the member function pointer.
Non-linear least-squares fitting class (GSL)
virtual int fit_fix(size_t np, vec_t &par, mat_t &covar, double &chi2, func_t &fitfun, bool_vec_t &fix)
Fit function func while fixing some parameters as specified in fix.
vec_t u_par_new
Vector for smaller parameter list of size u_np_new.
vec_t * x_par
The user-specified initial vector of size u_np.
size_t ntrial
Maximum number of iterations (default 500)
bool_vec_t * fix_par
Specify which parameters to fix (vector of size u_np)
fit_base< fit_fix_pars< bool_vec_t, func_t, vec_t, mat_t >, vec_t, mat_t > base_fit_t
The generic fitter type.
virtual size_t get_ndata()
The function to return the number of data points.
virtual int fit(size_t np, vec_t &par, mat_t &covar, double &chi2, func_t &fitfun)
Fit the data specified in (xdat,ydat) to the function fitfun with the parameters in par...
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
bool expand_covar
If true, expand the covariance matrix to the larger space by filling with the identity matrix (defaul...
func_t * funcp
The user-specified function.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
double tol_rel
(default 1.0e-4)
int verbose
An integer describing the verbosity of the output.
Multidimensional fitting class fixing some parameters and varying others.
fit_nonlin< fit_fix_pars< bool_vec_t, func_t, vec_t, mat_t >, vec_t, mat_t > def_fit_t
The default fitter type.
vec_t u_par
Temporary vector to store full parameter list of size u_np.
size_t u_np_new
The new number of variables.
virtual void operator()(size_t np_new, const vec_t &par_new, size_t nd, vec_t &f)
The function computing deviations.
Non-linear least-squares fitting [abstract base].
virtual void jac(size_t np_new, vec_t &par_new, size_t nd, vec_t &f, mat_t &J_new)
The function computing the Jacobian.
double tol_abs
Absolute tolerance (default 1.0e-4)
size_t u_np
The user-specified number of variables.
virtual int fit(size_t npar, vec_t &parms, mat_t &covar, double &chi2, func_t &fitfun)=0
Fit function fitfun using parameters in parms as initial guesses.