189 INTEGER INFO, KB, LDA, LDW, N, NB
193 COMPLEX A( LDA, * ), W( LDW, * )
200 parameter( zero = 0.0e+0, one = 1.0e+0 )
202 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
204 parameter( cone = ( 1.0e+0, 0.0e+0 ),
205 $ czero = ( 0.0e+0, 0.0e+0 ) )
209 INTEGER IMAX, ITEMP, J, JJ, JMAX, JP1, JP2, K, KK,
210 $ kw, kkw, kp, kstep, p, ii
211 REAL ABSAKK, ALPHA, COLMAX, ROWMAX, STEMP, SFMIN
212 COMPLEX D11, D12, D21, D22, R1, T, Z
218 EXTERNAL lsame, icamax, slamch
224 INTRINSIC abs, max, min, sqrt, aimag, real
230 cabs1( z ) = abs( real( z ) ) + abs( aimag( z ) )
238 alpha = ( one+sqrt( sevten ) ) / eight
242 sfmin = slamch(
'S' )
244 IF( lsame( uplo,
'U' ) )
THEN
261 IF( ( k.LE.n-nb+1 .AND. nb.LT.n ) .OR. k.LT.1 )
269 CALL ccopy( k, a( 1, k ), 1, w( 1, kw ), 1 )
271 $
CALL cgemv(
'No transpose', k, n-k, -cone, a( 1, k+1 ),
272 $ lda, w( k, kw+1 ), ldw, cone, w( 1, kw ), 1 )
277 absakk = cabs1( w( k, kw ) )
284 imax = icamax( k-1, w( 1, kw ), 1 )
285 colmax = cabs1( w( imax, kw ) )
290 IF( max( absakk, colmax ).EQ.zero )
THEN
297 CALL ccopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
307 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
326 CALL ccopy( imax, a( 1, imax ), 1, w( 1, kw-1 ),
328 CALL ccopy( k-imax, a( imax, imax+1 ), lda,
329 $ w( imax+1, kw-1 ), 1 )
332 $
CALL cgemv(
'No transpose', k, n-k, -cone,
333 $ a( 1, k+1 ), lda, w( imax, kw+1 ), ldw,
334 $ cone, w( 1, kw-1 ), 1 )
341 jmax = imax + icamax( k-imax, w( imax+1, kw-1 ),
343 rowmax = cabs1( w( jmax, kw-1 ) )
349 itemp = icamax( imax-1, w( 1, kw-1 ), 1 )
350 stemp = cabs1( w( itemp, kw-1 ) )
351 IF( stemp.GT.rowmax )
THEN
361 IF( .NOT.(cabs1( w( imax, kw-1 ) ).LT.alpha*rowmax ) )
371 CALL ccopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
378 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
397 CALL ccopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
403 IF( .NOT. done )
GOTO 12
415 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
419 CALL ccopy( k-p, a( p+1, k ), 1, a( p, p+1 ), lda )
420 CALL ccopy( p, a( 1, k ), 1, a( 1, p ), 1 )
425 CALL cswap( n-k+1, a( k, k ), lda, a( p, k ), lda )
426 CALL cswap( n-kk+1, w( k, kkw ), ldw, w( p, kkw ),
436 a( kp, k ) = a( kk, k )
437 CALL ccopy( k-1-kp, a( kp+1, kk ), 1, a( kp, kp+1 ),
439 CALL ccopy( kp, a( 1, kk ), 1, a( 1, kp ), 1 )
444 CALL cswap( n-kk+1, a( kk, kk ), lda, a( kp, kk ),
446 CALL cswap( n-kk+1, w( kk, kkw ), ldw, w( kp, kkw ),
450 IF( kstep.EQ.1 )
THEN
460 CALL ccopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
462 IF( cabs1( a( k, k ) ).GE.sfmin )
THEN
463 r1 = cone / a( k, k )
464 CALL cscal( k-1, r1, a( 1, k ), 1 )
465 ELSE IF( a( k, k ).NE.czero )
THEN
467 a( ii, k ) = a( ii, k ) / a( k, k )
487 d11 = w( k, kw ) / d12
488 d22 = w( k-1, kw-1 ) / d12
489 t = cone / ( d11*d22-cone )
491 a( j, k-1 ) = t*( (d11*w( j, kw-1 )-w( j, kw ) ) /
493 a( j, k ) = t*( ( d22*w( j, kw )-w( j, kw-1 ) ) /
500 a( k-1, k-1 ) = w( k-1, kw-1 )
501 a( k-1, k ) = w( k-1, kw )
502 a( k, k ) = w( k, kw )
508 IF( kstep.EQ.1 )
THEN
528 CALL cgemmtr(
'Upper',
'No transpose',
'Transpose', k, n-k,
529 $ -cone, a( 1, k+1 ), lda, w( 1, kw+1 ), ldw,
530 $ cone, a( 1, 1 ), lda )
550 IF( jp2.NE.jj .AND. j.LE.n )
551 $
CALL cswap( n-j+1, a( jp2, j ), lda, a( jj, j ), lda )
553 IF( jp1.NE.jj .AND. kstep.EQ.2 )
554 $
CALL cswap( n-j+1, a( jp1, j ), lda, a( jj, j ), lda )
575 IF( ( k.GE.nb .AND. nb.LT.n ) .OR. k.GT.n )
583 CALL ccopy( n-k+1, a( k, k ), 1, w( k, k ), 1 )
585 $
CALL cgemv(
'No transpose', n-k+1, k-1, -cone, a( k, 1 ),
586 $ lda, w( k, 1 ), ldw, cone, w( k, k ), 1 )
591 absakk = cabs1( w( k, k ) )
598 imax = k + icamax( n-k, w( k+1, k ), 1 )
599 colmax = cabs1( w( imax, k ) )
604 IF( max( absakk, colmax ).EQ.zero )
THEN
611 CALL ccopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
621 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
640 CALL ccopy( imax-k, a( imax, k ), lda, w( k, k+1 ),
642 CALL ccopy( n-imax+1, a( imax, imax ), 1,
643 $ w( imax, k+1 ), 1 )
645 $
CALL cgemv(
'No transpose', n-k+1, k-1, -cone,
646 $ a( k, 1 ), lda, w( imax, 1 ), ldw,
647 $ cone, w( k, k+1 ), 1 )
654 jmax = k - 1 + icamax( imax-k, w( k, k+1 ), 1 )
655 rowmax = cabs1( w( jmax, k+1 ) )
661 itemp = imax + icamax( n-imax, w( imax+1, k+1 ),
663 stemp = cabs1( w( itemp, k+1 ) )
664 IF( stemp.GT.rowmax )
THEN
674 IF( .NOT.( cabs1( w( imax, k+1 ) ).LT.alpha*rowmax ) )
684 CALL ccopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
692 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
711 CALL ccopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
718 IF( .NOT. done )
GOTO 72
726 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
730 CALL ccopy( p-k, a( k, k ), 1, a( p, k ), lda )
731 CALL ccopy( n-p+1, a( p, k ), 1, a( p, p ), 1 )
736 CALL cswap( k, a( k, 1 ), lda, a( p, 1 ), lda )
737 CALL cswap( kk, w( k, 1 ), ldw, w( p, 1 ), ldw )
746 a( kp, k ) = a( kk, k )
747 CALL ccopy( kp-k-1, a( k+1, kk ), 1, a( kp, k+1 ),
749 CALL ccopy( n-kp+1, a( kp, kk ), 1, a( kp, kp ), 1 )
753 CALL cswap( kk, a( kk, 1 ), lda, a( kp, 1 ), lda )
754 CALL cswap( kk, w( kk, 1 ), ldw, w( kp, 1 ), ldw )
757 IF( kstep.EQ.1 )
THEN
767 CALL ccopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
769 IF( cabs1( a( k, k ) ).GE.sfmin )
THEN
770 r1 = cone / a( k, k )
771 CALL cscal( n-k, r1, a( k+1, k ), 1 )
772 ELSE IF( a( k, k ).NE.czero )
THEN
774 a( ii, k ) = a( ii, k ) / a( k, k )
793 d11 = w( k+1, k+1 ) / d21
794 d22 = w( k, k ) / d21
795 t = cone / ( d11*d22-cone )
797 a( j, k ) = t*( ( d11*w( j, k )-w( j, k+1 ) ) /
799 a( j, k+1 ) = t*( ( d22*w( j, k+1 )-w( j, k ) ) /
806 a( k, k ) = w( k, k )
807 a( k+1, k ) = w( k+1, k )
808 a( k+1, k+1 ) = w( k+1, k+1 )
814 IF( kstep.EQ.1 )
THEN
834 CALL cgemmtr(
'Lower',
'No transpose',
'Transpose', n-k+1,
835 $ k-1, -cone, a( k, 1 ), lda, w( k, 1 ), ldw,
836 $ cone, a( k, k ), lda )
856 IF( jp2.NE.jj .AND. j.GE.1 )
857 $
CALL cswap( j, a( jp2, 1 ), lda, a( jj, 1 ), lda )
859 IF( jp1.NE.jj .AND. kstep.EQ.2 )
860 $
CALL cswap( j, a( jp1, 1 ), lda, a( jj, 1 ), lda )