111 SUBROUTINE chetri( UPLO, N, A, LDA, IPIV, WORK, INFO )
123 COMPLEX A( LDA, * ), WORK( * )
131 parameter( one = 1.0e+0, cone = ( 1.0e+0, 0.0e+0 ),
132 $ zero = ( 0.0e+0, 0.0e+0 ) )
136 INTEGER J, K, KP, KSTEP
143 EXTERNAL lsame, cdotc
149 INTRINSIC abs, conjg, max, real
156 upper = lsame( uplo,
'U' )
157 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
159 ELSE IF( n.LT.0 )
THEN
161 ELSE IF( lda.LT.max( 1, n ) )
THEN
165 CALL xerbla(
'CHETRI', -info )
180 DO 10 info = n, 1, -1
181 IF( ipiv( info ).GT.0 .AND. a( info, info ).EQ.zero )
189 IF( ipiv( info ).GT.0 .AND. a( info, info ).EQ.zero )
210 IF( ipiv( k ).GT.0 )
THEN
216 a( k, k ) = one / real( a( k, k ) )
221 CALL ccopy( k-1, a( 1, k ), 1, work, 1 )
222 CALL chemv( uplo, k-1, -cone, a, lda, work, 1, zero,
224 a( k, k ) = a( k, k ) - real( cdotc( k-1, work, 1,
235 t = abs( a( k, k+1 ) )
236 ak = real( a( k, k ) ) / t
237 akp1 = real( a( k+1, k+1 ) ) / t
238 akkp1 = a( k, k+1 ) / t
239 d = t*( ak*akp1-one )
241 a( k+1, k+1 ) = ak / d
242 a( k, k+1 ) = -akkp1 / d
247 CALL ccopy( k-1, a( 1, k ), 1, work, 1 )
248 CALL chemv( uplo, k-1, -cone, a, lda, work, 1, zero,
250 a( k, k ) = a( k, k ) - real( cdotc( k-1, work, 1,
253 a( k, k+1 ) = a( k, k+1 ) -
254 $ cdotc( k-1, a( 1, k ), 1, a( 1, k+1 ),
256 CALL ccopy( k-1, a( 1, k+1 ), 1, work, 1 )
257 CALL chemv( uplo, k-1, -cone, a, lda, work, 1, zero,
259 a( k+1, k+1 ) = a( k+1, k+1 ) -
260 $ real( cdotc( k-1, work, 1, a( 1,
267 kp = abs( ipiv( k ) )
273 CALL cswap( kp-1, a( 1, k ), 1, a( 1, kp ), 1 )
274 DO 40 j = kp + 1, k - 1
275 temp = conjg( a( j, k ) )
276 a( j, k ) = conjg( a( kp, j ) )
279 a( kp, k ) = conjg( a( kp, k ) )
281 a( k, k ) = a( kp, kp )
283 IF( kstep.EQ.2 )
THEN
285 a( k, k+1 ) = a( kp, k+1 )
309 IF( ipiv( k ).GT.0 )
THEN
315 a( k, k ) = one / real( a( k, k ) )
320 CALL ccopy( n-k, a( k+1, k ), 1, work, 1 )
321 CALL chemv( uplo, n-k, -cone, a( k+1, k+1 ), lda,
323 $ 1, zero, a( k+1, k ), 1 )
324 a( k, k ) = a( k, k ) - real( cdotc( n-k, work, 1,
334 t = abs( a( k, k-1 ) )
335 ak = real( a( k-1, k-1 ) ) / t
336 akp1 = real( a( k, k ) ) / t
337 akkp1 = a( k, k-1 ) / t
338 d = t*( ak*akp1-one )
339 a( k-1, k-1 ) = akp1 / d
341 a( k, k-1 ) = -akkp1 / d
346 CALL ccopy( n-k, a( k+1, k ), 1, work, 1 )
347 CALL chemv( uplo, n-k, -cone, a( k+1, k+1 ), lda,
349 $ 1, zero, a( k+1, k ), 1 )
350 a( k, k ) = a( k, k ) - real( cdotc( n-k, work, 1,
352 a( k, k-1 ) = a( k, k-1 ) -
353 $ cdotc( n-k, a( k+1, k ), 1, a( k+1,
356 CALL ccopy( n-k, a( k+1, k-1 ), 1, work, 1 )
357 CALL chemv( uplo, n-k, -cone, a( k+1, k+1 ), lda,
359 $ 1, zero, a( k+1, k-1 ), 1 )
360 a( k-1, k-1 ) = a( k-1, k-1 ) -
361 $ real( cdotc( n-k, work, 1, a( k+1,
368 kp = abs( ipiv( k ) )
375 $
CALL cswap( n-kp, a( kp+1, k ), 1, a( kp+1, kp ), 1 )
376 DO 70 j = k + 1, kp - 1
377 temp = conjg( a( j, k ) )
378 a( j, k ) = conjg( a( kp, j ) )
381 a( kp, k ) = conjg( a( kp, k ) )
383 a( k, k ) = a( kp, kp )
385 IF( kstep.EQ.2 )
THEN
387 a( k, k-1 ) = a( kp, k-1 )