Public Member Functions | Public Attributes | Protected Member Functions | List of all members
o2scl::fit_nonlin_b< vec_t, mat_t > Class Template Reference

Base routines for the nonlinear fitting classes. More...

#include <fit_nonlin.h>

Inheritance diagram for o2scl::fit_nonlin_b< vec_t, mat_t >:
o2scl::fit_nonlin< fit_fix_pars< bool_vec_t, func_t, vec_t, mat_t >, vec_t, mat_t > o2scl::fit_min< func_t, vec_t, mat_t > o2scl::fit_nonlin< func_t, vec_t, mat_t >

Public Member Functions

int test_delta_f (size_t nparm, vec_t &dx, vec_t &x, double l_epsabs, double l_epsrel)
 Test if converged.
 
int test_gradient_f (size_t nparm, vec_t &g, double l_epsabs)
 Test if converged.
 

Public Attributes

double tol_rel_covar
 The relative tolerance for the computation of the covariance matrix (default 0)
 

Protected Member Functions

double compute_actual_reduction (double fnorm0, double fnorm1)
 Desc.
 
size_t count_nsing (const size_t ncols, const mat_t &r2)
 Desc.
 
void compute_newton_direction (size_t n, const mat_t &r2, const permutation &perm2, const vec_t &qtf2, vec_t &x)
 Desc.
 
void compute_newton_bound (size_t nd, size_t np, const mat_t &r2, const vec_t &x, double dxnorm, const permutation &perm, const vec_t &diag, vec_t &w)
 Desc.
 
void compute_gradient_direction (size_t n, const mat_t &r, const permutation &p, const vec_t &qtf2, const vec_t &diag, vec_t &g)
 Desc.
 
void update_diag (size_t n, const mat_t &J, vec_t &diag2)
 Desc.
 
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 compute_delta (vec_t &diag2, size_t n, const vec_t &x)
 Desc.
 
void compute_rptdx (const mat_t &r2, const permutation &p, size_t N, vec_t &dx, vec_t &rptdx2)
 Desc.
 
int qrsolv (size_t n, mat_t &r2, const permutation &p, const double lambda, const vec_t &diag2, const vec_t &qtb, vec_t &x, vec_t &sdiag2, vec_t &wa)
 Compute the solution to a least squares system. More...
 
void compute_newton_correction (size_t n, const mat_t &r2, const vec_t &sdiag2, const permutation &p, vec_t &x, double dxnorm, const vec_t &diag2, vec_t &w2)
 Desc.
 
void lmpar (mat_t &r2, const permutation &perm2, const vec_t &qtf2, const vec_t &diag2, double delta2, double *par_inout, vec_t &newton2, vec_t &gradient2, vec_t &sdiag2, vec_t &x, vec_t &w2, size_t nparm, size_t ndata)
 Determine Levenburg-Marquardt parameter.
 
void compute_trial_step (size_t N, vec_t &x, vec_t &dx, vec_t &trial)
 Compute trial step, $ \mathrm{trial}=\mathrm{x}+\mathrm{dx} $.
 
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. More...
 
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. More...
 

Detailed Description

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
class o2scl::fit_nonlin_b< vec_t, mat_t >

Definition at line 67 of file fit_nonlin.h.

Member Function Documentation

◆ compute_diag()

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
int o2scl::fit_nonlin_b< vec_t, mat_t >::compute_diag ( size_t  nparm,
size_t  ndata,
const mat_t &  J,
vec_t &  diag_vec 
)
inlineprotected

This computes

\[ \mathrm{diag\_vec}_j = \sqrt{\sum_{i=0}^{\mathrm{ndata}-1} J_{ij}} \]

for $ 0\leq j \leq \mathrm{nparm}-1 $ . If any of the columns of J is all zero, then the corresponding entry in diag_vec is set to one instead.

Definition at line 680 of file fit_nonlin.h.

◆ covariance()

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
int o2scl::fit_nonlin_b< vec_t, mat_t >::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 
)
inlineprotected

Given a m by n Jacobian matrix J (where m must not be less than n), and a relative tolerance epsrel, this function computes the entries of the n by n covariance matrix covar. The allocation for covar must be performed beforehand.

This function is basically the equivalent of the function gsl_multifit_covar(), but rewritten for generic vector and matrix types.

The workspace work1 is used here.

Definition at line 721 of file fit_nonlin.h.

◆ qrsolv()

template<class vec_t = boost::numeric::ublas::vector<double>, class mat_t = boost::numeric::ublas::matrix<double>>
int o2scl::fit_nonlin_b< vec_t, mat_t >::qrsolv ( size_t  n,
mat_t &  r2,
const permutation p,
const double  lambda,
const vec_t &  diag2,
const vec_t &  qtb,
vec_t &  x,
vec_t &  sdiag2,
vec_t &  wa 
)
inlineprotected
This function computes the solution to the least squares system

phi=[ A x=b ,lambda D x=0 ]^2

where A is an M by N matrix,D is an N by N diagonal matrix,lambda
is a scalar parameter and b is a vector of length M.

The function requires the factorization of A into A=Q R P^T,
where Q is an orthogonal matrix,R is an upper triangular matrix
with diagonal elements of non-increasing magnitude and P is a
permuation matrix. The system above is then equivalent to

[ R z=Q^T b,P^T (lambda D) P z=0 ]

where x=P z. If this system does not have full rank then a least
squares solution is obtained. On output the function also provides
an upper triangular matrix S such that

P^T (A^T A+lambda^2 D^T D) P=S^T S

Parameters,

r: On input,contains the full upper triangle of R. On output the
strict lower triangle contains the transpose of the strict upper
triangle of S,and the diagonal of S is stored in sdiag.  The full
upper triangle of R is not modified.

p: the encoded form of the permutation matrix P. column j of P is
column p[j] of the identity matrix.

lambda,diag: contains the scalar lambda and the diagonal elements
of the matrix D

qtb: contains the product Q^T b

x: on output contains the least squares solution of the system

wa: is a workspace of length N

Definition at line 310 of file fit_nonlin.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).