|
|
◆ hybrd()
| void hybrd |
( |
void(*)(int, double *, double *, int *) |
fcn, |
|
|
int |
n, |
|
|
double |
x[], |
|
|
double |
fvec[], |
|
|
double |
xtol, |
|
|
int |
maxfev, |
|
|
int |
ml, |
|
|
int |
mu, |
|
|
double |
epsfcn, |
|
|
double |
diag[], |
|
|
int |
mode, |
|
|
double |
factor, |
|
|
int |
nprint, |
|
|
int * |
nfev, |
|
|
double |
work[], |
|
|
int |
lwork, |
|
|
int * |
info |
|
) |
| |
Solution of a system of nonlinear equations by Powell hybrid method (Jacobian not required)
- Purpose
- hybrd finds a zero of a system of n nonlinear functions in n variables
fi(x1, x2, ..., xn) = 0 (i = 1 to n)
by a modification of the Powell hybrid method.
The user must provide a subroutine which calculates the functions. Since the Jacobian is calculated by a forward difference approximation within the routine, the user is not required to provide the Jacobian.
- Parameters
-
| [in] | fcn | User supplied subroutine which calculates the functions fi(x) defined as follows. void fcn(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] (i = 0 to n-1). 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 outputting 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] | n | Number of functions and variables. (n > 0) |
| [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 >= n)
The function values evaluated at the solution vector x[]. |
| [in] | xtol | Target relative tolerance. Termination occurs when the relative error between two consecutive iterations is at most xtol. (xtol >= 0) |
| [in] | maxfev | Termination occurs when the number of calls to fcn with iflag = 1 or 2 has reached this value. (maxfev > 0) |
| [in] | ml | Number of sub-diagonals within the band of the Jacobian matrix (ml >= 0). If the Jacobian is not banded, set ml to at least n - 1. |
| [in] | mu | Number of super-diagonals within the band of the Jacobian matrix (mu >= 0). If the Jacobian is not banded, set mu to at least n - 1. |
| [in] | epsfcn | Used in determining a suitable step length for the forward-difference approximation. This approximation assumes that the relative errors in the functions are of the order of epsfcn. If epsfcn is less than the machine precision, it is assumed that the relative errors in the functions are of the order of the machine precision. |
| [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 or 2). |
| [out] | work[] | Array work[lwork]
Work array. |
| [in] | lwork | The length of work[]. (lwork >= n*(3*n + 15)/2) |
| [out] | info | = 0: Successful exit (relative error between two consecutive iterates is at most xtol)
= -2: The argument n had an illegal value (n < 1)
= -5: The argument xtol had an illegal value (xtol < 0)
= -6: The argument maxfev had an illegal value (maxfev <= 0)
= -7: The argument ml had an illegal value (ml < 0)
= -8: The argument mu had an illegal value (mu < 0)
= -10: The argument diag had an illegal value (diag[i] <= 0 when mode = 2)
= -12: The argument factor had an illegal value (factor <= 0)
= -16: 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: xtol is too small. No further improvement in the approximate solution x is possible
= 3: Iteration is not making good progress, as measured by the improvement from the last five Jacobian evaluations
= 4: Iteration is not making good progress, as measured by the improvement from the last ten iterations
= 5: User imposed termination (returned from fcn with iflag < 0) |
- Reference
- netlib/minpack
|