106 SUBROUTINE chptri( UPLO, N, AP, IPIV, WORK, INFO )
118 COMPLEX AP( * ), WORK( * )
126 parameter( one = 1.0e+0, cone = ( 1.0e+0, 0.0e+0 ),
127 $ zero = ( 0.0e+0, 0.0e+0 ) )
131 INTEGER J, K, KC, KCNEXT, KP, KPC, KSTEP, KX, NPP
138 EXTERNAL lsame, cdotc
144 INTRINSIC abs, conjg, real
151 upper = lsame( uplo,
'U' )
152 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
154 ELSE IF( n.LT.0 )
THEN
158 CALL xerbla(
'CHPTRI', -info )
174 DO 10 info = n, 1, -1
175 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
185 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
187 kp = kp + n - info + 1
209 IF( ipiv( k ).GT.0 )
THEN
215 ap( kc+k-1 ) = one / real( ap( kc+k-1 ) )
220 CALL ccopy( k-1, ap( kc ), 1, work, 1 )
221 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
223 ap( kc+k-1 ) = ap( kc+k-1 ) -
224 $ real( cdotc( k-1, work, 1, ap( kc ),
234 t = abs( ap( kcnext+k-1 ) )
235 ak = real( ap( kc+k-1 ) ) / t
236 akp1 = real( ap( kcnext+k ) ) / t
237 akkp1 = ap( kcnext+k-1 ) / t
238 d = t*( ak*akp1-one )
239 ap( kc+k-1 ) = akp1 / d
240 ap( kcnext+k ) = ak / d
241 ap( kcnext+k-1 ) = -akkp1 / d
246 CALL ccopy( k-1, ap( kc ), 1, work, 1 )
247 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
249 ap( kc+k-1 ) = ap( kc+k-1 ) -
250 $ real( cdotc( k-1, work, 1, ap( kc ),
252 ap( kcnext+k-1 ) = ap( kcnext+k-1 ) -
253 $ cdotc( k-1, ap( kc ), 1,
256 CALL ccopy( k-1, ap( kcnext ), 1, work, 1 )
257 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
259 ap( kcnext+k ) = ap( kcnext+k ) -
260 $ real( cdotc( k-1, work, 1,
265 kcnext = kcnext + k + 1
268 kp = abs( ipiv( k ) )
274 kpc = ( kp-1 )*kp / 2 + 1
275 CALL cswap( kp-1, ap( kc ), 1, ap( kpc ), 1 )
277 DO 40 j = kp + 1, k - 1
279 temp = conjg( ap( kc+j-1 ) )
280 ap( kc+j-1 ) = conjg( ap( kx ) )
283 ap( kc+kp-1 ) = conjg( ap( kc+kp-1 ) )
285 ap( kc+k-1 ) = ap( kpc+kp-1 )
286 ap( kpc+kp-1 ) = temp
287 IF( kstep.EQ.2 )
THEN
288 temp = ap( kc+k+k-1 )
289 ap( kc+k+k-1 ) = ap( kc+k+kp-1 )
290 ap( kc+k+kp-1 ) = temp
316 kcnext = kc - ( n-k+2 )
317 IF( ipiv( k ).GT.0 )
THEN
323 ap( kc ) = one / real( ap( kc ) )
328 CALL ccopy( n-k, ap( kc+1 ), 1, work, 1 )
329 CALL chpmv( uplo, n-k, -cone, ap( kc+n-k+1 ), work, 1,
330 $ zero, ap( kc+1 ), 1 )
331 ap( kc ) = ap( kc ) - real( cdotc( n-k, work, 1,
341 t = abs( ap( kcnext+1 ) )
342 ak = real( ap( kcnext ) ) / t
343 akp1 = real( ap( kc ) ) / t
344 akkp1 = ap( kcnext+1 ) / t
345 d = t*( ak*akp1-one )
346 ap( kcnext ) = akp1 / d
348 ap( kcnext+1 ) = -akkp1 / d
353 CALL ccopy( n-k, ap( kc+1 ), 1, work, 1 )
354 CALL chpmv( uplo, n-k, -cone, ap( kc+( n-k+1 ) ),
356 $ 1, zero, ap( kc+1 ), 1 )
357 ap( kc ) = ap( kc ) - real( cdotc( n-k, work, 1,
359 ap( kcnext+1 ) = ap( kcnext+1 ) -
360 $ cdotc( n-k, ap( kc+1 ), 1,
361 $ ap( kcnext+2 ), 1 )
362 CALL ccopy( n-k, ap( kcnext+2 ), 1, work, 1 )
363 CALL chpmv( uplo, n-k, -cone, ap( kc+( n-k+1 ) ),
365 $ 1, zero, ap( kcnext+2 ), 1 )
366 ap( kcnext ) = ap( kcnext ) -
367 $ real( cdotc( n-k, work, 1,
372 kcnext = kcnext - ( n-k+3 )
375 kp = abs( ipiv( k ) )
381 kpc = npp - ( n-kp+1 )*( n-kp+2 ) / 2 + 1
383 $
CALL cswap( n-kp, ap( kc+kp-k+1 ), 1, ap( kpc+1 ), 1 )
385 DO 70 j = k + 1, kp - 1
387 temp = conjg( ap( kc+j-k ) )
388 ap( kc+j-k ) = conjg( ap( kx ) )
391 ap( kc+kp-k ) = conjg( ap( kc+kp-k ) )
395 IF( kstep.EQ.2 )
THEN
396 temp = ap( kc-n+k-1 )
397 ap( kc-n+k-1 ) = ap( kc-n+kp-1 )
398 ap( kc-n+kp-1 ) = temp