2 SUBROUTINE FDJAC3 (FCN, M, N, X, FVEC, FJAC, LDFJAC, IFLAG,
4 C***BEGIN PROLOGUE FDJAC3
6 C***PURPOSE Subsidiary to SNLS1 and SNLS1E
8 C***TYPE SINGLE PRECISION (FDJAC3-S, DFDJC3-D)
12 C This subroutine computes a forward-difference approximation
13 C to the M by N Jacobian matrix associated with a specified
14 C problem of M functions in N variables.
16 C The subroutine statement is
18 C SUBROUTINE FDJAC3(FCN,M,N,X,FVEC,FJAC,LDFJAC,IFLAG,EPSFCN,WA)
22 C FCN is the name of the user-supplied subroutine which
23 C calculates the functions. FCN must be declared
24 C in an external statement in the user calling
25 C program, and should be written as follows.
27 C SUBROUTINE FCN(IFLAG,M,N,X,FVEC,FJAC,LDFJAC)
28 C INTEGER LDFJAC,M,N,IFLAG
29 C REAL X(N),FVEC(M),FJAC(LDFJAC,N)
31 C When IFLAG.EQ.1 calculate the functions at X and
32 C return this vector in FVEC.
37 C The value of IFLAG should not be changed by FCN unless
38 C the user wants to terminate execution of FDJAC3.
39 C In this case set IFLAG to a negative integer.
41 C M is a positive integer input variable set to the number
44 C N is a positive integer input variable set to the number
45 C of variables. N must not exceed M.
47 C X is an input array of length N.
49 C FVEC is an input array of length M which must contain the
50 C functions evaluated at X.
52 C FJAC is an output M by N array which contains the
53 C approximation to the Jacobian matrix evaluated at X.
55 C LDFJAC is a positive integer input variable not less than M
56 C which specifies the leading dimension of the array FJAC.
58 C IFLAG is an integer variable which can be used to terminate
59 C THE EXECUTION OF FDJAC3. See description of FCN.
61 C EPSFCN is an input variable used in determining a suitable
62 C step length for the forward-difference approximation. This
63 C approximation assumes that the relative errors in the
64 C functions are of the order of EPSFCN. If EPSFCN is less
65 C than the machine precision, it is assumed that the relative
66 C errors in the functions are of the order of the machine
69 C WA is a work array of length M.
71 C***SEE ALSO SNLS1, SNLS1E
72 C***ROUTINES CALLED R1MACH
73 C***REVISION HISTORY (YYMMDD)
75 C 890531 Changed all specific intrinsics to generic. (WRB)
76 C 890831 Modified array declarations. (WRB)
77 C 891214 Prologue converted to Version 4.0 format. (BAB)
78 C 900326 Removed duplicate information from DESCRIPTION section.
80 C 900328 Added TYPE section. (WRB)
81 C***END PROLOGUE FDJAC3
82 INTEGER M,N,LDFJAC,IFLAG
84 REAL X(*),FVEC(*),FJAC(LDFJAC,*),WA(*)
86 REAL EPS,EPSMCH,H,TEMP,ZERO
90 C***FIRST EXECUTABLE STATEMENT FDJAC3
93 EPS = SQRT(MAX(EPSFCN,EPSMCH))
94 C SET IFLAG=1 TO INDICATE THAT FUNCTION VALUES
95 C ARE TO BE RETURNED BY FCN.
100 IF (H .EQ. ZERO) H = EPS
102 CALL FCN(IFLAG,M,N,X,WA,FJAC,LDFJAC)
103 IF (IFLAG .LT. 0) GO TO 30
106 FJAC(I,J) = (WA(I) - FVEC(I))/H
112 C LAST CARD OF SUBROUTINE FDJAC3.