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