106 SUBROUTINE dsptri( UPLO, N, AP, IPIV, WORK, INFO )
118 DOUBLE PRECISION AP( * ), WORK( * )
124 DOUBLE PRECISION ONE, ZERO
125 parameter( one = 1.0d+0, zero = 0.0d+0 )
129 INTEGER J, K, KC, KCNEXT, KP, KPC, KSTEP, KX, NPP
130 DOUBLE PRECISION AK, AKKP1, AKP1, D, T, TEMP
134 DOUBLE PRECISION DDOT
148 upper = lsame( uplo,
'U' )
149 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
151 ELSE IF( n.LT.0 )
THEN
155 CALL xerbla(
'DSPTRI', -info )
171 DO 10 info = n, 1, -1
172 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
182 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
184 kp = kp + n - info + 1
206 IF( ipiv( k ).GT.0 )
THEN
212 ap( kc+k-1 ) = one / ap( kc+k-1 )
217 CALL dcopy( k-1, ap( kc ), 1, work, 1 )
218 CALL dspmv( uplo, k-1, -one, ap, work, 1, zero,
221 ap( kc+k-1 ) = ap( kc+k-1 ) -
222 $ ddot( k-1, work, 1, ap( kc ), 1 )
231 t = abs( ap( kcnext+k-1 ) )
232 ak = ap( kc+k-1 ) / t
233 akp1 = ap( kcnext+k ) / t
234 akkp1 = ap( kcnext+k-1 ) / t
235 d = t*( ak*akp1-one )
236 ap( kc+k-1 ) = akp1 / d
237 ap( kcnext+k ) = ak / d
238 ap( kcnext+k-1 ) = -akkp1 / d
243 CALL dcopy( k-1, ap( kc ), 1, work, 1 )
244 CALL dspmv( uplo, k-1, -one, ap, work, 1, zero,
247 ap( kc+k-1 ) = ap( kc+k-1 ) -
248 $ ddot( k-1, work, 1, ap( kc ), 1 )
249 ap( kcnext+k-1 ) = ap( kcnext+k-1 ) -
250 $ ddot( k-1, ap( kc ), 1,
253 CALL dcopy( k-1, ap( kcnext ), 1, work, 1 )
254 CALL dspmv( uplo, k-1, -one, ap, work, 1, zero,
256 ap( kcnext+k ) = ap( kcnext+k ) -
257 $ ddot( k-1, work, 1, ap( kcnext ), 1 )
260 kcnext = kcnext + k + 1
263 kp = abs( ipiv( k ) )
269 kpc = ( kp-1 )*kp / 2 + 1
270 CALL dswap( kp-1, ap( kc ), 1, ap( kpc ), 1 )
272 DO 40 j = kp + 1, k - 1
275 ap( kc+j-1 ) = ap( kx )
279 ap( kc+k-1 ) = ap( kpc+kp-1 )
280 ap( kpc+kp-1 ) = temp
281 IF( kstep.EQ.2 )
THEN
282 temp = ap( kc+k+k-1 )
283 ap( kc+k+k-1 ) = ap( kc+k+kp-1 )
284 ap( kc+k+kp-1 ) = temp
310 kcnext = kc - ( n-k+2 )
311 IF( ipiv( k ).GT.0 )
THEN
317 ap( kc ) = one / ap( kc )
322 CALL dcopy( n-k, ap( kc+1 ), 1, work, 1 )
323 CALL dspmv( uplo, n-k, -one, ap( kc+n-k+1 ), work, 1,
324 $ zero, ap( kc+1 ), 1 )
325 ap( kc ) = ap( kc ) - ddot( n-k, work, 1, ap( kc+1 ),
335 t = abs( ap( kcnext+1 ) )
336 ak = ap( kcnext ) / t
338 akkp1 = ap( kcnext+1 ) / t
339 d = t*( ak*akp1-one )
340 ap( kcnext ) = akp1 / d
342 ap( kcnext+1 ) = -akkp1 / d
347 CALL dcopy( n-k, ap( kc+1 ), 1, work, 1 )
348 CALL dspmv( uplo, n-k, -one, ap( kc+( n-k+1 ) ), work,
350 $ zero, ap( kc+1 ), 1 )
351 ap( kc ) = ap( kc ) - ddot( n-k, work, 1, ap( kc+1 ),
353 ap( kcnext+1 ) = ap( kcnext+1 ) -
354 $ ddot( n-k, ap( kc+1 ), 1,
355 $ ap( kcnext+2 ), 1 )
356 CALL dcopy( n-k, ap( kcnext+2 ), 1, work, 1 )
357 CALL dspmv( uplo, n-k, -one, ap( kc+( n-k+1 ) ), work,
359 $ zero, ap( kcnext+2 ), 1 )
360 ap( kcnext ) = ap( kcnext ) -
361 $ ddot( n-k, work, 1, ap( kcnext+2 ), 1 )
364 kcnext = kcnext - ( n-k+3 )
367 kp = abs( ipiv( k ) )
373 kpc = npp - ( n-kp+1 )*( n-kp+2 ) / 2 + 1
375 $
CALL dswap( n-kp, ap( kc+kp-k+1 ), 1, ap( kpc+1 ), 1 )
377 DO 70 j = k + 1, kp - 1
380 ap( kc+j-k ) = ap( kx )
386 IF( kstep.EQ.2 )
THEN
387 temp = ap( kc-n+k-1 )
388 ap( kc-n+k-1 ) = ap( kc-n+kp-1 )
389 ap( kc-n+kp-1 ) = temp