00001 SUBROUTINE ZGBRFS( TRANS, N, KL, KU, NRHS, AB, LDAB, AFB, LDAFB,
00002 $ IPIV, B, LDB, X, LDX, FERR, BERR, WORK, RWORK,
00003 $ INFO )
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 CHARACTER TRANS
00014 INTEGER INFO, KL, KU, LDAB, LDAFB, LDB, LDX, N, NRHS
00015
00016
00017 INTEGER IPIV( * )
00018 DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
00019 COMPLEX*16 AB( LDAB, * ), AFB( LDAFB, * ), B( LDB, * ),
00020 $ WORK( * ), X( LDX, * )
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 INTEGER ITMAX
00120 PARAMETER ( ITMAX = 5 )
00121 DOUBLE PRECISION ZERO
00122 PARAMETER ( ZERO = 0.0D+0 )
00123 COMPLEX*16 CONE
00124 PARAMETER ( CONE = ( 1.0D+0, 0.0D+0 ) )
00125 DOUBLE PRECISION TWO
00126 PARAMETER ( TWO = 2.0D+0 )
00127 DOUBLE PRECISION THREE
00128 PARAMETER ( THREE = 3.0D+0 )
00129
00130
00131 LOGICAL NOTRAN
00132 CHARACTER TRANSN, TRANST
00133 INTEGER COUNT, I, J, K, KASE, KK, NZ
00134 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
00135 COMPLEX*16 ZDUM
00136
00137
00138 INTEGER ISAVE( 3 )
00139
00140
00141 EXTERNAL XERBLA, ZAXPY, ZCOPY, ZGBMV, ZGBTRS, ZLACN2
00142
00143
00144 INTRINSIC ABS, DBLE, DIMAG, MAX, MIN
00145
00146
00147 LOGICAL LSAME
00148 DOUBLE PRECISION DLAMCH
00149 EXTERNAL LSAME, DLAMCH
00150
00151
00152 DOUBLE PRECISION CABS1
00153
00154
00155 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) )
00156
00157
00158
00159
00160
00161 INFO = 0
00162 NOTRAN = LSAME( TRANS, 'N' )
00163 IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) .AND. .NOT.
00164 $ LSAME( TRANS, 'C' ) ) THEN
00165 INFO = -1
00166 ELSE IF( N.LT.0 ) THEN
00167 INFO = -2
00168 ELSE IF( KL.LT.0 ) THEN
00169 INFO = -3
00170 ELSE IF( KU.LT.0 ) THEN
00171 INFO = -4
00172 ELSE IF( NRHS.LT.0 ) THEN
00173 INFO = -5
00174 ELSE IF( LDAB.LT.KL+KU+1 ) THEN
00175 INFO = -7
00176 ELSE IF( LDAFB.LT.2*KL+KU+1 ) THEN
00177 INFO = -9
00178 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
00179 INFO = -12
00180 ELSE IF( LDX.LT.MAX( 1, N ) ) THEN
00181 INFO = -14
00182 END IF
00183 IF( INFO.NE.0 ) THEN
00184 CALL XERBLA( 'ZGBRFS', -INFO )
00185 RETURN
00186 END IF
00187
00188
00189
00190 IF( N.EQ.0 .OR. NRHS.EQ.0 ) THEN
00191 DO 10 J = 1, NRHS
00192 FERR( J ) = ZERO
00193 BERR( J ) = ZERO
00194 10 CONTINUE
00195 RETURN
00196 END IF
00197
00198 IF( NOTRAN ) THEN
00199 TRANSN = 'N'
00200 TRANST = 'C'
00201 ELSE
00202 TRANSN = 'C'
00203 TRANST = 'N'
00204 END IF
00205
00206
00207
00208 NZ = MIN( KL+KU+2, N+1 )
00209 EPS = DLAMCH( 'Epsilon' )
00210 SAFMIN = DLAMCH( 'Safe minimum' )
00211 SAFE1 = NZ*SAFMIN
00212 SAFE2 = SAFE1 / EPS
00213
00214
00215
00216 DO 140 J = 1, NRHS
00217
00218 COUNT = 1
00219 LSTRES = THREE
00220 20 CONTINUE
00221
00222
00223
00224
00225
00226
00227 CALL ZCOPY( N, B( 1, J ), 1, WORK, 1 )
00228 CALL ZGBMV( TRANS, N, N, KL, KU, -CONE, AB, LDAB, X( 1, J ), 1,
00229 $ CONE, WORK, 1 )
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240 DO 30 I = 1, N
00241 RWORK( I ) = CABS1( B( I, J ) )
00242 30 CONTINUE
00243
00244
00245
00246 IF( NOTRAN ) THEN
00247 DO 50 K = 1, N
00248 KK = KU + 1 - K
00249 XK = CABS1( X( K, J ) )
00250 DO 40 I = MAX( 1, K-KU ), MIN( N, K+KL )
00251 RWORK( I ) = RWORK( I ) + CABS1( AB( KK+I, K ) )*XK
00252 40 CONTINUE
00253 50 CONTINUE
00254 ELSE
00255 DO 70 K = 1, N
00256 S = ZERO
00257 KK = KU + 1 - K
00258 DO 60 I = MAX( 1, K-KU ), MIN( N, K+KL )
00259 S = S + CABS1( AB( KK+I, K ) )*CABS1( X( I, J ) )
00260 60 CONTINUE
00261 RWORK( K ) = RWORK( K ) + S
00262 70 CONTINUE
00263 END IF
00264 S = ZERO
00265 DO 80 I = 1, N
00266 IF( RWORK( I ).GT.SAFE2 ) THEN
00267 S = MAX( S, CABS1( WORK( I ) ) / RWORK( I ) )
00268 ELSE
00269 S = MAX( S, ( CABS1( WORK( I ) )+SAFE1 ) /
00270 $ ( RWORK( I )+SAFE1 ) )
00271 END IF
00272 80 CONTINUE
00273 BERR( J ) = S
00274
00275
00276
00277
00278
00279
00280
00281 IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
00282 $ COUNT.LE.ITMAX ) THEN
00283
00284
00285
00286 CALL ZGBTRS( TRANS, N, KL, KU, 1, AFB, LDAFB, IPIV, WORK, N,
00287 $ INFO )
00288 CALL ZAXPY( N, CONE, WORK, 1, X( 1, J ), 1 )
00289 LSTRES = BERR( J )
00290 COUNT = COUNT + 1
00291 GO TO 20
00292 END IF
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316 DO 90 I = 1, N
00317 IF( RWORK( I ).GT.SAFE2 ) THEN
00318 RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I )
00319 ELSE
00320 RWORK( I ) = CABS1( WORK( I ) ) + NZ*EPS*RWORK( I ) +
00321 $ SAFE1
00322 END IF
00323 90 CONTINUE
00324
00325 KASE = 0
00326 100 CONTINUE
00327 CALL ZLACN2( N, WORK( N+1 ), WORK, FERR( J ), KASE, ISAVE )
00328 IF( KASE.NE.0 ) THEN
00329 IF( KASE.EQ.1 ) THEN
00330
00331
00332
00333 CALL ZGBTRS( TRANST, N, KL, KU, 1, AFB, LDAFB, IPIV,
00334 $ WORK, N, INFO )
00335 DO 110 I = 1, N
00336 WORK( I ) = RWORK( I )*WORK( I )
00337 110 CONTINUE
00338 ELSE
00339
00340
00341
00342 DO 120 I = 1, N
00343 WORK( I ) = RWORK( I )*WORK( I )
00344 120 CONTINUE
00345 CALL ZGBTRS( TRANSN, N, KL, KU, 1, AFB, LDAFB, IPIV,
00346 $ WORK, N, INFO )
00347 END IF
00348 GO TO 100
00349 END IF
00350
00351
00352
00353 LSTRES = ZERO
00354 DO 130 I = 1, N
00355 LSTRES = MAX( LSTRES, CABS1( X( I, J ) ) )
00356 130 CONTINUE
00357 IF( LSTRES.NE.ZERO )
00358 $ FERR( J ) = FERR( J ) / LSTRES
00359
00360 140 CONTINUE
00361
00362 RETURN
00363
00364
00365
00366 END