XLPack 7.0
XLPack Numerical Library (C API) Reference Manual
Loading...
Searching...
No Matches

◆ lmdif1_r()

void lmdif1_r ( int  m,
int  n,
double  x[],
double  fvec[],
double  tol,
double  work[],
int  lwork,
int  iwork[],
int *  info,
double  xx[],
double  yy[],
int *  irev 
)

Nonlinear least squares approximation (Levenberg-Marquardt method) (Jacobian not required) (simple driver) (reverse communication version)

Purpose
lmdif1_r 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 the calculated function values according to irev. Since the Jacobian is calculated by finite difference approximation within the routine, the user is not required to calculate the Jacobian.

lmdif1_r is equivalent to using lmdif_r with setting ftol = tol, xtol = tol, gtol = 0, maxfev = 100*(n+1), epsfcn = 0, mode = 1, factor = 100 and nprint = 0.
Parameters
[in]mNumber of functions. (m > 0)
[in]nNumber 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]tolRelative 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]lworkThe length of work[] (lwork >= n*(m + 5) + m)
[out]iwork[]Array iwork[liwork] (liwork >= n)
Work area
[out]info= 0: Successful exit (sub-code is set to work[0])
= -1: The argument m had an illegal value (m < n)
= -2: The argument n had an illegal value (n < 1)
= -5: The argument tol had an illegal value (tol < 0)
= -7: The argument lwork had an illegal value (lwork too small)
= 1: Number of function evaluations with irev = 1 to 3 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
[out]xx[]Array xx[lxx] (lxx >= n)
When returned with irev = 1 to 3, xx[] contains the abscissa where the function value should be evaluated and given in the next call.
[in]yy[]Array yy[lyy] (lyy >= m)
When returned with irev = 1 to 3, the function value fi(xx[]) (i = 1 to m) should be given in yy[] in the next call.
[in,out]irevControl variable for reverse communication.
[in] Before first call, irev should be initialized to zero. On succeeding calls, irev should not be altered.
[out] If irev is not zero, complete the following process and call this routine again.
= 0: Computation finished. See return code in info.
= 1 to 3: User should set the function values at xx[] in yy[]. Do not alter any variables other than yy[].
Reference
netlib/minpack