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