c05zd checks the user-supplied gradients of a set of nonlinear functions in several variables, for consistency with the functions themselves. The method must be called twice.

Syntax

C#
public static void c05zd(
	int mode,
	int m,
	int n,
	double[] x,
	double[] fvec,
	double[,] fjac,
	double[] xp,
	double[] fvecp,
	double[] err,
	out int ifail
)
Visual Basic
Public Shared Sub c05zd ( _
	mode As Integer, _
	m As Integer, _
	n As Integer, _
	x As Double(), _
	fvec As Double(), _
	fjac As Double(,), _
	xp As Double(), _
	fvecp As Double(), _
	err As Double(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void c05zd(
	int mode, 
	int m, 
	int n, 
	array<double>^ x, 
	array<double>^ fvec, 
	array<double,2>^ fjac, 
	array<double>^ xp, 
	array<double>^ fvecp, 
	array<double>^ err, 
	[OutAttribute] int% ifail
)
F#
static member c05zd : 
        mode : int * 
        m : int * 
        n : int * 
        x : float[] * 
        fvec : float[] * 
        fjac : float[,] * 
        xp : float[] * 
        fvecp : float[] * 
        err : float[] * 
        ifail : int byref -> unit 

Parameters

mode
Type: System..::..Int32
On entry: the value 1 on the first call and the value 2 on the second call of c05zd.
Constraint: mode=1 or 2.
m
Type: System..::..Int32
On entry: m, the number of functions.
Constraint: m1.
n
Type: System..::..Int32
On entry: n, the number of variables. For use with c05rbc05rc and c05rd, m=n.
Constraint: n1.
x
Type: array<System..::..Double>[]()[][]
An array of size [n]
On entry: the components of a point x, at which the consistency check is to be made. (See [Accuracy].)
fvec
Type: array<System..::..Double>[]()[][]
An array of size [m]
On entry: if mode=2, fvec must contain the value of the functions evaluated at x. If mode=1, fvec is not referenced.
fjac
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [m, n]
On entry: if mode=2, fjac must contain the value of fixj at the point x, for i=1,2,,m and j=1,2,,n. If mode=1, fjac is not referenced.
xp
Type: array<System..::..Double>[]()[][]
An array of size [n]
On exit: if mode=1, xp is set to a point neighbouring x. If mode=2, xp is undefined.
fvecp
Type: array<System..::..Double>[]()[][]
An array of size [m]
On entry: if mode=2, fvecp must contain the value of the functions evaluated at xp (as output by a preceding call to c05zd with mode=1). If mode=1, fvecp is not referenced.
err
Type: array<System..::..Double>[]()[][]
An array of size [m]
On exit: if mode=2, err contains measures of correctness of the respective gradients. If mode=1, err is undefined. If there is no loss of significance (see [Accuracy]), then if err[i-1] is 1.0 the ith user-supplied gradient fixj, for j=1,2,,n is correct, whilst if err[i-1] is 0.0 the ith gradient is incorrect. For values of err[i-1] between 0.0 and 1.0 the categorisation is less certain. In general, a value of err[i-1]>0.5 indicates that the ith gradient is probably correct.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

c05zd is based on the MINPACK routine CHKDER (see Moré et al. (1980)). It checks the ith gradient for consistency with the ith function by computing a forward-difference approximation along a suitably chosen direction and comparing this approximation with the user-supplied gradient along the same direction. The principal characteristic of c05zd is its invariance under changes in scale of the variables or functions.

References

Moré J J, Garbow B S and Hillstrom K E (1980) User guide for MINPACK-1 Technical Report ANL-80-74 Argonne National Laboratory

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry, mode=value.
Constraint: mode=1 or 2.
ifail=2
On entry, m=value.
Constraint: m1.
ifail=3
On entry, n=value.
Constraint: n1.
ifail=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

c05zd 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. The relative differences between corresponding elements of fvecp and fvec should be at least two orders of magnitude greater than the machine precision returned by x02aj.

Parallelism and Performance

None.

Further Comments

The time required by c05zd increases with m and n.

Example

This example checks the Jacobian matrix for a problem with 15 functions of 3 variables (sometimes referred to as the Bard problem).

Example program (C#): c05zde.cs

Example program results: c05zde.r

See Also