188 SUBROUTINE zherfs( UPLO, N, NRHS, A, LDA, AF, LDAF, IPIV, B,
190 $ X, LDX, FERR, BERR, WORK, RWORK, INFO )
198 INTEGER INFO, LDA, LDAF, LDB, LDX, N, NRHS
202 DOUBLE PRECISION BERR( * ), FERR( * ), RWORK( * )
203 COMPLEX*16 A( LDA, * ), AF( LDAF, * ), B( LDB, * ),
204 $ work( * ), x( ldx, * )
211 PARAMETER ( ITMAX = 5 )
212 DOUBLE PRECISION ZERO
213 parameter( zero = 0.0d+0 )
215 parameter( one = ( 1.0d+0, 0.0d+0 ) )
217 parameter( two = 2.0d+0 )
218 DOUBLE PRECISION THREE
219 parameter( three = 3.0d+0 )
223 INTEGER COUNT, I, J, K, KASE, NZ
224 DOUBLE PRECISION EPS, LSTRES, S, SAFE1, SAFE2, SAFMIN, XK
235 INTRINSIC abs, dble, dimag, max
239 DOUBLE PRECISION DLAMCH
240 EXTERNAL lsame, dlamch
243 DOUBLE PRECISION CABS1
246 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
253 upper = lsame( uplo,
'U' )
254 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
256 ELSE IF( n.LT.0 )
THEN
258 ELSE IF( nrhs.LT.0 )
THEN
260 ELSE IF( lda.LT.max( 1, n ) )
THEN
262 ELSE IF( ldaf.LT.max( 1, n ) )
THEN
264 ELSE IF( ldb.LT.max( 1, n ) )
THEN
266 ELSE IF( ldx.LT.max( 1, n ) )
THEN
270 CALL xerbla(
'ZHERFS', -info )
276 IF( n.EQ.0 .OR. nrhs.EQ.0 )
THEN
287 eps = dlamch(
'Epsilon' )
288 safmin = dlamch(
'Safe minimum' )
304 CALL zcopy( n, b( 1, j ), 1, work, 1 )
305 CALL zhemv( uplo, n, -one, a, lda, x( 1, j ), 1, one, work,
318 rwork( i ) = cabs1( b( i, j ) )
326 xk = cabs1( x( k, j ) )
328 rwork( i ) = rwork( i ) + cabs1( a( i, k ) )*xk
329 s = s + cabs1( a( i, k ) )*cabs1( x( i, j ) )
331 rwork( k ) = rwork( k ) + abs( dble( a( k, k ) ) )*xk + s
336 xk = cabs1( x( k, j ) )
337 rwork( k ) = rwork( k ) + abs( dble( a( k, k ) ) )*xk
339 rwork( i ) = rwork( i ) + cabs1( a( i, k ) )*xk
340 s = s + cabs1( a( i, k ) )*cabs1( x( i, j ) )
342 rwork( k ) = rwork( k ) + s
347 IF( rwork( i ).GT.safe2 )
THEN
348 s = max( s, cabs1( work( i ) ) / rwork( i ) )
350 s = max( s, ( cabs1( work( i ) )+safe1 ) /
351 $ ( rwork( i )+safe1 ) )
362 IF( berr( j ).GT.eps .AND. two*berr( j ).LE.lstres .AND.
363 $ count.LE.itmax )
THEN
367 CALL zhetrs( uplo, n, 1, af, ldaf, ipiv, work, n, info )
368 CALL zaxpy( n, one, work, 1, x( 1, j ), 1 )
397 IF( rwork( i ).GT.safe2 )
THEN
398 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i )
400 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i ) +
407 CALL zlacn2( n, work( n+1 ), work, ferr( j ), kase, isave )
413 CALL zhetrs( uplo, n, 1, af, ldaf, ipiv, work, n,
416 work( i ) = rwork( i )*work( i )
418 ELSE IF( kase.EQ.2 )
THEN
423 work( i ) = rwork( i )*work( i )
425 CALL zhetrs( uplo, n, 1, af, ldaf, ipiv, work, n,
435 lstres = max( lstres, cabs1( x( i, j ) ) )
438 $ ferr( j ) = ferr( j ) / lstres
subroutine zherfs(uplo, n, nrhs, a, lda, af, ldaf, ipiv, b, ldb, x, ldx, ferr, berr, work, rwork, info)
ZHERFS