xref: /aosp_15_r20/external/lmfit/lib/lmstruct.h (revision 5ddc57e5d924f146ab5fd87df586563e2270da38)
1*5ddc57e5SXin Li /*
2*5ddc57e5SXin Li  * Library:   lmfit (Levenberg-Marquardt least squares fitting)
3*5ddc57e5SXin Li  *
4*5ddc57e5SXin Li  * File:      lmstruct.h
5*5ddc57e5SXin Li  *
6*5ddc57e5SXin Li  * Contents:  Declarations of parameter records, used in lmmin.h and lmcurve.h
7*5ddc57e5SXin Li  *
8*5ddc57e5SXin Li  * Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013)
9*5ddc57e5SXin Li  *
10*5ddc57e5SXin Li  * License:   see ../COPYING (FreeBSD)
11*5ddc57e5SXin Li  *
12*5ddc57e5SXin Li  * Homepage:  apps.jcns.fz-juelich.de/lmfit
13*5ddc57e5SXin Li  */
14*5ddc57e5SXin Li 
15*5ddc57e5SXin Li #ifndef LMSTRUCT_H
16*5ddc57e5SXin Li #define LMSTRUCT_H
17*5ddc57e5SXin Li #undef __BEGIN_DECLS
18*5ddc57e5SXin Li #undef __END_DECLS
19*5ddc57e5SXin Li #ifdef __cplusplus
20*5ddc57e5SXin Li #define __BEGIN_DECLS extern "C" {
21*5ddc57e5SXin Li #define __END_DECLS }
22*5ddc57e5SXin Li #else
23*5ddc57e5SXin Li #define __BEGIN_DECLS /* empty */
24*5ddc57e5SXin Li #define __END_DECLS   /* empty */
25*5ddc57e5SXin Li #endif
26*5ddc57e5SXin Li __BEGIN_DECLS
27*5ddc57e5SXin Li 
28*5ddc57e5SXin Li #include <stdio.h>
29*5ddc57e5SXin Li 
30*5ddc57e5SXin Li /* Collection of input parameters for fit control. */
31*5ddc57e5SXin Li typedef struct {
32*5ddc57e5SXin Li     double ftol;      /* Relative error desired in the sum of squares.
33*5ddc57e5SXin Li                          Termination occurs when both the actual and
34*5ddc57e5SXin Li                          predicted relative reductions in the sum of squares
35*5ddc57e5SXin Li                          are at most ftol. */
36*5ddc57e5SXin Li     double xtol;      /* Relative error between last two approximations.
37*5ddc57e5SXin Li                          Termination occurs when the relative error between
38*5ddc57e5SXin Li                          two consecutive iterates is at most xtol. */
39*5ddc57e5SXin Li     double gtol;      /* Orthogonality desired between fvec and its derivs.
40*5ddc57e5SXin Li                          Termination occurs when the cosine of the angle
41*5ddc57e5SXin Li                          between fvec and any column of the Jacobian is at
42*5ddc57e5SXin Li                          most gtol in absolute value. */
43*5ddc57e5SXin Li     double epsilon;   /* Step used to calculate the Jacobian, should be
44*5ddc57e5SXin Li                          slightly larger than the relative error in the
45*5ddc57e5SXin Li                          user-supplied functions. */
46*5ddc57e5SXin Li     double stepbound; /* Used in determining the initial step bound. This
47*5ddc57e5SXin Li                          bound is set to the product of stepbound and the
48*5ddc57e5SXin Li                          Euclidean norm of diag*x if nonzero, or else to
49*5ddc57e5SXin Li                          stepbound itself. In most cases stepbound should lie
50*5ddc57e5SXin Li                          in the interval (0.1,100.0). Generally, the value
51*5ddc57e5SXin Li                          100.0 is recommended. */
52*5ddc57e5SXin Li     int patience;     /* Used to set the maximum number of function evaluations
53*5ddc57e5SXin Li                          to patience*(number_of_parameters+1). */
54*5ddc57e5SXin Li     int scale_diag;   /* If 1, the variables will be rescaled internally.
55*5ddc57e5SXin Li                          Recommended value is 1. */
56*5ddc57e5SXin Li     FILE* msgfile;    /* Progress messages will be written to this file. */
57*5ddc57e5SXin Li     int verbosity;    /* OR'ed: 1: print some messages; 2: print Jacobian. */
58*5ddc57e5SXin Li     int n_maxpri;     /* -1, or max number of parameters to print. */
59*5ddc57e5SXin Li     int m_maxpri;     /* -1, or max number of residuals to print. */
60*5ddc57e5SXin Li } lm_control_struct;
61*5ddc57e5SXin Li 
62*5ddc57e5SXin Li /* Collection of output parameters for status info. */
63*5ddc57e5SXin Li typedef struct {
64*5ddc57e5SXin Li     double fnorm;  /* norm of the residue vector fvec. */
65*5ddc57e5SXin Li     int nfev;      /* actual number of iterations. */
66*5ddc57e5SXin Li     int outcome;   /* Status indicator. Nonnegative values are used as index
67*5ddc57e5SXin Li                       for the message text lm_infmsg, set in lmmin.c. */
68*5ddc57e5SXin Li     int userbreak; /* Set when function evaluation requests termination. */
69*5ddc57e5SXin Li } lm_status_struct;
70*5ddc57e5SXin Li 
71*5ddc57e5SXin Li /* Preset (and recommended) control parameter settings. */
72*5ddc57e5SXin Li extern const lm_control_struct lm_control_double;
73*5ddc57e5SXin Li extern const lm_control_struct lm_control_float;
74*5ddc57e5SXin Li 
75*5ddc57e5SXin Li /* Preset message texts. */
76*5ddc57e5SXin Li 
77*5ddc57e5SXin Li extern const char* lm_infmsg[];
78*5ddc57e5SXin Li extern const char* lm_shortmsg[];
79*5ddc57e5SXin Li 
80*5ddc57e5SXin Li __END_DECLS
81*5ddc57e5SXin Li #endif /* LMSTRUCT_H */
82