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