objfun must calculate the objective function Fx and (optionally) its gradient gx=Fx for a specified n-vector x.

Syntax

C#
public delegate void E04WD_OBJFUN(
	ref int mode,
	int n,
	double[] x,
	ref double objf,
	double[] grad,
	int nstate
)
Visual Basic
Public Delegate Sub E04WD_OBJFUN ( _
	ByRef mode As Integer, _
	n As Integer, _
	x As Double(), _
	ByRef objf As Double, _
	grad As Double(), _
	nstate As Integer _
)
Visual C++
public delegate void E04WD_OBJFUN(
	int% mode, 
	int n, 
	array<double>^ x, 
	double% objf, 
	array<double>^ grad, 
	int nstate
)
F#
type E04WD_OBJFUN = 
    delegate of 
        mode : int byref * 
        n : int * 
        x : float[] * 
        objf : float byref * 
        grad : float[] * 
        nstate : int -> unit

Parameters

mode
Type: System..::..Int32%
On entry: is set by e04wd to indicate which values must be assigned during each call of objfun. Only the following values need be assigned:
mode=0
objf.
mode=1
All available elements of grad.
mode=2
objf and all available elements of grad.
On exit: may be used to indicate that you are unable or unwilling to evaluate the objective function at the current x.
During the linesearch, the function is evaluated at points of the form x=xk+αpk after they have already been evaluated satisfactorily at xk. For any such x, if you set mode=-1, e04wd will reduce α and evaluate the functions again (closer to xk, where they are more likely to be defined).
If for some reason you wish to terminate the current problem, set mode<-1.
n
Type: System..::..Int32
On entry: n, the number of variables.
x
Type: array<System..::..Double>[]()[][]
On entry: x, the vector of variables at which the objective function and/or all available elements of its gradient are to be evaluated.
objf
Type: System..::..Double%
On exit: if mode=0 or 2, objf must be set to the value of the objective function at x.
grad
Type: array<System..::..Double>[]()[][]
On entry: the elements of grad are set to special values.
On exit: if mode=1 or 2, grad must return the available elements of the gradient evaluated at x, i.e., grad[i-1] contains the partial derivative Fxi.
nstate
Type: System..::..Int32
On entry: if nstate=1 then e04wd is calling objfun for the first time. This parameter setting allows you to save computation time if certain data must be read or calculated only once.

See Also