156 SUBROUTINE zhptrf( UPLO, N, AP, IPIV, INFO )
174 DOUBLE PRECISION ZERO, ONE
175 parameter( zero = 0.0d+0, one = 1.0d+0 )
176 DOUBLE PRECISION EIGHT, SEVTEN
177 parameter( eight = 8.0d+0, sevten = 17.0d+0 )
181 INTEGER I, IMAX, J, JMAX, K, KC, KK, KNC, KP, KPC,
183 DOUBLE PRECISION ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
185 COMPLEX*16 D12, D21, T, WK, WKM1, WKP1, ZDUM
190 DOUBLE PRECISION DLAPY2
191 EXTERNAL lsame, izamax, dlapy2
197 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, sqrt
200 DOUBLE PRECISION CABS1
203 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
210 upper = lsame( uplo,
'U' )
211 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
213 ELSE IF( n.LT.0 )
THEN
217 CALL xerbla(
'ZHPTRF', -info )
223 alpha = ( one+sqrt( sevten ) ) / eight
233 kc = ( n-1 )*n / 2 + 1
246 absakk = abs( dble( ap( kc+k-1 ) ) )
252 imax = izamax( k-1, ap( kc ), 1 )
253 colmax = cabs1( ap( kc+imax-1 ) )
258 IF( max( absakk, colmax ).EQ.zero )
THEN
265 ap( kc+k-1 ) = dble( ap( kc+k-1 ) )
267 IF( absakk.GE.alpha*colmax )
THEN
279 kx = imax*( imax+1 ) / 2 + imax
280 DO 20 j = imax + 1, k
281 IF( cabs1( ap( kx ) ).GT.rowmax )
THEN
282 rowmax = cabs1( ap( kx ) )
287 kpc = ( imax-1 )*imax / 2 + 1
289 jmax = izamax( imax-1, ap( kpc ), 1 )
290 rowmax = max( rowmax, cabs1( ap( kpc+jmax-1 ) ) )
293 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
298 ELSE IF( abs( dble( ap( kpc+imax-1 ) ) ).GE.alpha*
323 CALL zswap( kp-1, ap( knc ), 1, ap( kpc ), 1 )
325 DO 30 j = kp + 1, kk - 1
327 t = dconjg( ap( knc+j-1 ) )
328 ap( knc+j-1 ) = dconjg( ap( kx ) )
331 ap( kx+kk-1 ) = dconjg( ap( kx+kk-1 ) )
332 r1 = dble( ap( knc+kk-1 ) )
333 ap( knc+kk-1 ) = dble( ap( kpc+kp-1 ) )
335 IF( kstep.EQ.2 )
THEN
336 ap( kc+k-1 ) = dble( ap( kc+k-1 ) )
338 ap( kc+k-2 ) = ap( kc+kp-1 )
342 ap( kc+k-1 ) = dble( ap( kc+k-1 ) )
344 $ ap( kc-1 ) = dble( ap( kc-1 ) )
349 IF( kstep.EQ.1 )
THEN
361 r1 = one / dble( ap( kc+k-1 ) )
362 CALL zhpr( uplo, k-1, -r1, ap( kc ), 1, ap )
366 CALL zdscal( k-1, r1, ap( kc ), 1 )
383 d = dlapy2( dble( ap( k-1+( k-1 )*k / 2 ) ),
384 $ dimag( ap( k-1+( k-1 )*k / 2 ) ) )
385 d22 = dble( ap( k-1+( k-2 )*( k-1 ) / 2 ) ) / d
386 d11 = dble( ap( k+( k-1 )*k / 2 ) ) / d
387 tt = one / ( d11*d22-one )
388 d12 = ap( k-1+( k-1 )*k / 2 ) / d
391 DO 50 j = k - 2, 1, -1
392 wkm1 = d*( d11*ap( j+( k-2 )*( k-1 ) / 2 )-
393 $ dconjg( d12 )*ap( j+( k-1 )*k / 2 ) )
394 wk = d*( d22*ap( j+( k-1 )*k / 2 )-d12*
395 $ ap( j+( k-2 )*( k-1 ) / 2 ) )
397 ap( i+( j-1 )*j / 2 ) = ap( i+( j-1 )*j / 2 ) -
398 $ ap( i+( k-1 )*k / 2 )*dconjg( wk ) -
399 $ ap( i+( k-2 )*( k-1 ) / 2 )*dconjg( wkm1 )
401 ap( j+( k-1 )*k / 2 ) = wk
402 ap( j+( k-2 )*( k-1 ) / 2 ) = wkm1
403 ap( j+( j-1 )*j / 2 ) = dcmplx( dble( ap( j+( j-
404 $ 1 )*j / 2 ) ), 0.0d+0 )
414 IF( kstep.EQ.1 )
THEN
449 absakk = abs( dble( ap( kc ) ) )
455 imax = k + izamax( n-k, ap( kc+1 ), 1 )
456 colmax = cabs1( ap( kc+imax-k ) )
461 IF( max( absakk, colmax ).EQ.zero )
THEN
468 ap( kc ) = dble( ap( kc ) )
470 IF( absakk.GE.alpha*colmax )
THEN
482 DO 70 j = k, imax - 1
483 IF( cabs1( ap( kx ) ).GT.rowmax )
THEN
484 rowmax = cabs1( ap( kx ) )
489 kpc = npp - ( n-imax+1 )*( n-imax+2 ) / 2 + 1
491 jmax = imax + izamax( n-imax, ap( kpc+1 ), 1 )
492 rowmax = max( rowmax, cabs1( ap( kpc+jmax-imax ) ) )
495 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
500 ELSE IF( abs( dble( ap( kpc ) ) ).GE.alpha*rowmax )
THEN
518 $ knc = knc + n - k + 1
525 $
CALL zswap( n-kp, ap( knc+kp-kk+1 ), 1,
529 DO 80 j = kk + 1, kp - 1
531 t = dconjg( ap( knc+j-kk ) )
532 ap( knc+j-kk ) = dconjg( ap( kx ) )
535 ap( knc+kp-kk ) = dconjg( ap( knc+kp-kk ) )
536 r1 = dble( ap( knc ) )
537 ap( knc ) = dble( ap( kpc ) )
539 IF( kstep.EQ.2 )
THEN
540 ap( kc ) = dble( ap( kc ) )
542 ap( kc+1 ) = ap( kc+kp-k )
546 ap( kc ) = dble( ap( kc ) )
548 $ ap( knc ) = dble( ap( knc ) )
553 IF( kstep.EQ.1 )
THEN
567 r1 = one / dble( ap( kc ) )
568 CALL zhpr( uplo, n-k, -r1, ap( kc+1 ), 1,
573 CALL zdscal( n-k, r1, ap( kc+1 ), 1 )
595 $ 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