00001 SUBROUTINE DSYRFS( UPLO, N, NRHS, A, LDA, AF, LDAF, IPIV, B, LDB,
00002 $ X, LDX, FERR, BERR, WORK, IWORK, INFO )
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 CHARACTER UPLO
00013 INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS
00014
00015
00016 INTEGER IPIV( * ), IWORK( * )
00017 DOUBLE PRECISION A( LDA, * ), AF( LDAF, * ), 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
00110
00111 INTEGER ITMAX
00112 PARAMETER ( ITMAX = 5 )
00113 DOUBLE PRECISION ZERO
00114 PARAMETER ( ZERO = 0.0D+0 )
00115 DOUBLE PRECISION ONE
00116 PARAMETER ( ONE = 1.0D+0 )
00117 DOUBLE PRECISION TWO
00118 PARAMETER ( TWO = 2.0D+0 )
00119 DOUBLE PRECISION THREE
00120 PARAMETER ( THREE = 3.0D+0 )
00121
00122
00123 LOGICAL UPPER
00124 INTEGER COUNT, I, J, K, KASE, NZ
00125 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
00126
00127
00128 INTEGER ISAVE( 3 )
00129
00130
00131 EXTERNAL DAXPY, DCOPY, DLACN2, DSYMV, DSYTRS, XERBLA
00132
00133
00134 INTRINSIC ABS, MAX
00135
00136
00137 LOGICAL LSAME
00138 DOUBLE PRECISION DLAMCH
00139 EXTERNAL LSAME, DLAMCH
00140
00141
00142
00143
00144
00145 INFO = 0
00146 UPPER = LSAME( UPLO, 'U' )
00147 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00148 INFO = -1
00149 ELSE IF( N.LT.0 ) THEN
00150 INFO = -2
00151 ELSE IF( NRHS.LT.0 ) THEN
00152 INFO = -3
00153 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00154 INFO = -5
00155 ELSE IF( LDAF.LT.MAX( 1, N ) ) THEN
00156 INFO = -7
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( 'DSYRFS', -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 = N + 1
00180 EPS = DLAMCH( 'Epsilon' )
00181 SAFMIN = DLAMCH( '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 DCOPY( N, B( 1, J ), 1, WORK( N+1 ), 1 )
00198 CALL DSYMV( UPLO, N, -ONE, A, LDA, 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 DO 40 I = 1, K - 1
00221 WORK( I ) = WORK( I ) + ABS( A( I, K ) )*XK
00222 S = S + ABS( A( I, K ) )*ABS( X( I, J ) )
00223 40 CONTINUE
00224 WORK( K ) = WORK( K ) + ABS( A( K, K ) )*XK + S
00225 50 CONTINUE
00226 ELSE
00227 DO 70 K = 1, N
00228 S = ZERO
00229 XK = ABS( X( K, J ) )
00230 WORK( K ) = WORK( K ) + ABS( A( K, K ) )*XK
00231 DO 60 I = K + 1, N
00232 WORK( I ) = WORK( I ) + ABS( A( I, K ) )*XK
00233 S = S + ABS( A( I, K ) )*ABS( X( I, J ) )
00234 60 CONTINUE
00235 WORK( K ) = WORK( K ) + S
00236 70 CONTINUE
00237 END IF
00238 S = ZERO
00239 DO 80 I = 1, N
00240 IF( WORK( I ).GT.SAFE2 ) THEN
00241 S = MAX( S, ABS( WORK( N+I ) ) / WORK( I ) )
00242 ELSE
00243 S = MAX( S, ( ABS( WORK( N+I ) )+SAFE1 ) /
00244 $ ( WORK( I )+SAFE1 ) )
00245 END IF
00246 80 CONTINUE
00247 BERR( J ) = S
00248
00249
00250
00251
00252
00253
00254
00255 IF( BERR( J ).GT.EPS .AND. TWO*BERR( J ).LE.LSTRES .AND.
00256 $ COUNT.LE.ITMAX ) THEN
00257
00258
00259
00260 CALL DSYTRS( UPLO, N, 1, AF, LDAF, IPIV, WORK( N+1 ), N,
00261 $ INFO )
00262 CALL DAXPY( N, ONE, WORK( N+1 ), 1, X( 1, J ), 1 )
00263 LSTRES = BERR( J )
00264 COUNT = COUNT + 1
00265 GO TO 20
00266 END IF
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 DO 90 I = 1, N
00291 IF( WORK( I ).GT.SAFE2 ) THEN
00292 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I )
00293 ELSE
00294 WORK( I ) = ABS( WORK( N+I ) ) + NZ*EPS*WORK( I ) + SAFE1
00295 END IF
00296 90 CONTINUE
00297
00298 KASE = 0
00299 100 CONTINUE
00300 CALL DLACN2( N, WORK( 2*N+1 ), WORK( N+1 ), IWORK, FERR( J ),
00301 $ KASE, ISAVE )
00302 IF( KASE.NE.0 ) THEN
00303 IF( KASE.EQ.1 ) THEN
00304
00305
00306
00307 CALL DSYTRS( UPLO, N, 1, AF, LDAF, IPIV, WORK( N+1 ), N,
00308 $ INFO )
00309 DO 110 I = 1, N
00310 WORK( N+I ) = WORK( I )*WORK( N+I )
00311 110 CONTINUE
00312 ELSE IF( KASE.EQ.2 ) THEN
00313
00314
00315
00316 DO 120 I = 1, N
00317 WORK( N+I ) = WORK( I )*WORK( N+I )
00318 120 CONTINUE
00319 CALL DSYTRS( UPLO, N, 1, AF, LDAF, IPIV, WORK( N+1 ), N,
00320 $ INFO )
00321 END IF
00322 GO TO 100
00323 END IF
00324
00325
00326
00327 LSTRES = ZERO
00328 DO 130 I = 1, N
00329 LSTRES = MAX( LSTRES, ABS( X( I, J ) ) )
00330 130 CONTINUE
00331 IF( LSTRES.NE.ZERO )
00332 $ FERR( J ) = FERR( J ) / LSTRES
00333
00334 140 CONTINUE
00335
00336 RETURN
00337
00338
00339
00340 END