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