• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)

Standard preamble:
========================================================================
..
..
.. Set up some character translations and predefined strings. \*(-- will
give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
double quote, and \*(R" will give a right double quote. \*(C+ will
give a nicer C++. Capital omega is used to do unbreakable dashes and
therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
nothing in troff, for use with C<>.
.tr \(*W- . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\}
Escape single quotes in literal strings from groff's Unicode transform.

If the F register is turned on, we'll generate index entries on stderr for
titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
entries marked with X<> in POD. Of course, you'll have to process the
output yourself in some meaningful fashion.

Avoid warning from groff about undefined register 'F'.
.. .nr rF 0 . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF
Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] .\} . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents . \" corrections for vroff . \" for low resolution devices (crt and lpr) \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} ========================================================================

Title "lmmin 3"
lmmin 3 "2015-11-27" "perl v5.20.2" "lmfit manual"
For nroff, turn off justification. Always turn off hyphenation; it makes
way too many mistakes in technical documents.
"NAME"
lmmin - Levenberg-Marquardt least-squares minimization
"SYNOPSIS"
Header "SYNOPSIS" \fB#include <lmmin.h>

\fBvoid lmmin( const int n_par, double *par, const int m_dat, const void *data, void *evaluate( const double *par, const int m_dat, const void *data, double *fvec, int *userbreak), const lm_control_struct *control, lm_status_struct *status );

\fBextern const lm_control_struct lm_control_double;

\fBextern const lm_control_struct lm_control_float;

\fBextern const char *lm_infmsg[];

\fBextern const char *lm_shortmsg[];

"DESCRIPTION"
Header "DESCRIPTION" \fB\f(BIlmmin() determines a vector par that minimizes the sum of squared elements of a vector fvec that is computed by a user-supplied function evaluate(). On success, par represents a local minimum, not necessarily a global one; it may depend on its starting value.

For applications in curve fitting, the wrapper function \f(BIlmcurve\|(3) offers a simplified \s-1API.\s0

The Levenberg-Marquardt minimization starts with a steepest-descent exploration of the parameter space, and achieves rapid convergence by crossing over into the Newton-Gauss method.

Function arguments:

"n_par" 4
Item "n_par" Number of free variables. Length of parameter vector par.
"par" 4
Item "par" Parameter vector. On input, it must contain a reasonable guess. On output, it contains the solution found to minimize ||fvec||.
"m_dat" 4
Item "m_dat" Length of vector fvec. Must statisfy n_par <= m_dat.
"data" 4
Item "data" This pointer is ignored by the fit algorithm, except for appearing as an argument in all calls to the user-supplied routine evaluate.
"evaluate" 4
Item "evaluate" Pointer to a user-supplied function that computes m_dat elements of vector fvec for a given parameter vector par. If evaluate return with *userbreak set to a negative value, \f(BIlmmin() will interrupt the fitting and terminate.
"control" 4
Item "control" Parameter collection for tuning the fit procedure. In most cases, the default &lm_control_double is adequate. If f is only computed with single-precision accuracy, \fI&lm_control_float should be used. See also below, \s-1NOTES\s0 on initializing parameter records. .Sp \fIcontrol has the following members (for more details, see the source file lmstruct.h):

"double control.ftol" 4
Item "double control.ftol" Relative error desired in the sum of squares. Recommended setting: somewhat above machine precision; less if fvec is computed with reduced accuracy.
"double control.xtol" 4
Item "double control.xtol" Relative error between last two approximations. Recommended setting: as ftol.
"double control.gtol" 4
Item "double control.gtol" A measure for degeneracy. Recommended setting: as ftol.
"double control.epsilon" 4
Item "double control.epsilon" Step used to calculate the Jacobian. Recommended setting: as ftol, but definitely less than the accuracy of fvec.
"double control.stepbound" 4
Item "double control.stepbound" Initial bound to steps in the outer loop, generally between 0.01 and 100; recommended value is 100.
"int control.patience" 4
Item "int control.patience" Used to set the maximum number of function evaluations to patience*n_par.
"int control.scale_diag" 4
Item "int control.scale_diag" Logical switch (0 or 1). If 1, then scale parameters to their initial value. This is the recommended setting.
"FILE* control.msgfile" 4
Item "FILE* control.msgfile" Progress messages will be written to this file. Typically stdout or stderr. The value \s-1NULL\s0 will be interpreted as stdout.
"int control.verbosity" 4
Item "int control.verbosity" If nonzero, some progress information from within the \s-1LM\s0 algorithm is written to control.stream.
"int control.n_maxpri" 4
Item "int control.n_maxpri" \-1, or maximum number of parameters to print.
"int control.m_maxpri" 4
Item "int control.m_maxpri" \-1, or maximum number of residuals to print.

"status" 4
Item "status" A record used to return information about the minimization process:

"double status.fnorm" 4
Item "double status.fnorm" Norm of the vector fvec;
"int status.nfev" 4
Item "int status.nfev" Actual number of iterations;
"int status.outcome" 4
Item "int status.outcome" Status of minimization; for the corresponding text message, print lm_infmsg[status.outcome]; for a short code, print lm_shortmsg[status.outcome].
"int status.userbreak" 4
Item "int status.userbreak" Set when termination has been forced by the user-supplied routine evaluate.

"NOTES"
Header "NOTES"
"Initializing parameter records."
Subsection "Initializing parameter records." The parameter record control should always be initialized from supplied default records:

.Vb 1 lm_control_struct control = lm_control_double; /* or _float */ .Ve

After this, parameters may be overwritten:

.Vb 2 control.patience = 500; /* allow more iterations */ control.verbosity = 15; /* for verbose monitoring */ .Ve

An application written this way is guaranteed to work even if new parameters are added to lm_control_struct.

Conversely, addition of parameters is not considered an \s-1API\s0 change; it may happen without increment of the major version number.

"EXAMPLES"
Header "EXAMPLES"
"Fitting a surface"
Subsection "Fitting a surface" Fit a data set y(t) by a function f(t;p) where t is a two-dimensional vector:

.Vb 2 #include "lmmin.h" #include <stdio.h> \& /* fit model: a plane p0 + p1*tx + p2*tz */ double f( double tx, double tz, const double *p ) { return p[0] + p[1]*tx + p[2]*tz; } \& /* data structure to transmit data arays and fit model */ typedef struct { double *tx, *tz; double *y; double (*f)( double tx, double tz, const double *p ); } data_struct; \& /* function evaluation, determination of residues */ void evaluate_surface( const double *par, int m_dat, const void *data, double *fvec, int *userbreak ) { /* for readability, explicit type conversion */ data_struct *D; D = (data_struct*)data; \& int i; for ( i = 0; i < m_dat; i++ ) fvec[i] = D->y[i] - D->f( D->tx[i], D->tz[i], par ); } \& int main() { /* parameter vector */ int n_par = 3; /* number of parameters in model function f */ double par[3] = { -1, 0, 1 }; /* arbitrary starting value */ \& /* data points */ int m_dat = 4; double tx[4] = { -1, -1, 1, 1 }; double tz[4] = { -1, 1, -1, 1 }; double y[4] = { 0, 1, 1, 2 }; \& data_struct data = { tx, tz, y, f }; \& /* auxiliary parameters */ lm_status_struct status; lm_control_struct control = lm_control_double; control.verbosity = 3; \& /* perform the fit */ printf( "Fitting:\en" ); lmmin( n_par, par, m_dat, (const void*) &data, evaluate_surface, &control, &status ); \& /* print results */ printf( "\enResults:\en" ); printf( "status after %d function evaluations:\en %s\en", status.nfev, lm_infmsg[status.outcome] ); \& printf("obtained parameters:\en"); int i; for ( i=0; i<n_par; ++i ) printf(" par[%i] = %12g\en", i, par[i]); printf("obtained norm:\en %12g\en", status.fnorm ); \& printf("fitting data as follows:\en"); double ff; for ( i=0; i<m_dat; ++i ){ ff = f(tx[i], tz[i], par); printf( " t[%2d]=%12g,%12g y=%12g fit=%12g residue=%12g\en", i, tx[i], tz[i], y[i], ff, y[i] - ff ); } \& return 0; } .Ve

"More examples"
Subsection "More examples" For more examples, see the homepage and directories demo/ and test/ in the source distribution.
"COPYING"
Header "COPYING" Copyright (C): 1980-1999 University of Chicago 2004-2015 Joachim Wuttke, Forschungszentrum Juelich GmbH

Software: FreeBSD License

Documentation: Creative Commons Attribution Share Alike

"SEE ALSO"
Header "SEE ALSO" lmcurve(3)

Homepage: http://apps.jcns.fz-juelich.de/lmfit

"BUGS"
Header "BUGS" Please send bug reports and suggestions to the author <j.wuttke@fz-juelich.de>.