apprgrdn

Purpose

Gradient approximation by the finite differences.

Usage

Matlab:
g = apprgrdn ( x,f,fun,deltax,obj)

FORTRAN:
call apprgrdn (n,g,x,f,fun,deltax,obj)

C:
apprgrdn (n,g,x,f,fun,deltax,obj);

Description

The routine performs the finite difference approximation of the gradient g at a point x. Normally, it calculates the forward differences (the argument deltax must provide the signed relative stepsizes at an entry to the routine). If the argument obj equals 1 (.true.), the routine calculates the central differences for the coordinates of x that have small (<1) absolute values. It is assumed that the function value f is calculated at a point x before a call to the routine.

Arguments:
 n is the space dimension (FORTRAN and C specific) Type: FORTRAN: integer C: unsigned short g is the approximated gradient vector returned by the routine. Type: FORTRAN: double precision C: double x is the current point in the n-dimensional space. Type: FORTRAN: double precision C: double f is the function value at a point (must be evaluated before a call to the routine). Type: FORTRAN: double precision C: double fun provides the entry to the function/subroutine that calculates the objective/constraint function value f at a point x. See synopsis in the language specific description section for the routine solvopt. deltax is an n-element array of the relative step sizes. The sign of an element points to the direction along the axis for making a step. Type: FORTRAN: double precision C: double obj is a flag which allows (if 1 or .true.) or not (if 0 or .false.) calculating of central differences. Type: FORTRAN: logical C: unsigned short

Calls

user-supplied function/subroutine <fun> or <func> (see description of solvopt).