250 COMPLEX A( LDA, * ), E( * )
257 parameter( zero = 0.0e+0, one = 1.0e+0 )
259 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
261 parameter( czero = ( 0.0e+0, 0.0e+0 ) )
265 INTEGER I, II, IMAX, ITEMP, J, JMAX, K, KK, KP, KSTEP,
267 REAL ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, STEMP,
269 COMPLEX D12, D21, T, WK, WKM1, WKP1, Z
276 EXTERNAL lsame, icamax, slamch, slapy2
282 INTRINSIC abs, aimag, cmplx, conjg, max, real, sqrt
288 cabs1( z ) = abs( real( z ) ) + abs( aimag( z ) )
295 upper = lsame( uplo,
'U' )
296 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
298 ELSE IF( n.LT.0 )
THEN
300 ELSE IF( lda.LT.max( 1, n ) )
THEN
304 CALL xerbla(
'CHETF2_RK', -info )
310 alpha = ( one+sqrt( sevten ) ) / eight
314 sfmin = slamch(
'S' )
341 absakk = abs( real( a( k, k ) ) )
348 imax = icamax( k-1, a( 1, k ), 1 )
349 colmax = cabs1( a( imax, k ) )
354 IF( ( max( absakk, colmax ).EQ.zero ) )
THEN
361 a( k, k ) = real( a( k, k ) )
378 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
400 jmax = imax + icamax( k-imax, a( imax, imax+1 ),
402 rowmax = cabs1( a( imax, jmax ) )
408 itemp = icamax( imax-1, a( 1, imax ), 1 )
409 stemp = cabs1( a( itemp, imax ) )
410 IF( stemp.GT.rowmax )
THEN
421 IF( .NOT.( abs( real( a( imax, imax ) ) )
422 $ .LT.alpha*rowmax ) )
THEN
434 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
456 IF( .NOT.done )
GOTO 12
471 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
474 $
CALL cswap( p-1, a( 1, k ), 1, a( 1, p ), 1 )
476 DO 14 j = p + 1, k - 1
477 t = conjg( a( j, k ) )
478 a( j, k ) = conjg( a( p, j ) )
482 a( p, k ) = conjg( a( p, k ) )
484 r1 = real( a( k, k ) )
485 a( k, k ) = real( a( p, p ) )
492 $
CALL cswap( n-k, a( k, k+1 ), lda, a( p, k+1 ),
503 $
CALL cswap( kp-1, a( 1, kk ), 1, a( 1, kp ), 1 )
505 DO 15 j = kp + 1, kk - 1
506 t = conjg( a( j, kk ) )
507 a( j, kk ) = conjg( a( kp, j ) )
511 a( kp, kk ) = conjg( a( kp, kk ) )
513 r1 = real( a( kk, kk ) )
514 a( kk, kk ) = real( a( kp, kp ) )
517 IF( kstep.EQ.2 )
THEN
519 a( k, k ) = real( a( k, k ) )
522 a( k-1, k ) = a( kp, k )
530 $
CALL cswap( n-k, a( kk, k+1 ), lda, a( kp, k+1 ),
535 a( k, k ) = real( a( k, k ) )
537 $ a( k-1, k-1 ) = real( a( k-1, k-1 ) )
542 IF( kstep.EQ.1 )
THEN
555 IF( abs( real( a( k, k ) ) ).GE.sfmin )
THEN
561 d11 = one / real( a( k, k ) )
562 CALL cher( uplo, k-1, -d11, a( 1, k ), 1, a,
567 CALL csscal( k-1, d11, a( 1, k ), 1 )
572 d11 = real( a( k, k ) )
574 a( ii, k ) = a( ii, k ) / d11
582 CALL cher( uplo, k-1, -d11, a( 1, k ), 1, a,
610 d = slapy2( real( a( k-1, k ) ),
611 $ aimag( a( k-1, k ) ) )
612 d11 = real( a( k, k ) / d )
613 d22 = real( a( k-1, k-1 ) / d )
614 d12 = a( k-1, k ) / d
615 tt = one / ( d11*d22-one )
617 DO 30 j = k - 2, 1, -1
621 wkm1 = tt*( d11*a( j, k-1 )-conjg( d12 )*
623 wk = tt*( d22*a( j, k )-d12*a( j, k-1 ) )
628 a( i, j ) = a( i, j ) -
629 $ ( a( i, k ) / d )*conjg( wk ) -
630 $ ( a( i, k-1 ) / d )*conjg( wkm1 )
636 a( j, k-1 ) = wkm1 / d
638 a( j, j ) = cmplx( real( a( j, j ) ), zero )
659 IF( kstep.EQ.1 )
THEN
697 absakk = abs( real( a( k, k ) ) )
704 imax = k + icamax( n-k, a( k+1, k ), 1 )
705 colmax = cabs1( a( imax, k ) )
710 IF( max( absakk, colmax ).EQ.zero )
THEN
717 a( k, k ) = real( a( k, k ) )
734 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
756 jmax = k - 1 + icamax( imax-k, a( imax, k ),
758 rowmax = cabs1( a( imax, jmax ) )
764 itemp = imax + icamax( n-imax, a( imax+1,
767 stemp = cabs1( a( itemp, imax ) )
768 IF( stemp.GT.rowmax )
THEN
779 IF( .NOT.( abs( real( a( imax, imax ) ) )
780 $ .LT.alpha*rowmax ) )
THEN
792 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
815 IF( .NOT.done )
GOTO 42
830 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
833 $
CALL cswap( n-p, a( p+1, k ), 1, a( p+1, p ), 1 )
835 DO 44 j = k + 1, p - 1
836 t = conjg( a( j, k ) )
837 a( j, k ) = conjg( a( p, j ) )
841 a( p, k ) = conjg( a( p, k ) )
843 r1 = real( a( k, k ) )
844 a( k, k ) = real( a( p, p ) )
851 $
CALL cswap( k-1, a( k, 1 ), lda, a( p, 1 ), lda )
861 $
CALL cswap( n-kp, a( kp+1, kk ), 1, a( kp+1, kp ),
864 DO 45 j = kk + 1, kp - 1
865 t = conjg( a( j, kk ) )
866 a( j, kk ) = conjg( a( kp, j ) )
870 a( kp, kk ) = conjg( a( kp, kk ) )
872 r1 = real( a( kk, kk ) )
873 a( kk, kk ) = real( a( kp, kp ) )
876 IF( kstep.EQ.2 )
THEN
878 a( k, k ) = real( a( k, k ) )
881 a( k+1, k ) = a( kp, k )
889 $
CALL cswap( k-1, a( kk, 1 ), lda, a( kp, 1 ), lda )
893 a( k, k ) = real( a( k, k ) )
895 $ a( k+1, k+1 ) = real( a( k+1, k+1 ) )
900 IF( kstep.EQ.1 )
THEN
915 IF( abs( real( a( k, k ) ) ).GE.sfmin )
THEN
921 d11 = one / real( a( k, k ) )
922 CALL cher( uplo, n-k, -d11, a( k+1, k ), 1,
923 $ a( k+1, k+1 ), lda )
927 CALL csscal( n-k, d11, a( k+1, k ), 1 )
932 d11 = real( a( k, k ) )
934 a( ii, k ) = a( ii, k ) / d11
942 CALL cher( uplo, n-k, -d11, a( k+1, k ), 1,
943 $ a( k+1, k+1 ), lda )
971 d = slapy2( real( a( k+1, k ) ),
972 $ aimag( a( k+1, k ) ) )
973 d11 = real( a( k+1, k+1 ) ) / d
974 d22 = real( a( k, k ) ) / d
975 d21 = a( k+1, k ) / d
976 tt = one / ( d11*d22-one )
982 wk = tt*( d11*a( j, k )-d21*a( j, k+1 ) )
983 wkp1 = tt*( d22*a( j, k+1 )-conjg( d21 )*
989 a( i, j ) = a( i, j ) -
990 $ ( a( i, k ) / d )*conjg( wk ) -
991 $ ( a( i, k+1 ) / d )*conjg( wkp1 )
997 a( j, k+1 ) = wkp1 / d
999 a( j, j ) = cmplx( real( a( j, j ) ), zero )
1008 e( k ) = a( k+1, k )
1020 IF( kstep.EQ.1 )
THEN