189 INTEGER INFO, KB, LDA, LDW, N, NB
193 DOUBLE PRECISION A( LDA, * ), W( LDW, * )
199 DOUBLE PRECISION ZERO, ONE
200 parameter( zero = 0.0d+0, one = 1.0d+0 )
201 DOUBLE PRECISION EIGHT, SEVTEN
202 parameter( eight = 8.0d+0, sevten = 17.0d+0 )
206 INTEGER IMAX, ITEMP, J, JJ, JMAX, JP1, JP2, K, KK,
207 $ kw, kkw, kp, kstep, p, ii
209 DOUBLE PRECISION ABSAKK, ALPHA, COLMAX, D11, D12, D21, D22,
210 $ dtemp, r1, rowmax, t, sfmin
215 DOUBLE PRECISION DLAMCH
216 EXTERNAL lsame, idamax, dlamch
222 INTRINSIC abs, max, min, sqrt
230 alpha = ( one+sqrt( sevten ) ) / eight
234 sfmin = dlamch(
'S' )
236 IF( lsame( uplo,
'U' ) )
THEN
253 IF( ( k.LE.n-nb+1 .AND. nb.LT.n ) .OR. k.LT.1 )
261 CALL dcopy( k, a( 1, k ), 1, w( 1, kw ), 1 )
263 $
CALL dgemv(
'No transpose', k, n-k, -one, a( 1, k+1 ),
264 $ lda, w( k, kw+1 ), ldw, one, w( 1, kw ), 1 )
269 absakk = abs( w( k, kw ) )
276 imax = idamax( k-1, w( 1, kw ), 1 )
277 colmax = abs( w( imax, kw ) )
282 IF( max( absakk, colmax ).EQ.zero )
THEN
289 CALL dcopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
299 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
318 CALL dcopy( imax, a( 1, imax ), 1, w( 1, kw-1 ),
320 CALL dcopy( k-imax, a( imax, imax+1 ), lda,
321 $ w( imax+1, kw-1 ), 1 )
324 $
CALL dgemv(
'No transpose', k, n-k, -one,
325 $ a( 1, k+1 ), lda, w( imax, kw+1 ), ldw,
326 $ one, w( 1, kw-1 ), 1 )
333 jmax = imax + idamax( k-imax, w( imax+1, kw-1 ),
335 rowmax = abs( w( jmax, kw-1 ) )
341 itemp = idamax( imax-1, w( 1, kw-1 ), 1 )
342 dtemp = abs( w( itemp, kw-1 ) )
343 IF( dtemp.GT.rowmax )
THEN
353 IF( .NOT.(abs( w( imax, kw-1 ) ).LT.alpha*rowmax ) )
363 CALL dcopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
370 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
389 CALL dcopy( k, w( 1, kw-1 ), 1, w( 1, kw ), 1 )
395 IF( .NOT. done )
GOTO 12
407 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
411 CALL dcopy( k-p, a( p+1, k ), 1, a( p, p+1 ), lda )
412 CALL dcopy( p, a( 1, k ), 1, a( 1, p ), 1 )
417 CALL dswap( n-k+1, a( k, k ), lda, a( p, k ), lda )
418 CALL dswap( n-kk+1, w( k, kkw ), ldw, w( p, kkw ),
428 a( kp, k ) = a( kk, k )
429 CALL dcopy( k-1-kp, a( kp+1, kk ), 1, a( kp, kp+1 ),
431 CALL dcopy( kp, a( 1, kk ), 1, a( 1, kp ), 1 )
436 CALL dswap( n-kk+1, a( kk, kk ), lda, a( kp, kk ),
438 CALL dswap( n-kk+1, w( kk, kkw ), ldw, w( kp, kkw ),
442 IF( kstep.EQ.1 )
THEN
452 CALL dcopy( k, w( 1, kw ), 1, a( 1, k ), 1 )
454 IF( abs( a( k, k ) ).GE.sfmin )
THEN
456 CALL dscal( k-1, r1, a( 1, k ), 1 )
457 ELSE IF( a( k, k ).NE.zero )
THEN
459 a( ii, k ) = a( ii, k ) / a( k, k )
479 d11 = w( k, kw ) / d12
480 d22 = w( k-1, kw-1 ) / d12
481 t = one / ( d11*d22-one )
483 a( j, k-1 ) = t*( (d11*w( j, kw-1 )-w( j, kw ) ) /
485 a( j, k ) = t*( ( d22*w( j, kw )-w( j, kw-1 ) ) /
492 a( k-1, k-1 ) = w( k-1, kw-1 )
493 a( k-1, k ) = w( k-1, kw )
494 a( k, k ) = w( k, kw )
500 IF( kstep.EQ.1 )
THEN
518 CALL dgemmtr(
'Upper',
'No transpose',
'Transpose', k, n-k,
519 $ -one, a( 1, k+1 ), lda, w( 1, kw+1 ), ldw,
520 $ one, a( 1, 1 ), lda )
540 IF( jp2.NE.jj .AND. j.LE.n )
541 $
CALL dswap( n-j+1, a( jp2, j ), lda, a( jj, j ), lda )
543 IF( jp1.NE.jj .AND. kstep.EQ.2 )
544 $
CALL dswap( n-j+1, a( jp1, j ), lda, a( jj, j ), lda )
565 IF( ( k.GE.nb .AND. nb.LT.n ) .OR. k.GT.n )
573 CALL dcopy( n-k+1, a( k, k ), 1, w( k, k ), 1 )
575 $
CALL dgemv(
'No transpose', n-k+1, k-1, -one, a( k, 1 ),
576 $ lda, w( k, 1 ), ldw, one, w( k, k ), 1 )
581 absakk = abs( w( k, k ) )
588 imax = k + idamax( n-k, w( k+1, k ), 1 )
589 colmax = abs( w( imax, k ) )
594 IF( max( absakk, colmax ).EQ.zero )
THEN
601 CALL dcopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
611 IF( .NOT.( absakk.LT.alpha*colmax ) )
THEN
630 CALL dcopy( imax-k, a( imax, k ), lda, w( k, k+1 ),
632 CALL dcopy( n-imax+1, a( imax, imax ), 1,
633 $ w( imax, k+1 ), 1 )
635 $
CALL dgemv(
'No transpose', n-k+1, k-1, -one,
636 $ a( k, 1 ), lda, w( imax, 1 ), ldw,
637 $ one, w( k, k+1 ), 1 )
644 jmax = k - 1 + idamax( imax-k, w( k, k+1 ), 1 )
645 rowmax = abs( w( jmax, k+1 ) )
651 itemp = imax + idamax( n-imax, w( imax+1, k+1 ),
653 dtemp = abs( w( itemp, k+1 ) )
654 IF( dtemp.GT.rowmax )
THEN
664 IF( .NOT.( abs( w( imax, k+1 ) ).LT.alpha*rowmax ) )
674 CALL dcopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
682 ELSE IF( ( p.EQ.jmax ) .OR. ( rowmax.LE.colmax ) )
701 CALL dcopy( n-k+1, w( k, k+1 ), 1, w( k, k ),
708 IF( .NOT. done )
GOTO 72
716 IF( ( kstep.EQ.2 ) .AND. ( p.NE.k ) )
THEN
720 CALL dcopy( p-k, a( k, k ), 1, a( p, k ), lda )
721 CALL dcopy( n-p+1, a( p, k ), 1, a( p, p ), 1 )
726 CALL dswap( k, a( k, 1 ), lda, a( p, 1 ), lda )
727 CALL dswap( kk, w( k, 1 ), ldw, w( p, 1 ), ldw )
736 a( kp, k ) = a( kk, k )
737 CALL dcopy( kp-k-1, a( k+1, kk ), 1, a( kp, k+1 ),
739 CALL dcopy( n-kp+1, a( kp, kk ), 1, a( kp, kp ), 1 )
743 CALL dswap( kk, a( kk, 1 ), lda, a( kp, 1 ), lda )
744 CALL dswap( kk, w( kk, 1 ), ldw, w( kp, 1 ), ldw )
747 IF( kstep.EQ.1 )
THEN
757 CALL dcopy( n-k+1, w( k, k ), 1, a( k, k ), 1 )
759 IF( abs( a( k, k ) ).GE.sfmin )
THEN
761 CALL dscal( n-k, r1, a( k+1, k ), 1 )
762 ELSE IF( a( k, k ).NE.zero )
THEN
764 a( ii, k ) = a( ii, k ) / a( k, k )
783 d11 = w( k+1, k+1 ) / d21
784 d22 = w( k, k ) / d21
785 t = one / ( d11*d22-one )
787 a( j, k ) = t*( ( d11*w( j, k )-w( j, k+1 ) ) /
789 a( j, k+1 ) = t*( ( d22*w( j, k+1 )-w( j, k ) ) /
796 a( k, k ) = w( k, k )
797 a( k+1, k ) = w( k+1, k )
798 a( k+1, k+1 ) = w( k+1, k+1 )
804 IF( kstep.EQ.1 )
THEN
822 CALL dgemmtr(
'Lower',
'No transpose',
'Transpose', n-k+1,
823 $ k-1, -one, a( k, 1 ), lda, w( k, 1 ), ldw,
824 $ one, a( k, k ), lda )
844 IF( jp2.NE.jj .AND. j.GE.1 )
845 $
CALL dswap( j, a( jp2, 1 ), lda, a( jj, 1 ), lda )
847 IF( jp1.NE.jj .AND. kstep.EQ.2 )
848 $
CALL dswap( j, a( jp1, 1 ), lda, a( jj, 1 ), lda )