Author:
The library can be used either with or without an analytical Jacobian.
extern int dlevmar_der( void (*f)(double *p, double *hx, int m, int n, void *adata), void (*jacf)(double *p, double *j, int m, int n, void *adata), double *p, double *x, int m, int n, int itmax, double *opts, double *info, double *work, double *covar, void *adata); ret = dlevmar_der(f, jacf, p, x, m, n, itmax, opts, info, work, covar, adata);
where
f is a function of the formvoid f(double *p, double *x, int m, int n, void *data) /** * p is the parameter vector of length m * x is the measurement vector of length n * (f evaluated at p is x) * data is unused (NULL) */
jac_f is a function of the formvoid (*jacf)(double *p, double *j, int m, int n, void *adata) /** * p is the parameter vector of length m * j is the Jacobian vector (df/dp) of length n * adata is unused (NULL) */
p is the parameter vector of length m (input: estimate, output: solution)x is the measurement vector of length nitmax is the maximum number of iterationsopts points to LM_OPTS_SZ doubles, containg (from lmbc_core.c)/* * minim. options [\mu, \epsilon1, \epsilon2, \epsilon3]. * * Respectively the scale factor for initial \mu, * stopping thresholds for ||J^T e||_inf, ||Dp||_2 and ||e||_2. * * Set to NULL for defaults to be used. * * Note that ||J^T e||_inf is computed on free (not equal * to lb[i] or ub[i]) variables only. */
info points to LM_INFO_SZ doubles, containing (from lmbc_core.c)/* * info[0]= ||e||_2 at initial p. * * info[1-4]=[ ||e||_2, ||J^T e||_inf, ||Dp||_2, * mu/max[J^T J]_ii ], all computed at estimated p. * * info[5]= number of iterations, * * info[6]= reason for terminating: * 1 - stopped by small gradient J^T e * 2 - stopped by small Dp * 3 - stopped by itmax * 4 - singular matrix. Restart from current p with * increased mu * 5 - no further error reduction is possible. Restart * with increased mu * 6 - stopped by small ||e||_2 * * info[7]= number of function evaluations * * info[8]= number of jacobian evaluations */
work pre-allocated workspacecovar pointer to covariance matrix (m x m)adata application specific dataret returns the number of iterations or -1 if failedextern int dlevmar_dif( void (*func)(double *p, double *hx, int m, int n, void *adata), double *p, double *x, int m, int n, int itmax, double *opts, double *info, double *work, double *covar, void *adata); ret = dlevmar_dif(f, p, x, m, n, 1000, opts, info, NULL, NULL, NULL);
[KMHN04] K. Madsen, H.B. Nielsen and O. Tinglef. Methods for non-linear least squares problems. Technical report, Informatics and Mathematical Modelling, Technical University of Denmark, 4/2004.