1 /*
2  * Library:   lmfit (Levenberg-Marquardt least squares fitting)
3  *
4  * File:      lmmin.h
5  *
6  * Contents:  Declarations for Levenberg-Marquardt minimization.
7  *
8  * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
9  *
10  * License:   see ../COPYING (FreeBSD)
11  *
12  * Homepage:  apps.jcns.fz-juelich.de/lmfit
13  */
14 
15 #ifndef LMMIN_H
16 #define LMMIN_H
17 
18 #include "lmstruct.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /* Levenberg-Marquardt minimization. */
25 void lmmin( int n_par, double *par, int m_dat, const void *data,
26             void (*evaluate) (const double *par, int m_dat, const void *data,
27                               double *fvec, int *userbreak),
28             const lm_control_struct *control, lm_status_struct *status );
29 /*
30  *   This routine contains the core algorithm of our library.
31  *
32  *   It minimizes the sum of the squares of m nonlinear functions
33  *   in n variables by a modified Levenberg-Marquardt algorithm.
34  *   The function evaluation is done by the user-provided routine 'evaluate'.
35  *   The Jacobian is then calculated by a forward-difference approximation.
36  *
37  *   Parameters:
38  *
39  *      n is the number of variables (INPUT, positive integer).
40  *
41  *      x is the solution vector (INPUT/OUTPUT, array of length n).
42  *        On input it must be set to an estimated solution.
43  *        On output it yields the final estimate of the solution.
44  *
45  *      m is the number of functions to be minimized (INPUT, positive integer).
46  *        It must fulfill m>=n.
47  *
48  *      data is a pointer that is ignored by lmmin; it is however forwarded
49  *        to the user-supplied functions evaluate and printout.
50  *        In a typical application, it contains experimental data to be fitted.
51  *
52  *      evaluate is a user-supplied function that calculates the m functions.
53  *        Parameters:
54  *          n, x, m, data as above.
55  *          fvec is an array of length m; on OUTPUT, it must contain the
56  *            m function values for the parameter vector x.
57  *          userbreak is an integer pointer. When *userbreak is set to a
58  *            nonzero value, lmmin will terminate.
59  *
60  *      control contains INPUT variables that control the fit algorithm,
61  *        as declared and explained in lmstruct.h
62  *
63  *      status contains OUTPUT variables that inform about the fit result,
64  *        as declared and explained in lmstruct.h
65  */
66 
67 /* Refined calculation of Eucledian norm. */
68 double lm_enorm( int, const double * );
69 
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif /* LMMIN_H */
75