|
|
◆ lmder()
| void lmder |
( |
void(*)(int, int, double *, double *, int, double *, int *) |
fcn, |
|
|
int |
m, |
|
|
int |
n, |
|
|
double |
x[], |
|
|
double |
fvec[], |
|
|
int |
ldfjac, |
|
|
double |
fjac[], |
|
|
double |
ftol, |
|
|
double |
xtol, |
|
|
double |
gtol, |
|
|
int |
maxfev, |
|
|
double |
diag[], |
|
|
int |
mode, |
|
|
double |
factor, |
|
|
int |
nprint, |
|
|
int * |
nfev, |
|
|
int * |
njev, |
|
|
int |
ipvt[], |
|
|
double |
work[], |
|
|
int |
lwork, |
|
|
int * |
info |
|
) |
| |
Nonlinear least squares approximation by Levenberg-Marquardt method
- Purpose
- lmder 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 and the Jacobian.
- Parameters
-
| [in] | fcn | User supplied subroutine which calculates the functions fi(x) and the Jacobian defined as follows. void fcn(int m, int n, double x[], double fvec[], int ldfjac, double fjac[][ldfjac], int *iflag)
{
If iflag = 1:
Calculate the function values fi(x) at x[] and return in fvec[i-1] (i = 1 to m). Other variables should not be changed.
If iflag = 2:
Calculate the Jacobian matrix (dfi/dxj) and return in fjac[] (i = 1 to m, j = 1 to n). Other variables should not be changed.
If iflag = 0:
If nprint is set to positive value, fcn is called every nprint iterations with iflag = 0 for printing intermediate result x[] and fvec[]. Any 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] | ldfjac | Leading dimension of the two dimensional array fjac[][]. (ldfjac >= m) |
| [out] | fjac[][] | Array fjac[lfjac][ldfjac] (lfjac >= n)
The upper n x n submatrix contains an upper triangular matrix R with diagonal elements of nonincreasing magnitude such that
P^T * (J^T * J)*P = R^T * R
where P is a permutation matrix and J is the final calculated Jacobian. |
| [in] | ftol | Relative error desired in the sum of squares. Termination occurs when both the actual and predicted relative reductions in the sum of squares are at most ftol. (ftol >= 0) |
| [in] | xtol | Relative error desired in the approximate solution. Termination occurs when the relative error between two consecutive iterates is at most xtol. (xtol >= 0) |
| [in] | gtol | Orthogonality desired between the function vector and the columns of the Jacobian. Termination occurs when the cosine of the angle between fvec[] and any column of the jacobian is at most gtol in absolute value. (gtol >= 0) |
| [in] | maxfev | Termination occurs when the number of calls to fcn with iflag = 1 or 2 has reached this value. (maxfev > 0) |
| [in,out] | diag[] | Array diag[ldiag] (ldiag >= n)
[in] If mode = 2, diag must contain positive entries that serve as multiplicative scale factors for the variables. (diag[i] > 0)
[out] If mode = 1, diag[] is set by the subroutine. |
| [in] | mode | = 1: The variables will be automatically scaled by the subroutine.
= 2: The scaling is specified by the input diag[].
(For other values, mode = 1 is assumed.) |
| [in] | factor | Used in determining the initial step bound. This bound is set to the product of factor and the Euclidean norm of diag*x if nonzero, or else to factor itself. In most cases factor should lie in the interval (0.1, 100). 100 is a generally recommended value. (factor > 0) |
| [in] | nprint | > 0: fcn is called with iflag = 0 at the beginning of the first iteration and every nprint iterations thereafter and at the end of last iteration for printing intermediate result.
<= 0: No special calls of fcn for printing intermediate results are made. |
| [out] | nfev | Number of function evaluations (number of calls to fcn with iflag = 1). |
| [out] | njev | Number of Jacobian evaluations (number of calls to fcn with iflag = 2). |
| [out] | ipvt[] | Array ipvt[lipvt] (lipvt >= n)
The pivot indices that define the permutation matrix P. |
| [out] | work[] | Array work[lwork]
Work array.
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 ftol.
= 2: Relative error between two consecutive iterates is at most xtol.
= 3: Both of above are satisfied.
= 4: The cosine of the angle between fvec and any column of the Jacobian is at most gtol in absolute value. |
| [in] | lwork | The length of work[]. (lwork >= 5*n + 2*m) |
| [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 <= 0)
= -6: The argument ldfjac had an illegal value (ldfjac < m)
= -8: The argument ftol had an illegal value (ftol < 0)
= -9: The argument xtol had an illegal value (xtol < 0)
= -10: The argument gtol had an illegal value (gtol < 0)
= -11: The argument maxfev had an illegal value (maxfev <= 0)
= -12: The argument diag had an illegal value (diag[i] <= 0 when mode = 2)
= -14: The argument factor had an illegal value (factor <= 0)
= -20: The argument lwork had an illegal value (lwork too small)
= 1: Number of calls to fcn with iflag=1 has reached maxfev
= 2: ftol is too small. No further reduction in the sum of squares is possible
= 3: xtol 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
|