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