Go to the documentation of this file.
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_funct 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++) {
201 #ifndef DOXYGEN_NO_O2NS
func_t * func
Pointer to the user-specified fitting function.
A class for representing permutations.
void matrix_copy(mat_t &src, mat2_t &dest)
Simple matrix copy.
vec_t fval
Storage for the function values.
bool min_set
True if the minimizer has been set by the user.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
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.
int set_mmin(mmin_base< multi_funct > &mm)
Set the mmin object to use (default is of type o2scl::mmin_simp2)
std::function< double(size_t, const boost::numeric::ublas::vector< double > &)> multi_funct
Multi-dimensional function typedef in src/base/multi_funct.h.
Base routines for the nonlinear fitting classes.
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.
double tol_rel_covar
The relative tolerance for the computation of the covariance matrix (default 0)
Non-linear least-squares fitting [abstract base].
Non-linear least-squares fitting class with generic minimizer.
virtual const char * type()
Return string denoting type ("fit_min")
mmin_simp2< multi_funct > def_mmin
The default minimizer.
mmin_base< multi_funct > * mmp
The minimizer.
double compute_delta(boost::numeric::ublas::vector< double > &diag2, size_t n, const boost::numeric::ublas::vector< double > &x)
Desc.
int compute_diag(size_t nparm, size_t ndata, const boost::numeric::ublas::matrix< double > &J, boost::numeric::ublas::vector< double > &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.
double dnrm2(const size_t N, const vec_t &X)
Compute the norm of the vector X.
int covariance(size_t m, size_t n, const boost::numeric::ublas::matrix< double > &J, boost::numeric::ublas::matrix< double > &covar, boost::numeric::ublas::vector< double > &norm, boost::numeric::ublas::matrix< double > &r, boost::numeric::ublas::vector< double > &tau, permutation &perm, double epsrel)
Compute the covarance matrix covar given the Jacobian J.
double min_func(size_t np, const vec_t &xp)
The function to minimize, .
double scaled_enorm(const boost::numeric::ublas::vector< double > &d, size_t n, const boost::numeric::ublas::vector< double > &f)
Euclidean norm of vector f of length n, scaled by vector d.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).