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