158 SUBROUTINE chptrf( UPLO, N, AP, IPIV, INFO )
177 parameter( zero = 0.0e+0, one = 1.0e+0 )
179 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
183 INTEGER I, IMAX, J, JMAX, K, KC, KK, KNC, KP, KPC,
185 REAL ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
187 COMPLEX D12, D21, T, WK, WKM1, WKP1, ZDUM
193 EXTERNAL lsame, icamax, slapy2
199 INTRINSIC abs, aimag, cmplx, conjg, max, real, sqrt
205 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
212 upper = lsame( uplo,
'U' )
213 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
215 ELSE IF( n.LT.0 )
THEN
219 CALL xerbla(
'CHPTRF', -info )
225 alpha = ( one+sqrt( sevten ) ) / eight
235 kc = ( n-1 )*n / 2 + 1
248 absakk = abs( real( ap( kc+k-1 ) ) )
254 imax = icamax( k-1, ap( kc ), 1 )
255 colmax = cabs1( ap( kc+imax-1 ) )
260 IF( max( absakk, colmax ).EQ.zero )
THEN
267 ap( kc+k-1 ) = real( ap( kc+k-1 ) )
269 IF( absakk.GE.alpha*colmax )
THEN
281 kx = imax*( imax+1 ) / 2 + imax
282 DO 20 j = imax + 1, k
283 IF( cabs1( ap( kx ) ).GT.rowmax )
THEN
284 rowmax = cabs1( ap( kx ) )
289 kpc = ( imax-1 )*imax / 2 + 1
291 jmax = icamax( imax-1, ap( kpc ), 1 )
292 rowmax = max( rowmax, cabs1( ap( kpc+jmax-1 ) ) )
295 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
300 ELSE IF( abs( real( ap( kpc+imax-1 ) ) ).GE.alpha*
325 CALL cswap( kp-1, ap( knc ), 1, ap( kpc ), 1 )
327 DO 30 j = kp + 1, kk - 1
329 t = conjg( ap( knc+j-1 ) )
330 ap( knc+j-1 ) = conjg( ap( kx ) )
333 ap( kx+kk-1 ) = conjg( ap( kx+kk-1 ) )
334 r1 = real( ap( knc+kk-1 ) )
335 ap( knc+kk-1 ) = real( ap( kpc+kp-1 ) )
337 IF( kstep.EQ.2 )
THEN
338 ap( kc+k-1 ) = real( ap( kc+k-1 ) )
340 ap( kc+k-2 ) = ap( kc+kp-1 )
344 ap( kc+k-1 ) = real( ap( kc+k-1 ) )
346 $ ap( kc-1 ) = real( ap( kc-1 ) )
351 IF( kstep.EQ.1 )
THEN
363 r1 = one / real( ap( kc+k-1 ) )
364 CALL chpr( uplo, k-1, -r1, ap( kc ), 1, ap )
368 CALL csscal( k-1, r1, ap( kc ), 1 )
385 d = slapy2( real( ap( k-1+( k-1 )*k / 2 ) ),
386 $ aimag( ap( k-1+( k-1 )*k / 2 ) ) )
387 d22 = real( ap( k-1+( k-2 )*( k-1 ) / 2 ) ) / d
388 d11 = real( ap( k+( k-1 )*k / 2 ) ) / d
389 tt = one / ( d11*d22-one )
390 d12 = ap( k-1+( k-1 )*k / 2 ) / d
393 DO 50 j = k - 2, 1, -1
394 wkm1 = d*( d11*ap( j+( k-2 )*( k-1 ) / 2 )-
395 $ conjg( d12 )*ap( j+( k-1 )*k / 2 ) )
396 wk = d*( d22*ap( j+( k-1 )*k / 2 )-d12*
397 $ ap( j+( k-2 )*( k-1 ) / 2 ) )
399 ap( i+( j-1 )*j / 2 ) = ap( i+( j-1 )*j / 2 ) -
400 $ ap( i+( k-1 )*k / 2 )*conjg( wk ) -
401 $ ap( i+( k-2 )*( k-1 ) / 2 )*conjg( wkm1 )
403 ap( j+( k-1 )*k / 2 ) = wk
404 ap( j+( k-2 )*( k-1 ) / 2 ) = wkm1
405 ap( j+( j-1 )*j / 2 ) = cmplx( real( ap( j+( j-1 )*
406 $ j / 2 ) ), 0.0e+0 )
416 IF( kstep.EQ.1 )
THEN
451 absakk = abs( real( ap( kc ) ) )
457 imax = k + icamax( n-k, ap( kc+1 ), 1 )
458 colmax = cabs1( ap( kc+imax-k ) )
463 IF( max( absakk, colmax ).EQ.zero )
THEN
470 ap( kc ) = real( ap( kc ) )
472 IF( absakk.GE.alpha*colmax )
THEN
484 DO 70 j = k, imax - 1
485 IF( cabs1( ap( kx ) ).GT.rowmax )
THEN
486 rowmax = cabs1( ap( kx ) )
491 kpc = npp - ( n-imax+1 )*( n-imax+2 ) / 2 + 1
493 jmax = imax + icamax( n-imax, ap( kpc+1 ), 1 )
494 rowmax = max( rowmax, cabs1( ap( kpc+jmax-imax ) ) )
497 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
502 ELSE IF( abs( real( ap( kpc ) ) ).GE.alpha*rowmax )
THEN
520 $ knc = knc + n - k + 1
527 $
CALL cswap( n-kp, ap( knc+kp-kk+1 ), 1, ap( kpc+1 ),
530 DO 80 j = kk + 1, kp - 1
532 t = conjg( ap( knc+j-kk ) )
533 ap( knc+j-kk ) = conjg( ap( kx ) )
536 ap( knc+kp-kk ) = conjg( ap( knc+kp-kk ) )
537 r1 = real( ap( knc ) )
538 ap( knc ) = real( ap( kpc ) )
540 IF( kstep.EQ.2 )
THEN
541 ap( kc ) = real( ap( kc ) )
543 ap( kc+1 ) = ap( kc+kp-k )
547 ap( kc ) = real( ap( kc ) )
549 $ ap( knc ) = real( ap( knc ) )
554 IF( kstep.EQ.1 )
THEN
568 r1 = one / real( ap( kc ) )
569 CALL chpr( uplo, n-k, -r1, ap( kc+1 ), 1,
574 CALL csscal( n-k, r1, ap( kc+1 ), 1 )
595 d = slapy2( real( ap( k+1+( k-1 )*( 2*n-k ) / 2 ) ),
596 $ aimag( ap( k+1+( k-1 )*( 2*n-k ) / 2 ) ) )
597 d11 = real( ap( k+1+k*( 2*n-k-1 ) / 2 ) ) / d
598 d22 = real( ap( k+( k-1 )*( 2*n-k ) / 2 ) ) / d
599 tt = one / ( d11*d22-one )
600 d21 = ap( k+1+( k-1 )*( 2*n-k ) / 2 ) / d
604 wk = d*( d11*ap( j+( k-1 )*( 2*n-k ) / 2 )-d21*
605 $ ap( j+k*( 2*n-k-1 ) / 2 ) )
606 wkp1 = d*( d22*ap( j+k*( 2*n-k-1 ) / 2 )-
607 $ conjg( d21 )*ap( j+( k-1 )*( 2*n-k ) / 2 ) )
609 ap( i+( j-1 )*( 2*n-j ) / 2 ) = ap( i+( j-1 )*
610 $ ( 2*n-j ) / 2 ) - ap( i+( k-1 )*( 2*n-k ) /
611 $ 2 )*conjg( wk ) - ap( i+k*( 2*n-k-1 ) / 2 )*
614 ap( j+( k-1 )*( 2*n-k ) / 2 ) = wk
615 ap( j+k*( 2*n-k-1 ) / 2 ) = wkp1
616 ap( j+( j-1 )*( 2*n-j ) / 2 )
617 $ = cmplx( real( ap( j+( j-1 )*( 2*n-j ) / 2 ) ),
626 IF( kstep.EQ.1 )
THEN
subroutine xerbla(srname, info)
subroutine chpr(uplo, n, alpha, x, incx, ap)
CHPR
subroutine chptrf(uplo, n, ap, ipiv, info)
CHPTRF
subroutine csscal(n, sa, cx, incx)
CSSCAL
subroutine cswap(n, cx, incx, cy, incy)
CSWAP