00001 SUBROUTINE SLAR1V( N, B1, BN, LAMBDA, D, L, LD, LLD,
00002 $ PIVMIN, GAPTOL, Z, WANTNC, NEGCNT, ZTZ, MINGMA,
00003 $ R, ISUPPZ, NRMINV, RESID, RQCORR, WORK )
00004
00005
00006
00007
00008
00009
00010
00011 LOGICAL WANTNC
00012 INTEGER B1, BN, N, NEGCNT, R
00013 REAL GAPTOL, LAMBDA, MINGMA, NRMINV, PIVMIN, RESID,
00014 $ RQCORR, ZTZ
00015
00016
00017 INTEGER ISUPPZ( * )
00018 REAL D( * ), L( * ), LD( * ), LLD( * ),
00019 $ WORK( * )
00020 REAL Z( * )
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
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 REAL ZERO, ONE
00139 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
00140
00141
00142
00143 LOGICAL SAWNAN1, SAWNAN2
00144 INTEGER I, INDLPL, INDP, INDS, INDUMN, NEG1, NEG2, R1,
00145 $ R2
00146 REAL DMINUS, DPLUS, EPS, S, TMP
00147
00148
00149 LOGICAL SISNAN
00150 REAL SLAMCH
00151 EXTERNAL SISNAN, SLAMCH
00152
00153
00154 INTRINSIC ABS
00155
00156
00157
00158 EPS = SLAMCH( 'Precision' )
00159
00160
00161 IF( R.EQ.0 ) THEN
00162 R1 = B1
00163 R2 = BN
00164 ELSE
00165 R1 = R
00166 R2 = R
00167 END IF
00168
00169
00170 INDLPL = 0
00171
00172 INDUMN = N
00173 INDS = 2*N + 1
00174 INDP = 3*N + 1
00175
00176 IF( B1.EQ.1 ) THEN
00177 WORK( INDS ) = ZERO
00178 ELSE
00179 WORK( INDS+B1-1 ) = LLD( B1-1 )
00180 END IF
00181
00182
00183
00184
00185
00186 SAWNAN1 = .FALSE.
00187 NEG1 = 0
00188 S = WORK( INDS+B1-1 ) - LAMBDA
00189 DO 50 I = B1, R1 - 1
00190 DPLUS = D( I ) + S
00191 WORK( INDLPL+I ) = LD( I ) / DPLUS
00192 IF(DPLUS.LT.ZERO) NEG1 = NEG1 + 1
00193 WORK( INDS+I ) = S*WORK( INDLPL+I )*L( I )
00194 S = WORK( INDS+I ) - LAMBDA
00195 50 CONTINUE
00196 SAWNAN1 = SISNAN( S )
00197 IF( SAWNAN1 ) GOTO 60
00198 DO 51 I = R1, R2 - 1
00199 DPLUS = D( I ) + S
00200 WORK( INDLPL+I ) = LD( I ) / DPLUS
00201 WORK( INDS+I ) = S*WORK( INDLPL+I )*L( I )
00202 S = WORK( INDS+I ) - LAMBDA
00203 51 CONTINUE
00204 SAWNAN1 = SISNAN( S )
00205
00206 60 CONTINUE
00207 IF( SAWNAN1 ) THEN
00208
00209 NEG1 = 0
00210 S = WORK( INDS+B1-1 ) - LAMBDA
00211 DO 70 I = B1, R1 - 1
00212 DPLUS = D( I ) + S
00213 IF(ABS(DPLUS).LT.PIVMIN) DPLUS = -PIVMIN
00214 WORK( INDLPL+I ) = LD( I ) / DPLUS
00215 IF(DPLUS.LT.ZERO) NEG1 = NEG1 + 1
00216 WORK( INDS+I ) = S*WORK( INDLPL+I )*L( I )
00217 IF( WORK( INDLPL+I ).EQ.ZERO )
00218 $ WORK( INDS+I ) = LLD( I )
00219 S = WORK( INDS+I ) - LAMBDA
00220 70 CONTINUE
00221 DO 71 I = R1, R2 - 1
00222 DPLUS = D( I ) + S
00223 IF(ABS(DPLUS).LT.PIVMIN) DPLUS = -PIVMIN
00224 WORK( INDLPL+I ) = LD( I ) / DPLUS
00225 WORK( INDS+I ) = S*WORK( INDLPL+I )*L( I )
00226 IF( WORK( INDLPL+I ).EQ.ZERO )
00227 $ WORK( INDS+I ) = LLD( I )
00228 S = WORK( INDS+I ) - LAMBDA
00229 71 CONTINUE
00230 END IF
00231
00232
00233
00234
00235 SAWNAN2 = .FALSE.
00236 NEG2 = 0
00237 WORK( INDP+BN-1 ) = D( BN ) - LAMBDA
00238 DO 80 I = BN - 1, R1, -1
00239 DMINUS = LLD( I ) + WORK( INDP+I )
00240 TMP = D( I ) / DMINUS
00241 IF(DMINUS.LT.ZERO) NEG2 = NEG2 + 1
00242 WORK( INDUMN+I ) = L( I )*TMP
00243 WORK( INDP+I-1 ) = WORK( INDP+I )*TMP - LAMBDA
00244 80 CONTINUE
00245 TMP = WORK( INDP+R1-1 )
00246 SAWNAN2 = SISNAN( TMP )
00247
00248 IF( SAWNAN2 ) THEN
00249
00250 NEG2 = 0
00251 DO 100 I = BN-1, R1, -1
00252 DMINUS = LLD( I ) + WORK( INDP+I )
00253 IF(ABS(DMINUS).LT.PIVMIN) DMINUS = -PIVMIN
00254 TMP = D( I ) / DMINUS
00255 IF(DMINUS.LT.ZERO) NEG2 = NEG2 + 1
00256 WORK( INDUMN+I ) = L( I )*TMP
00257 WORK( INDP+I-1 ) = WORK( INDP+I )*TMP - LAMBDA
00258 IF( TMP.EQ.ZERO )
00259 $ WORK( INDP+I-1 ) = D( I ) - LAMBDA
00260 100 CONTINUE
00261 END IF
00262
00263
00264
00265
00266 MINGMA = WORK( INDS+R1-1 ) + WORK( INDP+R1-1 )
00267 IF( MINGMA.LT.ZERO ) NEG1 = NEG1 + 1
00268 IF( WANTNC ) THEN
00269 NEGCNT = NEG1 + NEG2
00270 ELSE
00271 NEGCNT = -1
00272 ENDIF
00273 IF( ABS(MINGMA).EQ.ZERO )
00274 $ MINGMA = EPS*WORK( INDS+R1-1 )
00275 R = R1
00276 DO 110 I = R1, R2 - 1
00277 TMP = WORK( INDS+I ) + WORK( INDP+I )
00278 IF( TMP.EQ.ZERO )
00279 $ TMP = EPS*WORK( INDS+I )
00280 IF( ABS( TMP ).LE.ABS( MINGMA ) ) THEN
00281 MINGMA = TMP
00282 R = I + 1
00283 END IF
00284 110 CONTINUE
00285
00286
00287
00288 ISUPPZ( 1 ) = B1
00289 ISUPPZ( 2 ) = BN
00290 Z( R ) = ONE
00291 ZTZ = ONE
00292
00293
00294
00295 IF( .NOT.SAWNAN1 .AND. .NOT.SAWNAN2 ) THEN
00296 DO 210 I = R-1, B1, -1
00297 Z( I ) = -( WORK( INDLPL+I )*Z( I+1 ) )
00298 IF( (ABS(Z(I))+ABS(Z(I+1)))* ABS(LD(I)).LT.GAPTOL )
00299 $ THEN
00300 Z( I ) = ZERO
00301 ISUPPZ( 1 ) = I + 1
00302 GOTO 220
00303 ENDIF
00304 ZTZ = ZTZ + Z( I )*Z( I )
00305 210 CONTINUE
00306 220 CONTINUE
00307 ELSE
00308
00309 DO 230 I = R - 1, B1, -1
00310 IF( Z( I+1 ).EQ.ZERO ) THEN
00311 Z( I ) = -( LD( I+1 ) / LD( I ) )*Z( I+2 )
00312 ELSE
00313 Z( I ) = -( WORK( INDLPL+I )*Z( I+1 ) )
00314 END IF
00315 IF( (ABS(Z(I))+ABS(Z(I+1)))* ABS(LD(I)).LT.GAPTOL )
00316 $ THEN
00317 Z( I ) = ZERO
00318 ISUPPZ( 1 ) = I + 1
00319 GO TO 240
00320 END IF
00321 ZTZ = ZTZ + Z( I )*Z( I )
00322 230 CONTINUE
00323 240 CONTINUE
00324 ENDIF
00325
00326
00327 IF( .NOT.SAWNAN1 .AND. .NOT.SAWNAN2 ) THEN
00328 DO 250 I = R, BN-1
00329 Z( I+1 ) = -( WORK( INDUMN+I )*Z( I ) )
00330 IF( (ABS(Z(I))+ABS(Z(I+1)))* ABS(LD(I)).LT.GAPTOL )
00331 $ THEN
00332 Z( I+1 ) = ZERO
00333 ISUPPZ( 2 ) = I
00334 GO TO 260
00335 END IF
00336 ZTZ = ZTZ + Z( I+1 )*Z( I+1 )
00337 250 CONTINUE
00338 260 CONTINUE
00339 ELSE
00340
00341 DO 270 I = R, BN - 1
00342 IF( Z( I ).EQ.ZERO ) THEN
00343 Z( I+1 ) = -( LD( I-1 ) / LD( I ) )*Z( I-1 )
00344 ELSE
00345 Z( I+1 ) = -( WORK( INDUMN+I )*Z( I ) )
00346 END IF
00347 IF( (ABS(Z(I))+ABS(Z(I+1)))* ABS(LD(I)).LT.GAPTOL )
00348 $ THEN
00349 Z( I+1 ) = ZERO
00350 ISUPPZ( 2 ) = I
00351 GO TO 280
00352 END IF
00353 ZTZ = ZTZ + Z( I+1 )*Z( I+1 )
00354 270 CONTINUE
00355 280 CONTINUE
00356 END IF
00357
00358
00359
00360 TMP = ONE / ZTZ
00361 NRMINV = SQRT( TMP )
00362 RESID = ABS( MINGMA )*NRMINV
00363 RQCORR = MINGMA*TMP
00364
00365
00366 RETURN
00367
00368
00369
00370 END