158 SUBROUTINE zhptrf( UPLO, N, AP, IPIV, INFO )
176 DOUBLE PRECISION ZERO, ONE
177 parameter( zero = 0.0d+0, one = 1.0d+0 )
178 DOUBLE PRECISION EIGHT, SEVTEN
179 parameter( eight = 8.0d+0, sevten = 17.0d+0 )
183 INTEGER I, IMAX, J, JMAX, K, KC, KK, KNC, KP, KPC,
185 DOUBLE PRECISION ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
187 COMPLEX*16 D12, D21, T, WK, WKM1, WKP1, ZDUM
192 DOUBLE PRECISION DLAPY2
193 EXTERNAL lsame, izamax, dlapy2
199 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, sqrt
202 DOUBLE PRECISION CABS1
205 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( 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(
'ZHPTRF', -info )
225 alpha = ( one+sqrt( sevten ) ) / eight
235 kc = ( n-1 )*n / 2 + 1
248 absakk = abs( dble( ap( kc+k-1 ) ) )
254 imax = izamax( 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 ) = dble( 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 = izamax( 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( dble( ap( kpc+imax-1 ) ) ).GE.alpha*
325 CALL zswap( kp-1, ap( knc ), 1, ap( kpc ), 1 )
327 DO 30 j = kp + 1, kk - 1
329 t = dconjg( ap( knc+j-1 ) )
330 ap( knc+j-1 ) = dconjg( ap( kx ) )
333 ap( kx+kk-1 ) = dconjg( ap( kx+kk-1 ) )
334 r1 = dble( ap( knc+kk-1 ) )
335 ap( knc+kk-1 ) = dble( ap( kpc+kp-1 ) )
337 IF( kstep.EQ.2 )
THEN
338 ap( kc+k-1 ) = dble( ap( kc+k-1 ) )
340 ap( kc+k-2 ) = ap( kc+kp-1 )
344 ap( kc+k-1 ) = dble( ap( kc+k-1 ) )
346 $ ap( kc-1 ) = dble( ap( kc-1 ) )
351 IF( kstep.EQ.1 )
THEN
363 r1 = one / dble( ap( kc+k-1 ) )
364 CALL zhpr( uplo, k-1, -r1, ap( kc ), 1, ap )
368 CALL zdscal( k-1, r1, ap( kc ), 1 )
385 d = dlapy2( dble( ap( k-1+( k-1 )*k / 2 ) ),
386 $ dimag( ap( k-1+( k-1 )*k / 2 ) ) )
387 d22 = dble( ap( k-1+( k-2 )*( k-1 ) / 2 ) ) / d
388 d11 = dble( 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 $ dconjg( 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 )*dconjg( wk ) -
401 $ ap( i+( k-2 )*( k-1 ) / 2 )*dconjg( 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 ) = dcmplx( dble( ap( j+( j-
406 $ 1 )*j / 2 ) ), 0.0d+0 )
416 IF( kstep.EQ.1 )
THEN
451 absakk = abs( dble( ap( kc ) ) )
457 imax = k + izamax( n-k, ap( kc+1 ), 1 )
458 colmax = cabs1( ap( kc+imax-k ) )
463 IF( max( absakk, colmax ).EQ.zero )
THEN
470 ap( kc ) = dble( 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 + izamax( 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( dble( ap( kpc ) ) ).GE.alpha*rowmax )
THEN
520 $ knc = knc + n - k + 1
527 $
CALL zswap( n-kp, ap( knc+kp-kk+1 ), 1, ap( kpc+1 ),
530 DO 80 j = kk + 1, kp - 1
532 t = dconjg( ap( knc+j-kk ) )
533 ap( knc+j-kk ) = dconjg( ap( kx ) )
536 ap( knc+kp-kk ) = dconjg( ap( knc+kp-kk ) )
537 r1 = dble( ap( knc ) )
538 ap( knc ) = dble( ap( kpc ) )
540 IF( kstep.EQ.2 )
THEN
541 ap( kc ) = dble( ap( kc ) )
543 ap( kc+1 ) = ap( kc+kp-k )
547 ap( kc ) = dble( ap( kc ) )
549 $ ap( knc ) = dble( ap( knc ) )
554 IF( kstep.EQ.1 )
THEN
568 r1 = one / dble( ap( kc ) )
569 CALL zhpr( uplo, n-k, -r1, ap( kc+1 ), 1,
574 CALL zdscal( n-k, r1, ap( kc+1 ), 1 )
595 d = dlapy2( dble( ap( k+1+( k-1 )*( 2*n-k ) / 2 ) ),
596 $ dimag( ap( k+1+( k-1 )*( 2*n-k ) / 2 ) ) )
597 d11 = dble( ap( k+1+k*( 2*n-k-1 ) / 2 ) ) / d
598 d22 = dble( 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 $ dconjg( d21 )*ap( j+( k-1 )*( 2*n-k ) /
610 ap( i+( j-1 )*( 2*n-j ) / 2 ) = ap( i+( j-1 )*
611 $ ( 2*n-j ) / 2 ) - ap( i+( k-1 )*( 2*n-k ) /
612 $ 2 )*dconjg( wk ) - ap( i+k*( 2*n-k-1 ) / 2 )*
615 ap( j+( k-1 )*( 2*n-k ) / 2 ) = wk
616 ap( j+k*( 2*n-k-1 ) / 2 ) = wkp1
617 ap( j+( j-1 )*( 2*n-j ) / 2 )
618 $ = dcmplx( dble( ap( j+( j-1 )*( 2*n-j ) / 2 ) ),
627 IF( kstep.EQ.1 )
THEN
subroutine xerbla(srname, info)
subroutine zhpr(uplo, n, alpha, x, incx, ap)
ZHPR
subroutine zhptrf(uplo, n, ap, ipiv, info)
ZHPTRF
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP