2
SUBROUTINE DFDJC1 (FCN, N, X, FVEC, FJAC, LDFJAC, IFLAG, ML, MU,
4
C***BEGIN PROLOGUE DFDJC1
6
C***PURPOSE Subsidiary to DNSQ and DNSQE
8
C***TYPE DOUBLE PRECISION (FDJAC1-S, DFDJC1-D)
12
C This subroutine computes a forward-difference approximation
13
C to the N by N Jacobian matrix associated with a specified
14
C problem of N functions in N variables. If the Jacobian has
15
C a banded form, then function evaluations are saved by only
16
C approximating the nonzero terms.
18
C The subroutine statement is
20
C SUBROUTINE DFDJC1(FCN,N,X,FVEC,FJAC,LDFJAC,IFLAG,ML,MU,EPSFCN,
25
C FCN is the name of the user-supplied subroutine which
26
C calculates the functions. FCN must be declared
27
C in an EXTERNAL statement in the user calling
28
C program, and should be written as follows.
30
C SUBROUTINE FCN(N,X,FVEC,IFLAG)
32
C DOUBLE PRECISION X(N),FVEC(N)
34
C Calculate the functions at X and
35
C return this vector in FVEC.
39
C The value of IFLAG should not be changed by FCN unless
40
C the user wants to terminate execution of DFDJC1.
41
C In this case set IFLAG to a negative integer.
43
C N is a positive integer input variable set to the number
44
C of functions and variables.
46
C X is an input array of length N.
48
C FVEC is an input array of length N which must contain the
49
C functions evaluated at X.
51
C FJAC is an output N by N array which contains the
52
C approximation to the Jacobian matrix evaluated at X.
54
C LDFJAC is a positive integer input variable not less than N
55
C which specifies the leading dimension of the array FJAC.
57
C IFLAG is an integer variable which can be used to terminate
58
C the execution of DFDJC1. See description of FCN.
60
C ML is a nonnegative integer input variable which specifies
61
C the number of subdiagonals within the band of the
62
C Jacobian matrix. If the Jacobian is not banded, set
63
C ML to at least N - 1.
65
C EPSFCN is an input variable used in determining a suitable
66
C step length for the forward-difference approximation. This
67
C approximation assumes that the relative errors in the
68
C functions are of the order of EPSFCN. If EPSFCN is less
69
C than the machine precision, it is assumed that the relative
70
C errors in the functions are of the order of the machine
73
C MU is a nonnegative integer input variable which specifies
74
C the number of superdiagonals within the band of the
75
C Jacobian matrix. If the Jacobian is not banded, set
76
C MU to at least N - 1.
78
C WA1 and WA2 are work arrays of length N. If ML + MU + 1 is at
79
C least N, then the Jacobian is considered dense, and WA2 is
82
C***SEE ALSO DNSQ, DNSQE
83
C***ROUTINES CALLED D1MACH
84
C***REVISION HISTORY (YYMMDD)
86
C 890531 Changed all specific intrinsics to generic. (WRB)
87
C 890831 Modified array declarations. (WRB)
88
C 891214 Prologue converted to Version 4.0 format. (BAB)
89
C 900326 Removed duplicate information from DESCRIPTION section.
91
C 900328 Added TYPE section. (WRB)
92
C***END PROLOGUE DFDJC1
93
DOUBLE PRECISION D1MACH
94
INTEGER I, IFLAG, J, K, LDFJAC, ML, MSUM, MU, N
95
DOUBLE PRECISION EPS, EPSFCN, EPSMCH, FJAC(LDFJAC,*),
96
1 FVEC(*), H, TEMP, WA1(*), WA2(*), X(*), ZERO
100
C EPSMCH IS THE MACHINE PRECISION.
102
C***FIRST EXECUTABLE STATEMENT DFDJC1
105
EPS = SQRT(MAX(EPSFCN,EPSMCH))
107
IF (MSUM .LT. N) GO TO 40
109
C COMPUTATION OF DENSE APPROXIMATE JACOBIAN.
114
IF (H .EQ. ZERO) H = EPS
116
CALL FCN(N,X,WA1,IFLAG)
117
IF (IFLAG .LT. 0) GO TO 30
120
FJAC(I,J) = (WA1(I) - FVEC(I))/H
127
C COMPUTATION OF BANDED APPROXIMATE JACOBIAN.
133
IF (H .EQ. ZERO) H = EPS
136
CALL FCN(N,X,WA1,IFLAG)
137
IF (IFLAG .LT. 0) GO TO 100
141
IF (H .EQ. ZERO) H = EPS
144
IF (I .GE. J - MU .AND. I .LE. J + ML)
145
1 FJAC(I,J) = (WA1(I) - FVEC(I))/H
153
C LAST CARD OF SUBROUTINE DFDJC1.