158 SUBROUTINE clahef( UPLO, N, NB, KB, A, LDA, IPIV, W, LDW, INFO )
167 INTEGER info, kb, lda, ldw, n, nb
171 COMPLEX a( lda, * ), w( ldw, * )
178 parameter( zero = 0.0e+0, one = 1.0e+0 )
180 parameter( cone = ( 1.0e+0, 0.0e+0 ) )
182 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
185 INTEGER imax, j, jb, jj, jmax, jp, k, kk, kkw, kp,
187 REAL absakk, alpha, colmax, r1, rowmax, t
188 COMPLEX d11, d21, d22, z
199 INTRINSIC abs, aimag, conjg, max, min,
REAL, sqrt
205 cabs1( z ) = abs(
REAL( Z ) ) + abs( aimag( z ) )
213 alpha = ( one+sqrt( sevten ) ) / eight
215 IF(
lsame( uplo,
'U' ) )
THEN
231 IF( ( k.LE.n-nb+1 .AND. nb.LT.n ) .OR. k.LT.1 )
236 CALL
ccopy( k-1, a( 1, k ), 1, w( 1, kw ), 1 )
237 w( k, kw ) =
REAL( A( K, K ) )
239 CALL
cgemv(
'No transpose', k, n-k, -cone, a( 1, k+1 ), lda,
240 $ w( k, kw+1 ), ldw, cone, w( 1, kw ), 1 )
241 w( k, kw ) =
REAL( W( K, KW ) )
249 absakk = abs(
REAL( W( K, KW ) ) )
255 imax =
icamax( k-1, w( 1, kw ), 1 )
256 colmax = cabs1( w( imax, kw ) )
261 IF( max( absakk, colmax ).EQ.zero )
THEN
268 a( k, k ) =
REAL( A( K, K ) )
270 IF( absakk.GE.alpha*colmax )
THEN
279 CALL
ccopy( imax-1, a( 1, imax ), 1, w( 1, kw-1 ), 1 )
280 w( imax, kw-1 ) =
REAL( A( IMAX, IMAX ) )
281 CALL
ccopy( k-imax, a( imax, imax+1 ), lda,
282 $ w( imax+1, kw-1 ), 1 )
283 CALL
clacgv( k-imax, w( imax+1, kw-1 ), 1 )
285 CALL
cgemv(
'No transpose', k, n-k, -cone,
286 $ a( 1, k+1 ), lda, w( imax, kw+1 ), ldw,
287 $ cone, w( 1, kw-1 ), 1 )
288 w( imax, kw-1 ) =
REAL( W( IMAX, KW-1 ) )
294 jmax = imax +
icamax( k-imax, w( imax+1, kw-1 ), 1 )
295 rowmax = cabs1( w( jmax, kw-1 ) )
297 jmax =
icamax( imax-1, w( 1, kw-1 ), 1 )
298 rowmax = max( rowmax, cabs1( w( jmax, kw-1 ) ) )
301 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
306 ELSE IF( abs(
REAL( W( IMAX, KW-1 ) ) ).GE.alpha*rowmax )
316 CALL
ccopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
336 a( kp, kp ) =
REAL( A( KK, KK ) )
337 CALL
ccopy( kk-1-kp, a( kp+1, kk ), 1, a( kp, kp+1 ),
339 CALL
clacgv( kk-1-kp, a( kp, kp+1 ), lda )
340 CALL
ccopy( kp-1, a( 1, kk ), 1, a( 1, kp ), 1 )
345 $ CALL
cswap( n-kk, a( kk, kk+1 ), lda, a( kp, kk+1 ),
347 CALL
cswap( n-kk+1, w( kk, kkw ), ldw, w( kp, kkw ),
351 IF( kstep.EQ.1 )
THEN
361 CALL
ccopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
362 r1 = one /
REAL( A( K, K ) )
363 CALL
csscal( k-1, r1, a( 1, k ), 1 )
367 CALL
clacgv( k-1, w( 1, kw ), 1 )
383 d11 = w( k, kw ) / conjg( d21 )
384 d22 = w( k-1, kw-1 ) / d21
385 t = one / (
REAL( d11*d22 )-one )
388 a( j, k-1 ) = d21*( d11*w( j, kw-1 )-w( j, kw ) )
389 a( j, k ) = conjg( d21 )*
390 $ ( d22*w( j, kw )-w( j, kw-1 ) )
396 a( k-1, k-1 ) = w( k-1, kw-1 )
397 a( k-1, k ) = w( k-1, kw )
398 a( k, k ) = w( k, kw )
402 CALL
clacgv( k-1, w( 1, kw ), 1 )
403 CALL
clacgv( k-2, w( 1, kw-1 ), 1 )
409 IF( kstep.EQ.1 )
THEN
430 DO 50 j = ( ( k-1 ) / nb )*nb + 1, 1, -nb
431 jb = min( nb, k-j+1 )
435 DO 40 jj = j, j + jb - 1
436 a( jj, jj ) =
REAL( A( JJ, JJ ) )
437 CALL
cgemv(
'No transpose', jj-j+1, n-k, -cone,
438 $ a( j, k+1 ), lda, w( jj, kw+1 ), ldw, cone,
440 a( jj, jj ) =
REAL( A( JJ, JJ ) )
445 CALL
cgemm(
'No transpose',
'Transpose', j-1, jb, n-k,
446 $ -cone, a( 1, k+1 ), lda, w( j, kw+1 ), ldw,
447 $ cone, a( 1, j ), lda )
462 IF( jp.NE.jj .AND. j.LE.n )
463 $ CALL
cswap( n-j+1, a( jp, j ), lda, a( jj, j ), lda )
484 IF( ( k.GE.nb .AND. nb.LT.n ) .OR. k.GT.n )
489 w( k, k ) =
REAL( A( K, K ) )
491 $ CALL
ccopy( n-k, a( k+1, k ), 1, w( k+1, k ), 1 )
492 CALL
cgemv(
'No transpose', n-k+1, k-1, -cone, a( k, 1 ), lda,
493 $ w( k, 1 ), ldw, cone, w( k, k ), 1 )
494 w( k, k ) =
REAL( W( K, K ) )
501 absakk = abs(
REAL( W( K, K ) ) )
507 imax = k +
icamax( n-k, w( k+1, k ), 1 )
508 colmax = cabs1( w( imax, k ) )
513 IF( max( absakk, colmax ).EQ.zero )
THEN
520 a( k, k ) =
REAL( A( K, K ) )
522 IF( absakk.GE.alpha*colmax )
THEN
531 CALL
ccopy( imax-k, a( imax, k ), lda, w( k, k+1 ), 1 )
532 CALL
clacgv( imax-k, w( k, k+1 ), 1 )
533 w( imax, k+1 ) =
REAL( A( IMAX, IMAX ) )
535 $ CALL
ccopy( n-imax, a( imax+1, imax ), 1,
536 $ w( imax+1, k+1 ), 1 )
537 CALL
cgemv(
'No transpose', n-k+1, k-1, -cone, a( k, 1 ),
538 $ lda, w( imax, 1 ), ldw, cone, w( k, k+1 ),
540 w( imax, k+1 ) =
REAL( W( IMAX, K+1 ) )
545 jmax = k - 1 +
icamax( imax-k, w( k, k+1 ), 1 )
546 rowmax = cabs1( w( jmax, k+1 ) )
548 jmax = imax +
icamax( n-imax, w( imax+1, k+1 ), 1 )
549 rowmax = max( rowmax, cabs1( w( jmax, k+1 ) ) )
552 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
557 ELSE IF( abs(
REAL( W( IMAX, K+1 ) ) ).GE.alpha*rowmax )
567 CALL
ccopy( n-k+1, w( k, k+1 ), 1, w( k, k ), 1 )
586 a( kp, kp ) =
REAL( A( KK, KK ) )
587 CALL
ccopy( kp-kk-1, a( kk+1, kk ), 1, a( kp, kk+1 ),
589 CALL
clacgv( kp-kk-1, a( kp, kk+1 ), lda )
591 $ CALL
ccopy( n-kp, a( kp+1, kk ), 1, a( kp+1, kp ), 1 )
595 CALL
cswap( kk-1, a( kk, 1 ), lda, a( kp, 1 ), lda )
596 CALL
cswap( kk, w( kk, 1 ), ldw, w( kp, 1 ), ldw )
599 IF( kstep.EQ.1 )
THEN
609 CALL
ccopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
611 r1 = one /
REAL( A( K, K ) )
612 CALL
csscal( n-k, r1, a( k+1, k ), 1 )
616 CALL
clacgv( n-k, w( k+1, k ), 1 )
632 d11 = w( k+1, k+1 ) / d21
633 d22 = w( k, k ) / conjg( d21 )
634 t = one / (
REAL( d11*d22 )-one )
637 a( j, k ) = conjg( d21 )*
638 $ ( d11*w( j, k )-w( j, k+1 ) )
639 a( j, k+1 ) = d21*( d22*w( j, k+1 )-w( j, k ) )
645 a( k, k ) = w( k, k )
646 a( k+1, k ) = w( k+1, k )
647 a( k+1, k+1 ) = w( k+1, k+1 )
651 CALL
clacgv( n-k, w( k+1, k ), 1 )
652 CALL
clacgv( n-k-1, w( k+2, k+1 ), 1 )
658 IF( kstep.EQ.1 )
THEN
680 jb = min( nb, n-j+1 )
684 DO 100 jj = j, j + jb - 1
685 a( jj, jj ) =
REAL( A( JJ, JJ ) )
686 CALL
cgemv(
'No transpose', j+jb-jj, k-1, -cone,
687 $ a( jj, 1 ), lda, w( jj, 1 ), ldw, cone,
689 a( jj, jj ) =
REAL( A( JJ, JJ ) )
695 $ CALL
cgemm(
'No transpose',
'Transpose', n-j-jb+1, jb,
696 $ k-1, -cone, a( j+jb, 1 ), lda, w( j, 1 ),
697 $ ldw, cone, a( j+jb, j ), lda )
712 IF( jp.NE.jj .AND. j.GE.1 )
713 $ CALL
cswap( j, a( jp, 1 ), lda, a( jj, 1 ), lda )