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

◆ chkder()

void chkder ( int  m,
int  n,
double  x[],
double  fvec[],
int  ldfjac,
double  fjac[],
double  xp[],
double  fvecp[],
int  mode,
double  err[],
int *  info 
)

Checks the computed gradients

Purpose
chkder checks the gradients of m nonlinear functions in n variables, evaluated at a point x, for consistency with the functions themselves. It can be used to check the user's subroutine for hybrj, hybrj1, and others.

The user must call chkder twice, first with mode = 1 and then with mode = 2.
mode = 1:
  On input, x must contain the point of evaluation.
  On output, xp is set to a neighboring point.
mode = 2:
  On input, fvec must contain the functions and the rows of fjac must contain the gradients of the respective functions each evaluated at x, and fvecp must contain the functions evaluated at xp.
  On output, err contains measures of correctness of the respective gradients.

The subroutine does not perform reliably if cancellation or rounding errors cause a severe loss of significance in the evaluation of a function. Therefore, none of the components of x should be unusually small (in particular, zero) or any other value which may cause loss of significance.
Parameters
[in]mNumber of functions. (m > 0)
[in]nNumber of variables. (n > 0)
[in]x[]Array x[lx] (lx >= n)
The point of evaluation.
[in]fvec[]Array fvec[lfvec] (lfvec >= m)
The function values evaluated at x (when mode = 2).
[in]ldfjacThe leading dimension of the array fjac[][]. (ldfjac >= m)
[in]fjac[][]Array fjac[lfjac][ldfjac] (lfjac >= n)
The Jacobian (∂fi/∂xj) values (i = 0 to m-1, j = 0 to n-1) evaluated at x (when mode = 2).
[out]xp[]Array x[lx] (lx >= n)
A neighboring point of x returned by the routine (when mode = 1).
[in]fvecp[]Array fvecp[lfvecp] (lfvecp >= m)
The function values evaluated at xp (when mode = 2).
[in]modeControl variable (mode = 1 or 2)
The user must call this routine twice as below.
  • First, after setting m, n, and x[], call with mode = 1, then xp[] is returned.
  • Second, after setting fvec[], fjac[], and fvecp[], call with mode = 2, then err[] contains measures of correctness of the respective gradients.
[out]err[]Array err[lerr] (lerr >= m)
Measures of correctness of the respective gradients (when mode = 2). (0 <= err[i] <= 1)
1 shows the gradients is correct, and 0 shows it is incorrect. For values between 0 and 1, the categorization is less certain. In general, a value of err[i] greater than 0.5 indicates that the i-th gradient is probably correct.
[out]info= 0: Successful exit
= -1: The argument m had an illegal value (m <= 0)
= -2: The argument n had an illegal value (n <= 0)
= -5: The argument ldjac had an illegal value (ldjac < m)
= -9: The argument mode had an illegal value (mode != 1 and mode != 2)
Reference
netlib/minpack