5 * Revision 1.1.1.1 1996/04/01 15:01:52 mclareni
10 #if defined(CERNLIB_DOUBLE)
11 SUBROUTINE DSNLEQ(N,X,F,FTOL,XTOL,MAXF,IPRT,INFO,SUB,W)
12 #include "gen/imp64.inc"
14 #if !defined(CERNLIB_DOUBLE)
15 SUBROUTINE RSNLEQ(N,X,F,FTOL,XTOL,MAXF,IPRT,INFO,SUB,W)
18 C Based on J.J. More and M.Y. Cosnard
20 C ALGORITHM 554 BRENTM, A Fortran Subroutine for the
21 C Numerical Solution of Systems of Nonlinear Equations [C5]
23 C ACM Trans. Math. Software 6 (1980) 240-251.
25 DIMENSION X(N),F(N),W(N,*),MPT(288)
28 PARAMETER (Z1 = 1, SCALE = 10, P05 = 5*Z1/100)
29 C**** EPS = SQRT(SMALLEST FP.NUMBER)
30 C EPS = 1 / SQRT( 16D0**13 )
31 #if !defined(CERNLIB_DOUBLE)
32 PARAMETER (EPS = 0.84293 69702 17878 97282 52636 392E-07)
34 #if defined(CERNLIB_IBM)
35 PARAMETER (EPS = 0.14901 16119 38476 562D-07)
37 #if defined(CERNLIB_VAX)
38 PARAMETER (EPS = 0.37252 90298 46191 40625D-08)
40 #if (defined(CERNLIB_UNIX))&&(defined(CERNLIB_DOUBLE))
41 PARAMETER (EPS = 0.14901 16119 38476 600D-07)
44 1/1* 1,1* 2,3* 3,3* 4,4* 5,4* 6,4* 7,4* 8,5* 9,5*10,5*11,5*12,
45 2 5*13,5*14,6*15,6*16,5*17,6*18,6*19,6*20,7*21,6*22,6*23,7*24,
46 3 6*25,7*26,6*27,7*28,7*29,7*30,7*31,7*32,7*33,7*34,7*35,7*36,
47 4 8*37,7*38,7*39,8*40,7*41,8*42,7*43,8*44,8*45,7*46,8*47,8*48/
50 IF(N .LE. 0 .OR. FTOL .LE. 0 .OR. XTOL .LE. 0) RETURN
52 C Find optimal MOPT for iterative refinement
59 TEMP=LOG(I+Z1)/(N+2*I+1)
78 10 XNORM=MAX(XNORM,ABS(X(I)))
80 IF(XNORM .EQ. 0) DELTA=SCALE
82 20 IF(IPRT .NE. 0) WRITE(6,'(1X,I5,D25.14)') (I,X(I),I=1,N)
89 C Compute step H for the divided difference which approximates
90 C the K-th row of the Jacobian matrix
100 C Enter a subiteration
104 CALL SUB(N,W(1,2),F,IFLAG)
108 IF(IFLAG .LT. 0) GO TO 230
109 FNORM=MAX(FNORM,ABS(FKY))
111 C Compute the K-th row of the Jacobian matrix
115 50 W(I,3)=W(I,2)+W(I,J+3)
116 CALL SUB(N,W(1,3),F,IFLAG)
120 IF(IFLAG .LT. 0) GO TO 230
124 C Compute the Householder transformation to reduce the K-th row
125 C of the Jacobian matrix to a multiple of the K-th unit vector
129 70 ETA=MAX(ETA,ABS(W(I,1)))
130 IF(ETA .EQ. 0) GO TO 150
135 80 SKNORM=SKNORM+W(I,1)**2
137 IF(W(K,1) .LT. 0) SKNORM=-SKNORM
140 C Apply the transformation
146 100 W(I,3)=W(I,3)+W(J,1)*W(I,J+3)
148 TEMP=W(J,1)/(SKNORM*W(K,1))
150 120 W(I,J+3)=W(I,J+3)-TEMP*W(I,3)
152 C Compute the subiterate
156 IF(H*ABS(TEMP) .GT. DELTA) TEMP=SIGN(DELTA/H,TEMP)
158 140 W(I,2)=W(I,2)+TEMP*W(I,K+3)
161 C Compute the norms of the iterate and correction vector
166 XNORM=MAX(XNORM,ABS(W(I,2)))
167 DIFIT=MAX(DIFIT,ABS(X(I)-W(I,2)))
170 C Update the bound on the correction vector
172 DELTA=MAX(DELTA,SCALE*XNORM)
174 C Determine the progress of the iteration
176 LCV=FNORM .LT. FNORM1 .AND. DIFIT .LT. DIFIT1 .AND. NSING .EQ. 0
181 IF(FNORM .LT. FNORM1 .OR. DIFIT .LT. DIFIT1) NIER7=0
182 IF(DIFIT .GT. EPS*XNORM) NIER8=0
184 C Tests for convergence
186 IF(FNORM .LE. FTOL) INFO=1
187 IF(DIFIT .LE. XTOL*XNORM .AND. LCV) INFO=2
188 IF(FNORM .LE. FTOL .AND. INFO .EQ. 2) INFO=3
189 IF(INFO .NE. 0) GO TO 230
191 C Tests for termination
193 IF(NUMF .GE. MAXF) INFO=4
194 IF(NSING .EQ. N) INFO=5
195 IF(NIER6 .EQ. 5) INFO=6
196 IF(NIER7 .EQ. 3) INFO=7
197 IF(NIER8 .EQ. 4) INFO=8
198 IF(INFO .NE. 0) GO TO 230
199 IF(.NOT.LCV .OR. DIFIT .GT. P05*XNORM) GO TO 20
201 C Iterative refinement (if the iteration is converging)
208 CALL SUB(N,W(1,2),F,IFLAG)
212 IF(IFLAG .LT. 0) GO TO 230
213 FNORM=MAX(FNORM,ABS(FKY))
215 C Iterative refinement is terminated if it does not give a
216 C reduction on residuals
218 IF(FNORM .GE. FNORM1) THEN
224 180 W(I,2)=W(I,2)+TEMP*W(I,K+3)
227 C Compute the norms of the iterate and correction vector
232 XNORM=MAX(XNORM,ABS(W(I,2)))
233 DIFIT=MAX(DIFIT,ABS(X(I)-W(I,2)))
236 C Stopping criteria for iterative refinement
238 IF(FNORM .LE. FTOL) INFO=1
239 IF(DIFIT .LE. XTOL*XNORM) INFO=2
240 IF(FNORM .LE. FTOL .AND. INFO .EQ. 2) INFO=3
241 IF(NUMF .GE. MAXF .AND. INFO .EQ. 0) INFO=4
242 IF(INFO .NE. 0) GO TO 230
246 230 IF(IFLAG .LT. 0) INFO=IFLAG