108 SUBROUTINE chptri( UPLO, N, AP, IPIV, WORK, INFO )
120 COMPLEX AP( * ), WORK( * )
128 parameter( one = 1.0e+0, cone = ( 1.0e+0, 0.0e+0 ),
129 $ zero = ( 0.0e+0, 0.0e+0 ) )
133 INTEGER J, K, KC, KCNEXT, KP, KPC, KSTEP, KX, NPP
140 EXTERNAL lsame, cdotc
146 INTRINSIC abs, conjg, real
153 upper = lsame( uplo,
'U' )
154 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
156 ELSE IF( n.LT.0 )
THEN
160 CALL xerbla(
'CHPTRI', -info )
176 DO 10 info = n, 1, -1
177 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
187 IF( ipiv( info ).GT.0 .AND. ap( kp ).EQ.zero )
189 kp = kp + n - info + 1
211 IF( ipiv( k ).GT.0 )
THEN
217 ap( kc+k-1 ) = one / real( ap( kc+k-1 ) )
222 CALL ccopy( k-1, ap( kc ), 1, work, 1 )
223 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
225 ap( kc+k-1 ) = ap( kc+k-1 ) -
226 $ real( cdotc( k-1, work, 1, ap( kc ), 1 ) )
235 t = abs( ap( kcnext+k-1 ) )
236 ak = real( ap( kc+k-1 ) ) / t
237 akp1 = real( ap( kcnext+k ) ) / t
238 akkp1 = ap( kcnext+k-1 ) / t
239 d = t*( ak*akp1-one )
240 ap( kc+k-1 ) = akp1 / d
241 ap( kcnext+k ) = ak / d
242 ap( kcnext+k-1 ) = -akkp1 / d
247 CALL ccopy( k-1, ap( kc ), 1, work, 1 )
248 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
250 ap( kc+k-1 ) = ap( kc+k-1 ) -
251 $ real( cdotc( k-1, work, 1, ap( kc ), 1 ) )
252 ap( kcnext+k-1 ) = ap( kcnext+k-1 ) -
253 $ cdotc( k-1, ap( kc ), 1, ap( kcnext ),
255 CALL ccopy( k-1, ap( kcnext ), 1, work, 1 )
256 CALL chpmv( uplo, k-1, -cone, ap, work, 1, zero,
258 ap( kcnext+k ) = ap( kcnext+k ) -
259 $ real( cdotc( k-1, work, 1, ap( kcnext ),
263 kcnext = kcnext + k + 1
266 kp = abs( ipiv( k ) )
272 kpc = ( kp-1 )*kp / 2 + 1
273 CALL cswap( kp-1, ap( kc ), 1, ap( kpc ), 1 )
275 DO 40 j = kp + 1, k - 1
277 temp = conjg( ap( kc+j-1 ) )
278 ap( kc+j-1 ) = conjg( ap( kx ) )
281 ap( kc+kp-1 ) = conjg( ap( kc+kp-1 ) )
283 ap( kc+k-1 ) = ap( kpc+kp-1 )
284 ap( kpc+kp-1 ) = temp
285 IF( kstep.EQ.2 )
THEN
286 temp = ap( kc+k+k-1 )
287 ap( kc+k+k-1 ) = ap( kc+k+kp-1 )
288 ap( kc+k+kp-1 ) = temp
314 kcnext = kc - ( n-k+2 )
315 IF( ipiv( k ).GT.0 )
THEN
321 ap( kc ) = one / real( ap( kc ) )
326 CALL ccopy( n-k, ap( kc+1 ), 1, work, 1 )
327 CALL chpmv( uplo, n-k, -cone, ap( kc+n-k+1 ), work, 1,
328 $ zero, ap( kc+1 ), 1 )
329 ap( kc ) = ap( kc ) - real( cdotc( n-k, work, 1,
339 t = abs( ap( kcnext+1 ) )
340 ak = real( ap( kcnext ) ) / t
341 akp1 = real( ap( kc ) ) / t
342 akkp1 = ap( kcnext+1 ) / t
343 d = t*( ak*akp1-one )
344 ap( kcnext ) = akp1 / d
346 ap( kcnext+1 ) = -akkp1 / d
351 CALL ccopy( n-k, ap( kc+1 ), 1, work, 1 )
352 CALL chpmv( uplo, n-k, -cone, ap( kc+( n-k+1 ) ), work,
353 $ 1, zero, ap( kc+1 ), 1 )
354 ap( kc ) = ap( kc ) - real( cdotc( n-k, work, 1,
356 ap( kcnext+1 ) = ap( kcnext+1 ) -
357 $ cdotc( n-k, ap( kc+1 ), 1,
358 $ ap( kcnext+2 ), 1 )
359 CALL ccopy( n-k, ap( kcnext+2 ), 1, work, 1 )
360 CALL chpmv( uplo, n-k, -cone, ap( kc+( n-k+1 ) ), work,
361 $ 1, zero, ap( kcnext+2 ), 1 )
362 ap( kcnext ) = ap( kcnext ) -
363 $ real( cdotc( n-k, work, 1, ap( kcnext+2 ),
367 kcnext = kcnext - ( n-k+3 )
370 kp = abs( ipiv( k ) )
376 kpc = npp - ( n-kp+1 )*( n-kp+2 ) / 2 + 1
378 $
CALL cswap( n-kp, ap( kc+kp-k+1 ), 1, ap( kpc+1 ), 1 )
380 DO 70 j = k + 1, kp - 1
382 temp = conjg( ap( kc+j-k ) )
383 ap( kc+j-k ) = conjg( ap( kx ) )
386 ap( kc+kp-k ) = conjg( ap( kc+kp-k ) )
390 IF( kstep.EQ.2 )
THEN
391 temp = ap( kc-n+k-1 )
392 ap( kc-n+k-1 ) = ap( kc-n+kp-1 )
393 ap( kc-n+kp-1 ) = temp
subroutine xerbla(srname, info)
subroutine ccopy(n, cx, incx, cy, incy)
CCOPY
subroutine chpmv(uplo, n, alpha, ap, x, incx, beta, y, incy)
CHPMV
subroutine chptri(uplo, n, ap, ipiv, work, info)
CHPTRI
subroutine cswap(n, cx, incx, cy, incy)
CSWAP