libkpl  6.0
A Library for Graphical Presentation of Data Sets and Functions
LMFit Class Reference

Parameter fit class. More...

#include <lmfit.h>

Inheritance diagram for LMFit:

Signals

void updateMessage (const QString &message)
 Emitted when a message should be displayed.
 

Public Member Functions

 LMFit (const QList< const ArrayItem * > *aList, QList< FunItem * > *fList, const bool *bFit, double *par, QObject *parent=nullptr, const double *sigma=nullptr)
 Constructor.
 
 ~LMFit ()
 Destructor.
 
bool linFit (int n, int nPar, double par[], double resVector[], double fJac[], int iPvt[])
 Performs general linear least square parameter fit.
 
void lmdif (int n, int nPar, double par[], double resVector[], double tol, int itMax, int *info, double fJac[], int iPvt[])
 Performs nonlinear Levenberg-Marquardt parameter fit.
 
void setSigma (const double *sigma)
 Sets data error array.
 
void setUserBreak (bool userBreak=true)
 Sets condition to stop calculations.
 
bool userBreak () const
 Returns current break condition for calculations.
 

Static Public Member Functions

static double enorm (int n, const double x[])
 Calculates the euclidean norm of x.
 
static double igamc (double a, double x)
 Calculates complemented incomplete gamma integral.
 
static int minv (double a[], double x[], int n)
 Finds the inverse of a square matrix.
 

Protected Member Functions

void fcn (int n, int np, const double p[], double fvec[], int *iflag)
 
void fdjac2 (int m, int n, double x[], const double fvec[], double fjac[], int ldfjac, int *iflag, double epsfcn, double wa[])
 
void lmdif (int m, int np, double px[], double fvec[], double ftol, double ptol, double gtol, int maxfev, double epsfcn, double diag[], int mode, double factor, int nprint, int *info, int *nfev, double fjac[], int ldfjac, int ipvt[], double qtf[], double wa1[], double wa2[], double wa3[], double wa4[])
 

Protected Attributes

bool m_userBreak
 
const bool * m_bFit
 
double * m_par
 
const double * m_sigma
 
const QList< const ArrayItem * > * m_aList
 
QList< FunItem * > * m_fList
 

Detailed Description

Parameter fit class.

Provides methods for nonlinear Levenberg-Marquardt parameter fits and general linear least square parameter fits.

The functions lmdif, lmpar, fdjac2, qrsolv, qrfac, and enorm use code from the public domain Fortran version of Argonne National Laboratories MINPACK, C translation by Steve Moshier. Modifications by Werner Stille.

The functions minv, igamc, igam, simq, and mtransp are from the Cephes Math Library Release 2.7, Copyright by Stephen L. Moshier.

The function lgam (original name: gsl_sf_lngamma_impl, Author: G. Jungman) is from the GNU Scientific Library. Modifications by Werner Stille.

Constructor & Destructor Documentation

◆ LMFit()

LMFit::LMFit ( const QList< const ArrayItem * > * aList,
QList< FunItem * > * fList,
const bool * bFit,
double * par,
QObject * parent = nullptr,
const double * sigma = nullptr )

Constructor.

Parameters
aListlist of array items.
fListlist of function items.
bFitarray containing true values for parameters to be fitted.
pararray of parameters.
sigmaarray for data errors.
parentpointer to parent widget.

Member Function Documentation

◆ enorm()

static double LMFit::enorm ( int n,
const double x[] )
static

Calculates the euclidean norm of x.

Parameters
nlength of x.
xinput array.
Returns
euclidean norm of x.

◆ igamc()

static double LMFit::igamc ( double a,
double x )
static

Calculates complemented incomplete gamma integral.

Parameters
aargument of gamma function.
xupper boundary of integral.
Returns
complemented incomplete gamma integral.

◆ linFit()

bool LMFit::linFit ( int n,
int nPar,
double par[],
double resVector[],
double fJac[],
int iPvt[] )

Performs general linear least square parameter fit.

Parameters
nnumber of data points.
nParnumber of parameters to be fitted.
pararray of parameters to be fitted.
resVectorarray for weighted residuals.
fJacarray for calculating the Jacobian matrix.
iPvtarray defining a permutation matrix for calculating the Jacobian matrix.
Returns
true in case of termination by user.

◆ lmdif()

void LMFit::lmdif ( int n,
int nPar,
double par[],
double resVector[],
double tol,
int itMax,
int * info,
double fJac[],
int iPvt[] )

Performs nonlinear Levenberg-Marquardt parameter fit.

Parameters
nnumber of data points.
nParnumber of parameters to be fitted.
pararray of parameters to be fitted.
resVectorarray for weighted residuals.
toltolerance value for stopping nonlinear fit iterations.
itMaxmaximum number of nonlinear fit iterations.
infoerror code.
fJacarray for calculating the Jacobian matrix.
iPvtarray defining a permutation matrix for calculating the Jacobian matrix.

◆ minv()

static int LMFit::minv ( double a[],
double x[],
int n )
static

Finds the inverse of a square matrix.

Parameters
ainput matrix.
xoutput matrix.
nnumbers of rows and columns of input matrix.
Returns
0 for success.

◆ setSigma()

void LMFit::setSigma ( const double * sigma)
inline

Sets data error array.

Parameters
sigmaarray for data errors.

◆ setUserBreak()

void LMFit::setUserBreak ( bool userBreak = true)
inline

Sets condition to stop calculations.

Parameters
userBreaktrue to break calculations.

◆ updateMessage

void LMFit::updateMessage ( const QString & message)
signal

Emitted when a message should be displayed.

Parameters
messagemessage text

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