|
|
◆ lmdif1()
| void lmdif1 |
( |
void(*)(int, int, double *, double *, int *) |
fcn, |
|
|
int |
m, |
|
|
int |
n, |
|
|
double |
x[], |
|
|
double |
fvec[], |
|
|
double |
tol, |
|
|
double |
work[], |
|
|
int |
lwork, |
|
|
int |
iwork[], |
|
|
int * |
info |
|
) |
| |
Nonlinear least squares approximation (Levenberg-Marquardt method) (Jacobian not required) (simple driver)
- Purpose
- lmdif1 minimizes the sum of the squares of m nonlinear functions in n variables by a modification of the Levenberg-Marquardt algorithm.
minimize the sum of fi(x1, x2, ..., xn)^2 (sum for i = 1 to m)
The user must provide a subroutine which calculates the function values. Since the Jacobian is calculated by finite difference approximation within the routine, the user is not required to calculate the Jacobian.
lmdif1 is equivalent to using lmdif with setting ftol = tol, xtol = tol, gtol = 0, maxfev = 100*(n+1), epsfcn = 0, mode = 1, factor = 100 and nprint = 0.
- Parameters
-
| [in] | fcn | User supplied subroutine which calculates the functions fi(x) defined as follows. void fcn(int m, int n, double x[], double fvec[], int *iflag)
{
If iflag = 1 or iflag = 2:
Calculate the function values fi(x) at x[] and return in fvec[i-1] (i = 1 to m). Other variables should not be changed.
}
The value of iflag should not be changed unless the user wants to terminate the execution. In this case, set iflag to a negative integer. |
| [in] | m | Number of functions. (m > 0) |
| [in] | n | Number of variables. (0 < n <= m) |
| [in,out] | x[] | Array x[lx] (lx >= n)
[in] An initial estimate of the solution vector.
[out] The obtained solution vector. |
| [out] | fvec[] | Array fvec[lfvec] (lfvec >= m)
The function values evaluated at the solution vector x[]. |
| [in] | tol | Relative error desired in the sum of squares and the approximate solution. (tol >= 0) |
| [out] | work[] | Array work[lwork]
Work area.
On return with info = 0, sub-code is set to work[0].
= 1: Both actual and predicted relative reductions in the sum of squares are at most tol.
= 2: Relative error between two consecutive iterates is at most tol.
= 3: Both of above are satisfied. |
| [in] | lwork | The length of work[]. (lwork >= n*(m + 6) + 2*m) |
| [out] | iwork[] | Array iwork[liwork] (liwork >= n)
Work area. |
| [out] | info | = 0: Successful exit (sub-code is set to work[0])
= -2: The argument m had an illegal value (m < n)
= -3: The argument n had an illegal value (n < 1)
= -6: The argument tol had an illegal value (tol < 0)
= -8: The argument lwork had an illegal value (lwork too small)
= 1: Number of calls to fcn with iflag = 1 or 2 has reached maxfev
= 2: tol is too small. No further reduction in the sum of squares is possible
= 3: tol is too small. No further improvement in the approximate solution x is possible
= 4: gtol is too small. fvec is orthogonal to the columns of the Jacobian to machine precision
= 5: User imposed termination (returned from fcn with iflag < 0) |
- Reference
- netlib/minpack
|