178 SUBROUTINE chetf2( UPLO, N, A, LDA, IPIV, INFO )
198 parameter( zero = 0.0e+0, one = 1.0e+0 )
200 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
204 INTEGER i, imax, j, jmax, k, kk, kp, kstep
205 REAL absakk, alpha, colmax, d, d11, d22, r1, rowmax,
207 COMPLEX d12, d21, t, wk, wkm1, wkp1, zdum
219 INTRINSIC abs, aimag, cmplx, conjg, max,
REAL, sqrt
225 cabs1( zdum ) = abs(
REAL( ZDUM ) ) + abs( aimag( zdum ) )
232 upper =
lsame( uplo,
'U' )
233 IF( .NOT.upper .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
235 ELSE IF( n.LT.0 )
THEN
237 ELSE IF( lda.LT.max( 1, n ) )
THEN
241 CALL
xerbla(
'CHETF2', -info )
247 alpha = ( one+sqrt( sevten ) ) / eight
268 absakk = abs(
REAL( A( K, K ) ) )
274 imax =
icamax( k-1, a( 1, k ), 1 )
275 colmax = cabs1( a( imax, k ) )
280 IF( (max( absakk, colmax ).EQ.zero) .OR.
sisnan(absakk) )
THEN
287 a( k, k ) =
REAL( A( K, K ) )
289 IF( absakk.GE.alpha*colmax )
THEN
299 jmax = imax +
icamax( k-imax, a( imax, imax+1 ), lda )
300 rowmax = cabs1( a( imax, jmax ) )
302 jmax =
icamax( imax-1, a( 1, imax ), 1 )
303 rowmax = max( rowmax, cabs1( a( jmax, imax ) ) )
306 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
311 ELSE IF( abs(
REAL( A( IMAX, IMAX ) ) ).GE.alpha*rowmax )
334 CALL
cswap( kp-1, a( 1, kk ), 1, a( 1, kp ), 1 )
335 DO 20 j = kp + 1, kk - 1
336 t = conjg( a( j, kk ) )
337 a( j, kk ) = conjg( a( kp, j ) )
340 a( kp, kk ) = conjg( a( kp, kk ) )
341 r1 =
REAL( A( KK, KK ) )
342 a( kk, kk ) =
REAL( A( KP, KP ) )
344 IF( kstep.EQ.2 )
THEN
345 a( k, k ) =
REAL( A( K, K ) )
347 a( k-1, k ) = a( kp, k )
351 a( k, k ) =
REAL( A( K, K ) )
353 $ a( k-1, k-1 ) =
REAL( A( K-1, K-1 ) )
358 IF( kstep.EQ.1 )
THEN
370 r1 = one /
REAL( A( K, K ) )
371 CALL
cher( uplo, k-1, -r1, a( 1, k ), 1, a, lda )
375 CALL
csscal( k-1, r1, a( 1, k ), 1 )
392 d =
slapy2(
REAL( A( K-1, K ) ),
393 $ aimag( a( k-1, k ) ) )
394 d22 =
REAL( A( K-1, K-1 ) ) / d
395 d11 =
REAL( A( K, K ) ) / d
396 tt = one / ( d11*d22-one )
397 d12 = a( k-1, k ) / d
400 DO 40 j = k - 2, 1, -1
401 wkm1 = d*( d11*a( j, k-1 )-conjg( d12 )*a( j, k ) )
402 wk = d*( d22*a( j, k )-d12*a( j, k-1 ) )
404 a( i, j ) = a( i, j ) - a( i, k )*conjg( wk ) -
405 $ a( i, k-1 )*conjg( wkm1 )
409 a( j, j ) = cmplx(
REAL( A( J, J ) ), 0.0e+0 )
419 IF( kstep.EQ.1 )
THEN
450 absakk = abs(
REAL( A( K, K ) ) )
456 imax = k +
icamax( n-k, a( k+1, k ), 1 )
457 colmax = cabs1( a( imax, k ) )
462 IF( (max( absakk, colmax ).EQ.zero) .OR.
sisnan(absakk) )
THEN
469 a( k, k ) =
REAL( A( K, K ) )
471 IF( absakk.GE.alpha*colmax )
THEN
481 jmax = k - 1 +
icamax( imax-k, a( imax, k ), lda )
482 rowmax = cabs1( a( imax, jmax ) )
484 jmax = imax +
icamax( n-imax, a( imax+1, imax ), 1 )
485 rowmax = max( rowmax, cabs1( a( jmax, imax ) ) )
488 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
493 ELSE IF( abs(
REAL( A( IMAX, IMAX ) ) ).GE.alpha*rowmax )
517 $ CALL
cswap( n-kp, a( kp+1, kk ), 1, a( kp+1, kp ), 1 )
518 DO 60 j = kk + 1, kp - 1
519 t = conjg( a( j, kk ) )
520 a( j, kk ) = conjg( a( kp, j ) )
523 a( kp, kk ) = conjg( a( kp, kk ) )
524 r1 =
REAL( A( KK, KK ) )
525 a( kk, kk ) =
REAL( A( KP, KP ) )
527 IF( kstep.EQ.2 )
THEN
528 a( k, k ) =
REAL( A( K, K ) )
530 a( k+1, k ) = a( kp, k )
534 a( k, k ) =
REAL( A( K, K ) )
536 $ a( k+1, k+1 ) =
REAL( A( K+1, K+1 ) )
541 IF( kstep.EQ.1 )
THEN
555 r1 = one /
REAL( A( K, K ) )
556 CALL
cher( uplo, n-k, -r1, a( k+1, k ), 1,
557 $ a( k+1, k+1 ), lda )
561 CALL
csscal( n-k, r1, a( k+1, k ), 1 )
577 d =
slapy2(
REAL( A( K+1, K ) ),
578 $ aimag( a( k+1, k ) ) )
579 d11 =
REAL( A( K+1, K+1 ) ) / d
580 d22 =
REAL( A( K, K ) ) / d
581 tt = one / ( d11*d22-one )
582 d21 = a( k+1, k ) / d
586 wk = d*( d11*a( j, k )-d21*a( j, k+1 ) )
587 wkp1 = d*( d22*a( j, k+1 )-conjg( d21 )*a( j, k ) )
589 a( i, j ) = a( i, j ) - a( i, k )*conjg( wk ) -
590 $ a( i, k+1 )*conjg( wkp1 )
594 a( j, j ) = cmplx(
REAL( A( J, J ) ), 0.0e+0 )
602 IF( kstep.EQ.1 )
THEN