156 SUBROUTINE dsptrf( UPLO, N, AP, IPIV, INFO )
168 DOUBLE PRECISION AP( * )
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, D11, D12, D21, D22, R1,
184 $ ROWMAX, T, WK, WKM1, WKP1
189 EXTERNAL lsame, idamax
195 INTRINSIC abs, max, sqrt
202 upper = lsame( uplo,
'U' )
203 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
205 ELSE IF( n.LT.0 )
THEN
209 CALL xerbla(
'DSPTRF', -info )
215 alpha = ( one+sqrt( sevten ) ) / eight
225 kc = ( n-1 )*n / 2 + 1
238 absakk = abs( ap( kc+k-1 ) )
244 imax = idamax( k-1, ap( kc ), 1 )
245 colmax = abs( ap( kc+imax-1 ) )
250 IF( max( absakk, colmax ).EQ.zero )
THEN
258 IF( absakk.GE.alpha*colmax )
THEN
267 kx = imax*( imax+1 ) / 2 + imax
268 DO 20 j = imax + 1, k
269 IF( abs( ap( kx ) ).GT.rowmax )
THEN
270 rowmax = abs( ap( kx ) )
275 kpc = ( imax-1 )*imax / 2 + 1
277 jmax = idamax( imax-1, ap( kpc ), 1 )
278 rowmax = max( rowmax, abs( ap( kpc+jmax-1 ) ) )
281 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
286 ELSE IF( abs( ap( kpc+imax-1 ) ).GE.alpha*rowmax )
THEN
310 CALL dswap( kp-1, ap( knc ), 1, ap( kpc ), 1 )
312 DO 30 j = kp + 1, kk - 1
315 ap( knc+j-1 ) = ap( kx )
319 ap( knc+kk-1 ) = ap( kpc+kp-1 )
321 IF( kstep.EQ.2 )
THEN
323 ap( kc+k-2 ) = ap( kc+kp-1 )
330 IF( kstep.EQ.1 )
THEN
342 r1 = one / ap( kc+k-1 )
343 CALL dspr( uplo, k-1, -r1, ap( kc ), 1, ap )
347 CALL dscal( k-1, r1, ap( kc ), 1 )
364 d12 = ap( k-1+( k-1 )*k / 2 )
365 d22 = ap( k-1+( k-2 )*( k-1 ) / 2 ) / d12
366 d11 = ap( k+( k-1 )*k / 2 ) / d12
367 t = one / ( d11*d22-one )
370 DO 50 j = k - 2, 1, -1
371 wkm1 = d12*( d11*ap( j+( k-2 )*( k-1 ) / 2 )-
372 $ ap( j+( k-1 )*k / 2 ) )
373 wk = d12*( d22*ap( j+( k-1 )*k / 2 )-
374 $ ap( j+( k-2 )*( k-1 ) / 2 ) )
376 ap( i+( j-1 )*j / 2 ) = ap( i+( j-1 )*j / 2 ) -
377 $ ap( i+( k-1 )*k / 2 )*wk -
378 $ ap( i+( k-2 )*( k-1 ) / 2 )*wkm1
380 ap( j+( k-1 )*k / 2 ) = wk
381 ap( j+( k-2 )*( k-1 ) / 2 ) = wkm1
391 IF( kstep.EQ.1 )
THEN
426 absakk = abs( ap( kc ) )
432 imax = k + idamax( n-k, ap( kc+1 ), 1 )
433 colmax = abs( ap( kc+imax-k ) )
438 IF( max( absakk, colmax ).EQ.zero )
THEN
446 IF( absakk.GE.alpha*colmax )
THEN
458 DO 70 j = k, imax - 1
459 IF( abs( ap( kx ) ).GT.rowmax )
THEN
460 rowmax = abs( ap( kx ) )
465 kpc = npp - ( n-imax+1 )*( n-imax+2 ) / 2 + 1
467 jmax = imax + idamax( n-imax, ap( kpc+1 ), 1 )
468 rowmax = max( rowmax, abs( ap( kpc+jmax-imax ) ) )
471 IF( absakk.GE.alpha*colmax*( colmax / rowmax ) )
THEN
476 ELSE IF( abs( ap( kpc ) ).GE.alpha*rowmax )
THEN
494 $ knc = knc + n - k + 1
501 $
CALL dswap( n-kp, ap( knc+kp-kk+1 ), 1,
505 DO 80 j = kk + 1, kp - 1
508 ap( knc+j-kk ) = ap( kx )
512 ap( knc ) = ap( kpc )
514 IF( kstep.EQ.2 )
THEN
516 ap( kc+1 ) = ap( kc+kp-k )
523 IF( kstep.EQ.1 )
THEN
538 CALL dspr( uplo, n-k, -r1, ap( kc+1 ), 1,
543 CALL dscal( n-k, r1, ap( kc+1 ), 1 )
564 d21 = ap( k+1+( k-1 )*( 2*n-k ) / 2 )
565 d11 = ap( k+1+k*( 2*n-k-1 ) / 2 ) / d21
566 d22 = ap( k+( k-1 )*( 2*n-k ) / 2 ) / d21
567 t = one / ( d11*d22-one )
571 wk = d21*( d11*ap( j+( k-1 )*( 2*n-k ) / 2 )-
572 $ ap( j+k*( 2*n-k-1 ) / 2 ) )
573 wkp1 = d21*( d22*ap( j+k*( 2*n-k-1 ) / 2 )-
574 $ ap( j+( k-1 )*( 2*n-k ) / 2 ) )
577 ap( i+( j-1 )*( 2*n-j ) / 2 ) = ap( i+( j-1 )*
578 $ ( 2*n-j ) / 2 ) - ap( i+( k-1 )*( 2*n-k ) /
579 $ 2 )*wk - ap( i+k*( 2*n-k-1 ) / 2 )*wkp1
582 ap( j+( k-1 )*( 2*n-k ) / 2 ) = wk
583 ap( j+k*( 2*n-k-1 ) / 2 ) = wkp1
592 IF( kstep.EQ.1 )
THEN