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 #undef __BEGIN_DECLS 18 #undef __END_DECLS 19 #ifdef __cplusplus 20 #define __BEGIN_DECLS extern "C" { 21 #define __END_DECLS } 22 #else 23 #define __BEGIN_DECLS /* empty */ 24 #define __END_DECLS /* empty */ 25 #endif 26 27 #include "lmstruct.h" 28 29 __BEGIN_DECLS 30 31 /* Levenberg-Marquardt minimization. */ 32 void lmmin(const int n_par, double* par, const int m_dat, const void* data, 33 void (*evaluate)(const double* par, const int m_dat, 34 const void* data, double* fvec, int* userbreak), 35 const lm_control_struct* control, lm_status_struct* status); 36 /* 37 * This routine contains the core algorithm of our library. 38 * 39 * It minimizes the sum of the squares of m nonlinear functions 40 * in n variables by a modified Levenberg-Marquardt algorithm. 41 * The function evaluation is done by the user-provided routine 'evaluate'. 42 * The Jacobian is then calculated by a forward-difference approximation. 43 * 44 * Parameters: 45 * 46 * n is the number of variables (INPUT, positive integer). 47 * 48 * x is the solution vector (INPUT/OUTPUT, array of length n). 49 * On input it must be set to an estimated solution. 50 * On output it yields the final estimate of the solution. 51 * 52 * m is the number of functions to be minimized (INPUT, positive integer). 53 * It must fulfill m>=n. 54 * 55 * data is a pointer that is ignored by lmmin; it is however forwarded 56 * to the user-supplied functions evaluate and printout. 57 * In a typical application, it contains experimental data to be fitted. 58 * 59 * evaluate is a user-supplied function that calculates the m functions. 60 * Parameters: 61 * n, x, m, data as above. 62 * fvec is an array of length m; on OUTPUT, it must contain the 63 * m function values for the parameter vector x. 64 * userbreak is an integer pointer. When *userbreak is set to a 65 * nonzero value, lmmin will terminate. 66 * 67 * control contains INPUT variables that control the fit algorithm, 68 * as declared and explained in lmstruct.h 69 * 70 * status contains OUTPUT variables that inform about the fit result, 71 * as declared and explained in lmstruct.h 72 */ 73 74 /* Refined calculation of Eucledian norm. */ 75 double lm_enorm(int, const double*); 76 77 __END_DECLS 78 #endif /* LMMIN_H */ 79