23 #ifndef O2SCL_FIT_MIN_H 24 #define O2SCL_FIT_MIN_H 30 #include <o2scl/mmin.h> 31 #include <o2scl/multi_funct.h> 32 #include <o2scl/mmin_simp2.h> 33 #include <o2scl/fit_base.h> 34 #include <o2scl/fit_nonlin.h> 36 #ifndef DOXYGEN_NO_O2NS 59 template<
class func_t=gen_fit_funct<>,
60 class vec_t=boost::numeric::ublas::vector<
double>,
61 class mat_t=boost::numeric::ublas::matrix<
double> >
class fit_min :
79 virtual int fit(
size_t npar, vec_t &par, mat_t &covar,
double &chi2,
84 size_t ndata=fitfun.get_ndata();
91 multi_funct11 mmf=std::bind(std::mem_fn<
double(
size_t,
const vec_t &)>
93 this,std::placeholders::_1,
94 std::placeholders::_2);
108 vec_t diag, tau, norm;
117 J.resize(ndata,npar);
118 r.resize(ndata,npar);
121 fitfun(npar,par,ndata,
fval);
122 fitfun.jac(npar,par,ndata,
fval,J);
139 this->
covariance(ndata,npar,J,covar,norm,r,tau,perm,
169 virtual const char *
type() {
return "fit_min"; }
171 #ifndef DOXYGEN_INTERNAL 190 (*func)(np,xp,func->get_ndata(),
fval);
191 for(
size_t i=0;i<func->get_ndata();i++) {
192 ret+=fval[i]*fval[i];
201 #ifndef DOXYGEN_NO_O2NS double compute_delta(vec_t &diag2, size_t n, const vec_t &x)
Desc.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
func_t * func
Pointer to the user-specified fitting function.
int compute_diag(size_t nparm, size_t ndata, const mat_t &J, vec_t &diag_vec)
Compute the root of the sum of the squares of the columns of J.
virtual int mmin(size_t nvar, vec_t &x, double &fmin, func_t &func)=0
Calculate the minimum min of func w.r.t. the array x of size nvar.
Non-linear least-squares fitting class with generic minimizer.
A class for representing permutations.
mmin_base< multi_funct11 > * mmp
The minimizer.
void QRPT_decomp(size_t M, size_t N, mat_t &A, vec_t &tau, o2scl::permutation &p, int &signum, vec2_t &norm)
Compute the QR decomposition of matrix A.
vec_t fval
Storage for the function values.
Base routines for the nonlinear fitting classes.
double dnrm2(const size_t N, const vec_t &X)
Compute the norm of the vector X.
virtual const char * type()
Return string denoting type ("fit_min")
void matrix_copy(mat_t &src, mat2_t &dest)
Simple matrix copy.
int set_mmin(mmin_base< multi_funct11 > &mm)
Set the mmin object to use (default is of type o2scl::mmin_simp2)
bool min_set
True if the minimizer has been set by the user.
double min_func(size_t np, const vec_t &xp)
The function to minimize, .
virtual int fit(size_t npar, 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...
Non-linear least-squares fitting [abstract base].
std::function< double(size_t, const boost::numeric::ublas::vector< double > &)> multi_funct11
Multi-dimensional function typedef.
mmin_simp2< multi_funct11 > def_mmin
The default minimizer.
int covariance(size_t m, size_t n, const mat_t &J, mat_t &covar, vec_t &norm, mat_t &r, vec_t &tau, permutation &perm, double epsrel)
Compute the covarance matrix covar given the Jacobian J.
double scaled_enorm(const vec_t &d, size_t n, const vec_t &f)
Euclidean norm of vector f of length n, scaled by vector d.
double tol_rel_covar
The relative tolerance for the computation of the covariance matrix (default 0)