188 SUBROUTINE zhetf2( UPLO, N, A, LDA, IPIV, INFO )
200 COMPLEX*16 A( LDA, * )
206 DOUBLE PRECISION ZERO, ONE
207 parameter( zero = 0.0d+0, one = 1.0d+0 )
208 DOUBLE PRECISION EIGHT, SEVTEN
209 parameter( eight = 8.0d+0, sevten = 17.0d+0 )
213 INTEGER I, IMAX, J, JMAX, K, KK, KP, KSTEP
214 DOUBLE PRECISION ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
216 COMPLEX*16 D12, D21, T, WK, WKM1, WKP1, ZDUM
219 LOGICAL LSAME, DISNAN
221 DOUBLE PRECISION DLAPY2
222 EXTERNAL lsame, izamax, dlapy2, disnan
228 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, sqrt
231 DOUBLE PRECISION CABS1
234 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
241 upper = lsame( uplo,
'U' )
242 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
244 ELSE IF( n.LT.0 )
THEN
246 ELSE IF( lda.LT.max( 1, n ) )
THEN
250 CALL xerbla(
'ZHETF2', -info )
256 alpha = ( one+sqrt( sevten ) ) / eight
277 absakk = abs( dble( a( k, k ) ) )
284 imax = izamax( k-1, a( 1, k ), 1 )
285 colmax = cabs1( a( imax, k ) )
290 IF( (max( absakk, colmax ).EQ.zero) .OR.
291 $ disnan(absakk) )
THEN
299 a( k, k ) = dble( a( k, k ) )
306 IF( absakk.GE.alpha*colmax )
THEN
317 jmax = imax + izamax( k-imax, a( imax, imax+1 ), lda )
318 rowmax = cabs1( a( imax, jmax ) )
320 jmax = izamax( imax-1, a( 1, imax ), 1 )
321 rowmax = max( rowmax, cabs1( a( jmax, imax ) ) )
324 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
330 ELSE IF( abs( dble( a( imax, imax ) ) ).GE.alpha*rowmax )
356 CALL zswap( kp-1, a( 1, kk ), 1, a( 1, kp ), 1 )
357 DO 20 j = kp + 1, kk - 1
358 t = dconjg( a( j, kk ) )
359 a( j, kk ) = dconjg( a( kp, j ) )
362 a( kp, kk ) = dconjg( a( kp, kk ) )
363 r1 = dble( a( kk, kk ) )
364 a( kk, kk ) = dble( a( kp, kp ) )
366 IF( kstep.EQ.2 )
THEN
367 a( k, k ) = dble( a( k, k ) )
369 a( k-1, k ) = a( kp, k )
373 a( k, k ) = dble( a( k, k ) )
375 $ a( k-1, k-1 ) = dble( a( k-1, k-1 ) )
380 IF( kstep.EQ.1 )
THEN
392 r1 = one / dble( a( k, k ) )
393 CALL zher( uplo, k-1, -r1, a( 1, k ), 1, a, lda )
397 CALL zdscal( k-1, r1, a( 1, k ), 1 )
414 d = dlapy2( dble( a( k-1, k ) ),
415 $ dimag( a( k-1, k ) ) )
416 d22 = dble( a( k-1, k-1 ) ) / d
417 d11 = dble( a( k, k ) ) / d
418 tt = one / ( d11*d22-one )
419 d12 = a( k-1, k ) / d
422 DO 40 j = k - 2, 1, -1
423 wkm1 = d*( d11*a( j, k-1 )-dconjg( d12 )*
425 wk = d*( d22*a( j, k )-d12*a( j, k-1 ) )
427 a( i, j ) = a( i, j ) - a( i, k )*dconjg( wk ) -
428 $ a( i, k-1 )*dconjg( wkm1 )
432 a( j, j ) = dcmplx( dble( a( j, j ) ), 0.0d+0 )
442 IF( kstep.EQ.1 )
THEN
473 absakk = abs( dble( a( k, k ) ) )
480 imax = k + izamax( n-k, a( k+1, k ), 1 )
481 colmax = cabs1( a( imax, k ) )
486 IF( (max( absakk, colmax ).EQ.zero) .OR.
487 $ disnan(absakk) )
THEN
495 a( k, k ) = dble( a( k, k ) )
502 IF( absakk.GE.alpha*colmax )
THEN
513 jmax = k - 1 + izamax( imax-k, a( imax, k ), lda )
514 rowmax = cabs1( a( imax, jmax ) )
516 jmax = imax + izamax( n-imax, a( imax+1, imax ),
518 rowmax = max( rowmax, cabs1( a( jmax, imax ) ) )
521 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
527 ELSE IF( abs( dble( a( imax, imax ) ) ).GE.alpha*rowmax )
554 $
CALL zswap( n-kp, a( kp+1, kk ), 1, a( kp+1, kp ),
556 DO 60 j = kk + 1, kp - 1
557 t = dconjg( a( j, kk ) )
558 a( j, kk ) = dconjg( a( kp, j ) )
561 a( kp, kk ) = dconjg( a( kp, kk ) )
562 r1 = dble( a( kk, kk ) )
563 a( kk, kk ) = dble( a( kp, kp ) )
565 IF( kstep.EQ.2 )
THEN
566 a( k, k ) = dble( a( k, k ) )
568 a( k+1, k ) = a( kp, k )
572 a( k, k ) = dble( a( k, k ) )
574 $ a( k+1, k+1 ) = dble( a( k+1, k+1 ) )
579 IF( kstep.EQ.1 )
THEN
593 r1 = one / dble( a( k, k ) )
594 CALL zher( uplo, n-k, -r1, a( k+1, k ), 1,
595 $ a( k+1, k+1 ), lda )
599 CALL zdscal( n-k, r1, a( k+1, k ), 1 )
615 d = dlapy2( dble( a( k+1, k ) ),
616 $ dimag( a( k+1, k ) ) )
617 d11 = dble( a( k+1, k+1 ) ) / d
618 d22 = dble( a( k, k ) ) / d
619 tt = one / ( d11*d22-one )
620 d21 = a( k+1, k ) / d
624 wk = d*( d11*a( j, k )-d21*a( j, k+1 ) )
625 wkp1 = d*( d22*a( j, k+1 )-dconjg( d21 )*
628 a( i, j ) = a( i, j ) - a( i, k )*dconjg( wk ) -
629 $ a( i, k+1 )*dconjg( wkp1 )
633 a( j, j ) = dcmplx( dble( a( j, j ) ), 0.0d+0 )
641 IF( kstep.EQ.1 )
THEN