156 SUBROUTINE chptrf( UPLO, N, AP, IPIV, INFO )
175 parameter( zero = 0.0e+0, one = 1.0e+0 )
177 parameter( eight = 8.0e+0, sevten = 17.0e+0 )
181 INTEGER I, IMAX, J, JMAX, K, KC, KK, KNC, KP, KPC,
183 REAL ABSAKK, ALPHA, COLMAX, D, D11, D22, R1, ROWMAX,
185 COMPLEX D12, D21, T, WK, WKM1, WKP1, ZDUM
191 EXTERNAL lsame, icamax, slapy2
197 INTRINSIC abs, aimag, cmplx, conjg, max, real, sqrt
203 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( 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(
'CHPTRF', -info )
223 alpha = ( one+sqrt( sevten ) ) / eight
233 kc = ( n-1 )*n / 2 + 1
246 absakk = abs( real( ap( kc+k-1 ) ) )
252 imax = icamax( 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 ) = real( 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 = icamax( 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( real( ap( kpc+imax-1 ) ) ).GE.alpha*
323 CALL cswap( kp-1, ap( knc ), 1, ap( kpc ), 1 )
325 DO 30 j = kp + 1, kk - 1
327 t = conjg( ap( knc+j-1 ) )
328 ap( knc+j-1 ) = conjg( ap( kx ) )
331 ap( kx+kk-1 ) = conjg( ap( kx+kk-1 ) )
332 r1 = real( ap( knc+kk-1 ) )
333 ap( knc+kk-1 ) = real( ap( kpc+kp-1 ) )
335 IF( kstep.EQ.2 )
THEN
336 ap( kc+k-1 ) = real( ap( kc+k-1 ) )
338 ap( kc+k-2 ) = ap( kc+kp-1 )
342 ap( kc+k-1 ) = real( ap( kc+k-1 ) )
344 $ ap( kc-1 ) = real( ap( kc-1 ) )
349 IF( kstep.EQ.1 )
THEN
361 r1 = one / real( ap( kc+k-1 ) )
362 CALL chpr( uplo, k-1, -r1, ap( kc ), 1, ap )
366 CALL csscal( k-1, r1, ap( kc ), 1 )
383 d = slapy2( real( ap( k-1+( k-1 )*k / 2 ) ),
384 $ aimag( ap( k-1+( k-1 )*k / 2 ) ) )
385 d22 = real( ap( k-1+( k-2 )*( k-1 ) / 2 ) ) / d
386 d11 = real( 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 $ conjg( 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 )*conjg( wk ) -
399 $ ap( i+( k-2 )*( k-1 ) / 2 )*conjg( 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 ) = cmplx( real( ap( j+( j-1 )*
404 $ j / 2 ) ), 0.0e+0 )
414 IF( kstep.EQ.1 )
THEN
449 absakk = abs( real( ap( kc ) ) )
455 imax = k + icamax( n-k, ap( kc+1 ), 1 )
456 colmax = cabs1( ap( kc+imax-k ) )
461 IF( max( absakk, colmax ).EQ.zero )
THEN
468 ap( kc ) = real( 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 + icamax( 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( real( ap( kpc ) ) ).GE.alpha*rowmax )
THEN
518 $ knc = knc + n - k + 1
525 $
CALL cswap( n-kp, ap( knc+kp-kk+1 ), 1,
529 DO 80 j = kk + 1, kp - 1
531 t = conjg( ap( knc+j-kk ) )
532 ap( knc+j-kk ) = conjg( ap( kx ) )
535 ap( knc+kp-kk ) = conjg( ap( knc+kp-kk ) )
536 r1 = real( ap( knc ) )
537 ap( knc ) = real( ap( kpc ) )
539 IF( kstep.EQ.2 )
THEN
540 ap( kc ) = real( ap( kc ) )
542 ap( kc+1 ) = ap( kc+kp-k )
546 ap( kc ) = real( ap( kc ) )
548 $ ap( knc ) = real( ap( knc ) )
553 IF( kstep.EQ.1 )
THEN
567 r1 = one / real( ap( kc ) )
568 CALL chpr( uplo, n-k, -r1, ap( kc+1 ), 1,
573 CALL csscal( n-k, r1, ap( kc+1 ), 1 )
595 $ 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