183 SUBROUTINE zporfs( UPLO, N, NRHS, A, LDA, AF, LDAF, B, LDB, X,
184 $ ldx, ferr, berr, work, rwork, info )
193 INTEGER info, lda, ldaf, ldb, ldx, n, nrhs
196 DOUBLE PRECISION berr( * ), ferr( * ), rwork( * )
197 COMPLEX*16 a( lda, * ), af( ldaf, * ), b( ldb, * ),
198 $ work( * ), x( ldx, * )
205 parameter( itmax = 5 )
206 DOUBLE PRECISION zero
207 parameter( zero = 0.0d+0 )
209 parameter( one = ( 1.0d+0, 0.0d+0 ) )
211 parameter( two = 2.0d+0 )
212 DOUBLE PRECISION three
213 parameter( three = 3.0d+0 )
217 INTEGER count, i, j, k, kase, nz
218 DOUBLE PRECISION eps, lstres, s, safe1, safe2, safmin, xk
228 INTRINSIC abs, dble, dimag, max
236 DOUBLE PRECISION cabs1
239 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
246 upper =
lsame( uplo,
'U' )
247 IF( .NOT.upper .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
249 ELSE IF( n.LT.0 )
THEN
251 ELSE IF( nrhs.LT.0 )
THEN
253 ELSE IF( lda.LT.max( 1, n ) )
THEN
255 ELSE IF( ldaf.LT.max( 1, n ) )
THEN
257 ELSE IF( ldb.LT.max( 1, n ) )
THEN
259 ELSE IF( ldx.LT.max( 1, n ) )
THEN
263 CALL
xerbla(
'ZPORFS', -info )
269 IF( n.EQ.0 .OR. nrhs.EQ.0 )
THEN
281 safmin =
dlamch(
'Safe minimum' )
297 CALL
zcopy( n, b( 1, j ), 1, work, 1 )
298 CALL
zhemv( uplo, n, -one, a, lda, x( 1, j ), 1, one, work, 1 )
310 rwork( i ) = cabs1( b( i, j ) )
318 xk = cabs1( x( k, j ) )
320 rwork( i ) = rwork( i ) + cabs1( a( i, k ) )*xk
321 s = s + cabs1( a( i, k ) )*cabs1( x( i, j ) )
323 rwork( k ) = rwork( k ) + abs( dble( a( k, k ) ) )*xk + s
328 xk = cabs1( x( k, j ) )
329 rwork( k ) = rwork( k ) + abs( dble( a( k, k ) ) )*xk
331 rwork( i ) = rwork( i ) + cabs1( a( i, k ) )*xk
332 s = s + cabs1( a( i, k ) )*cabs1( x( i, j ) )
334 rwork( k ) = rwork( k ) + s
339 IF( rwork( i ).GT.safe2 )
THEN
340 s = max( s, cabs1( work( i ) ) / rwork( i ) )
342 s = max( s, ( cabs1( work( i ) )+safe1 ) /
343 $ ( rwork( i )+safe1 ) )
354 IF( berr( j ).GT.eps .AND. two*berr( j ).LE.lstres .AND.
355 $ count.LE.itmax )
THEN
359 CALL
zpotrs( uplo, n, 1, af, ldaf, work, n, info )
360 CALL
zaxpy( n, one, work, 1, x( 1, j ), 1 )
389 IF( rwork( i ).GT.safe2 )
THEN
390 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i )
392 rwork( i ) = cabs1( work( i ) ) + nz*eps*rwork( i ) +
399 CALL
zlacn2( n, work( n+1 ), work, ferr( j ), kase, isave )
405 CALL
zpotrs( uplo, n, 1, af, ldaf, work, n, info )
407 work( i ) = rwork( i )*work( i )
409 ELSE IF( kase.EQ.2 )
THEN
414 work( i ) = rwork( i )*work( i )
416 CALL
zpotrs( uplo, n, 1, af, ldaf, work, n, info )
425 lstres = max( lstres, cabs1( x( i, j ) ) )
428 $ ferr( j ) = ferr( j ) / lstres