00001 SUBROUTINE DLARRF( N, D, L, LD, CLSTRT, CLEND,
00002 $ W, WGAP, WERR,
00003 $ SPDIAM, CLGAPL, CLGAPR, PIVMIN, SIGMA,
00004 $ DPLUS, LPLUS, WORK, INFO )
00005
00006
00007
00008
00009
00010
00011
00012 INTEGER CLSTRT, CLEND, INFO, N
00013 DOUBLE PRECISION CLGAPL, CLGAPR, PIVMIN, SIGMA, SPDIAM
00014
00015
00016 DOUBLE PRECISION D( * ), DPLUS( * ), L( * ), LD( * ),
00017 $ LPLUS( * ), W( * ), WGAP( * ), WERR( * ), WORK( * )
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109 DOUBLE PRECISION FOUR, MAXGROWTH1, MAXGROWTH2, ONE, QUART, TWO,
00110 $ ZERO
00111 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0, TWO = 2.0D0,
00112 $ FOUR = 4.0D0, QUART = 0.25D0,
00113 $ MAXGROWTH1 = 8.D0,
00114 $ MAXGROWTH2 = 8.D0 )
00115
00116
00117 LOGICAL DORRR1, FORCER, NOFAIL, SAWNAN1, SAWNAN2, TRYRRR1
00118 INTEGER I, INDX, KTRY, KTRYMAX, SLEFT, SRIGHT, SHIFT
00119 PARAMETER ( KTRYMAX = 1, SLEFT = 1, SRIGHT = 2 )
00120 DOUBLE PRECISION AVGAP, BESTSHIFT, CLWDTH, EPS, FACT, FAIL,
00121 $ FAIL2, GROWTHBOUND, LDELTA, LDMAX, LSIGMA,
00122 $ MAX1, MAX2, MINGAP, OLDP, PROD, RDELTA, RDMAX,
00123 $ RRR1, RRR2, RSIGMA, S, SMLGROWTH, TMP, ZNM2
00124
00125
00126 LOGICAL DISNAN
00127 DOUBLE PRECISION DLAMCH
00128 EXTERNAL DISNAN, DLAMCH
00129
00130
00131 EXTERNAL DCOPY
00132
00133
00134 INTRINSIC ABS
00135
00136
00137
00138 INFO = 0
00139 FACT = DBLE(2**KTRYMAX)
00140 EPS = DLAMCH( 'Precision' )
00141 SHIFT = 0
00142 FORCER = .FALSE.
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 NOFAIL = .TRUE.
00158
00159
00160
00161 CLWDTH = ABS(W(CLEND)-W(CLSTRT)) + WERR(CLEND) + WERR(CLSTRT)
00162 AVGAP = CLWDTH / DBLE(CLEND-CLSTRT)
00163 MINGAP = MIN(CLGAPL, CLGAPR)
00164
00165 LSIGMA = MIN(W( CLSTRT ),W( CLEND )) - WERR( CLSTRT )
00166 RSIGMA = MAX(W( CLSTRT ),W( CLEND )) + WERR( CLEND )
00167
00168
00169 LSIGMA = LSIGMA - ABS(LSIGMA)* FOUR * EPS
00170 RSIGMA = RSIGMA + ABS(RSIGMA)* FOUR * EPS
00171
00172
00173 LDMAX = QUART * MINGAP + TWO * PIVMIN
00174 RDMAX = QUART * MINGAP + TWO * PIVMIN
00175
00176 LDELTA = MAX(AVGAP,WGAP( CLSTRT ))/FACT
00177 RDELTA = MAX(AVGAP,WGAP( CLEND-1 ))/FACT
00178
00179
00180
00181 S = DLAMCH( 'S' )
00182 SMLGROWTH = ONE / S
00183 FAIL = DBLE(N-1)*MINGAP/(SPDIAM*EPS)
00184 FAIL2 = DBLE(N-1)*MINGAP/(SPDIAM*SQRT(EPS))
00185 BESTSHIFT = LSIGMA
00186
00187
00188 KTRY = 0
00189 GROWTHBOUND = MAXGROWTH1*SPDIAM
00190
00191 5 CONTINUE
00192 SAWNAN1 = .FALSE.
00193 SAWNAN2 = .FALSE.
00194
00195 LDELTA = MIN(LDMAX,LDELTA)
00196 RDELTA = MIN(RDMAX,RDELTA)
00197
00198
00199
00200
00201
00202 S = -LSIGMA
00203 DPLUS( 1 ) = D( 1 ) + S
00204 IF(ABS(DPLUS(1)).LT.PIVMIN) THEN
00205 DPLUS(1) = -PIVMIN
00206
00207
00208 SAWNAN1 = .TRUE.
00209 ENDIF
00210 MAX1 = ABS( DPLUS( 1 ) )
00211 DO 6 I = 1, N - 1
00212 LPLUS( I ) = LD( I ) / DPLUS( I )
00213 S = S*LPLUS( I )*L( I ) - LSIGMA
00214 DPLUS( I+1 ) = D( I+1 ) + S
00215 IF(ABS(DPLUS(I+1)).LT.PIVMIN) THEN
00216 DPLUS(I+1) = -PIVMIN
00217
00218
00219 SAWNAN1 = .TRUE.
00220 ENDIF
00221 MAX1 = MAX( MAX1,ABS(DPLUS(I+1)) )
00222 6 CONTINUE
00223 SAWNAN1 = SAWNAN1 .OR. DISNAN( MAX1 )
00224
00225 IF( FORCER .OR.
00226 $ (MAX1.LE.GROWTHBOUND .AND. .NOT.SAWNAN1 ) ) THEN
00227 SIGMA = LSIGMA
00228 SHIFT = SLEFT
00229 GOTO 100
00230 ENDIF
00231
00232
00233 S = -RSIGMA
00234 WORK( 1 ) = D( 1 ) + S
00235 IF(ABS(WORK(1)).LT.PIVMIN) THEN
00236 WORK(1) = -PIVMIN
00237
00238
00239 SAWNAN2 = .TRUE.
00240 ENDIF
00241 MAX2 = ABS( WORK( 1 ) )
00242 DO 7 I = 1, N - 1
00243 WORK( N+I ) = LD( I ) / WORK( I )
00244 S = S*WORK( N+I )*L( I ) - RSIGMA
00245 WORK( I+1 ) = D( I+1 ) + S
00246 IF(ABS(WORK(I+1)).LT.PIVMIN) THEN
00247 WORK(I+1) = -PIVMIN
00248
00249
00250 SAWNAN2 = .TRUE.
00251 ENDIF
00252 MAX2 = MAX( MAX2,ABS(WORK(I+1)) )
00253 7 CONTINUE
00254 SAWNAN2 = SAWNAN2 .OR. DISNAN( MAX2 )
00255
00256 IF( FORCER .OR.
00257 $ (MAX2.LE.GROWTHBOUND .AND. .NOT.SAWNAN2 ) ) THEN
00258 SIGMA = RSIGMA
00259 SHIFT = SRIGHT
00260 GOTO 100
00261 ENDIF
00262
00263
00264
00265 IF(SAWNAN1.AND.SAWNAN2) THEN
00266
00267 GOTO 50
00268 ELSE
00269 IF( .NOT.SAWNAN1 ) THEN
00270 INDX = 1
00271 IF(MAX1.LE.SMLGROWTH) THEN
00272 SMLGROWTH = MAX1
00273 BESTSHIFT = LSIGMA
00274 ENDIF
00275 ENDIF
00276 IF( .NOT.SAWNAN2 ) THEN
00277 IF(SAWNAN1 .OR. MAX2.LE.MAX1) INDX = 2
00278 IF(MAX2.LE.SMLGROWTH) THEN
00279 SMLGROWTH = MAX2
00280 BESTSHIFT = RSIGMA
00281 ENDIF
00282 ENDIF
00283 ENDIF
00284
00285
00286
00287
00288
00289
00290 IF((CLWDTH.LT.MINGAP/DBLE(128)) .AND.
00291 $ (MIN(MAX1,MAX2).LT.FAIL2)
00292 $ .AND.(.NOT.SAWNAN1).AND.(.NOT.SAWNAN2)) THEN
00293 DORRR1 = .TRUE.
00294 ELSE
00295 DORRR1 = .FALSE.
00296 ENDIF
00297 TRYRRR1 = .TRUE.
00298 IF( TRYRRR1 .AND. DORRR1 ) THEN
00299 IF(INDX.EQ.1) THEN
00300 TMP = ABS( DPLUS( N ) )
00301 ZNM2 = ONE
00302 PROD = ONE
00303 OLDP = ONE
00304 DO 15 I = N-1, 1, -1
00305 IF( PROD .LE. EPS ) THEN
00306 PROD =
00307 $ ((DPLUS(I+1)*WORK(N+I+1))/(DPLUS(I)*WORK(N+I)))*OLDP
00308 ELSE
00309 PROD = PROD*ABS(WORK(N+I))
00310 END IF
00311 OLDP = PROD
00312 ZNM2 = ZNM2 + PROD**2
00313 TMP = MAX( TMP, ABS( DPLUS( I ) * PROD ))
00314 15 CONTINUE
00315 RRR1 = TMP/( SPDIAM * SQRT( ZNM2 ) )
00316 IF (RRR1.LE.MAXGROWTH2) THEN
00317 SIGMA = LSIGMA
00318 SHIFT = SLEFT
00319 GOTO 100
00320 ENDIF
00321 ELSE IF(INDX.EQ.2) THEN
00322 TMP = ABS( WORK( N ) )
00323 ZNM2 = ONE
00324 PROD = ONE
00325 OLDP = ONE
00326 DO 16 I = N-1, 1, -1
00327 IF( PROD .LE. EPS ) THEN
00328 PROD = ((WORK(I+1)*LPLUS(I+1))/(WORK(I)*LPLUS(I)))*OLDP
00329 ELSE
00330 PROD = PROD*ABS(LPLUS(I))
00331 END IF
00332 OLDP = PROD
00333 ZNM2 = ZNM2 + PROD**2
00334 TMP = MAX( TMP, ABS( WORK( I ) * PROD ))
00335 16 CONTINUE
00336 RRR2 = TMP/( SPDIAM * SQRT( ZNM2 ) )
00337 IF (RRR2.LE.MAXGROWTH2) THEN
00338 SIGMA = RSIGMA
00339 SHIFT = SRIGHT
00340 GOTO 100
00341 ENDIF
00342 END IF
00343 ENDIF
00344
00345 50 CONTINUE
00346
00347 IF (KTRY.LT.KTRYMAX) THEN
00348
00349
00350 LSIGMA = MAX( LSIGMA - LDELTA,
00351 $ LSIGMA - LDMAX)
00352 RSIGMA = MIN( RSIGMA + RDELTA,
00353 $ RSIGMA + RDMAX )
00354 LDELTA = TWO * LDELTA
00355 RDELTA = TWO * RDELTA
00356 KTRY = KTRY + 1
00357 GOTO 5
00358 ELSE
00359
00360
00361 IF((SMLGROWTH.LT.FAIL).OR.NOFAIL) THEN
00362 LSIGMA = BESTSHIFT
00363 RSIGMA = BESTSHIFT
00364 FORCER = .TRUE.
00365 GOTO 5
00366 ELSE
00367 INFO = 1
00368 RETURN
00369 ENDIF
00370 END IF
00371
00372 100 CONTINUE
00373 IF (SHIFT.EQ.SLEFT) THEN
00374 ELSEIF (SHIFT.EQ.SRIGHT) THEN
00375
00376 CALL DCOPY( N, WORK, 1, DPLUS, 1 )
00377 CALL DCOPY( N-1, WORK(N+1), 1, LPLUS, 1 )
00378 ENDIF
00379
00380 RETURN
00381
00382
00383
00384 END