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