117 SUBROUTINE chetri2x( UPLO, N, A, LDA, IPIV, WORK, NB, INFO )
125 INTEGER INFO, LDA, N, NB
129 COMPLEX A( LDA, * ), WORK( N+NB+1,* )
137 parameter( one = 1.0e+0,
138 $ cone = ( 1.0e+0, 0.0e+0 ),
139 $ zero = ( 0.0e+0, 0.0e+0 ) )
143 INTEGER I, IINFO, IP, K, CUT, NNB
147 COMPLEX AK, AKKP1, AKP1, D, T
148 COMPLEX U01_I_J, U01_IP1_J
149 COMPLEX U11_I_J, U11_IP1_J
167 upper = lsame( uplo,
'U' )
168 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
170 ELSE IF( n.LT.0 )
THEN
172 ELSE IF( lda.LT.max( 1, n ) )
THEN
180 CALL xerbla(
'CHETRI2X', -info )
189 CALL csyconv( uplo,
'C', n, a, lda, ipiv, work, iinfo )
198 IF( ipiv( info ).GT.0 .AND. a( info, info ).EQ.zero )
206 IF( ipiv( info ).GT.0 .AND. a( info, info ).EQ.zero )
226 CALL ctrtri( uplo,
'U', n, a, lda, info )
231 DO WHILE ( k .LE. n )
232 IF( ipiv( k ).GT.0 )
THEN
234 work(k,invd) = one / real( a( k, k ) )
239 t = abs( work(k+1,1) )
240 ak = real( a( k, k ) ) / t
241 akp1 = real( a( k+1, k+1 ) ) / t
242 akkp1 = work(k+1,1) / t
243 d = t*( ak*akp1-one )
244 work(k,invd) = akp1 / d
245 work(k+1,invd+1) = ak / d
246 work(k,invd+1) = -akkp1 / d
247 work(k+1,invd) = conjg(work(k,invd+1) )
257 DO WHILE (cut .GT. 0)
259 IF (cut .LE. nnb)
THEN
265 IF (ipiv(i) .LT. 0) count=count+1
268 IF (mod(count,2) .EQ. 1) nnb=nnb+1
289 work(u11+i,j)=a(cut+i,cut+j)
296 DO WHILE (i .LE. cut)
297 IF (ipiv(i) > 0)
THEN
299 work(i,j)=work(i,invd)*work(i,j)
305 u01_ip1_j = work(i+1,j)
306 work(i,j)=work(i,invd)*u01_i_j+
307 $ work(i,invd+1)*u01_ip1_j
308 work(i+1,j)=work(i+1,invd)*u01_i_j+
309 $ work(i+1,invd+1)*u01_ip1_j
318 DO WHILE (i .LE. nnb)
319 IF (ipiv(cut+i) > 0)
THEN
321 work(u11+i,j)=work(cut+i,invd)*work(u11+i,j)
326 u11_i_j = work(u11+i,j)
327 u11_ip1_j = work(u11+i+1,j)
328 work(u11+i,j)=work(cut+i,invd)*work(u11+i,j) +
329 $ work(cut+i,invd+1)*work(u11+i+1,j)
330 work(u11+i+1,j)=work(cut+i+1,invd)*u11_i_j+
331 $ work(cut+i+1,invd+1)*u11_ip1_j
339 CALL ctrmm(
'L',
'U',
'C',
'U',nnb, nnb,
340 $ cone,a(cut+1,cut+1),lda,work(u11+1,1),n+nb+1)
344 a(cut+i,cut+j)=work(u11+i,j)
350 CALL cgemm(
'C',
'N',nnb,nnb,cut,cone,a(1,cut+1),lda,
351 $ work,n+nb+1, zero, work(u11+1,1), n+nb+1)
357 a(cut+i,cut+j)=a(cut+i,cut+j)+work(u11+i,j)
363 CALL ctrmm(
'L',uplo,
'C',
'U',cut, nnb,
364 $ cone,a,lda,work,n+nb+1)
382 DO WHILE ( i .LE. n )
383 IF( ipiv(i) .GT. 0 )
THEN
385 IF (i .LT. ip)
CALL cheswapr( uplo, n, a, lda, i ,
387 IF (i .GT. ip)
CALL cheswapr( uplo, n, a, lda, ip ,
393 $
CALL cheswapr( uplo, n, a, lda, i-1 ,ip )
395 $
CALL cheswapr( uplo, n, a, lda, ip ,i-1 )
405 CALL ctrtri( uplo,
'U', n, a, lda, info )
410 DO WHILE ( k .GE. 1 )
411 IF( ipiv( k ).GT.0 )
THEN
413 work(k,invd) = one / real( a( k, k ) )
418 t = abs( work(k-1,1) )
419 ak = real( a( k-1, k-1 ) ) / t
420 akp1 = real( a( k, k ) ) / t
421 akkp1 = work(k-1,1) / t
422 d = t*( ak*akp1-one )
423 work(k-1,invd) = akp1 / d
424 work(k,invd) = ak / d
425 work(k,invd+1) = -akkp1 / d
426 work(k-1,invd+1) = conjg(work(k,invd+1) )
436 DO WHILE (cut .LT. n)
438 IF (cut + nnb .GE. n)
THEN
444 IF (ipiv(i) .LT. 0) count=count+1
447 IF (mod(count,2) .EQ. 1) nnb=nnb+1
452 work(i,j)=a(cut+nnb+i,cut+j)
462 work(u11+i,j)=a(cut+i,cut+j)
470 IF (ipiv(cut+nnb+i) > 0)
THEN
472 work(i,j)=work(cut+nnb+i,invd)*work(i,j)
478 u01_ip1_j = work(i-1,j)
479 work(i,j)=work(cut+nnb+i,invd)*u01_i_j+
480 $ work(cut+nnb+i,invd+1)*u01_ip1_j
481 work(i-1,j)=work(cut+nnb+i-1,invd+1)*u01_i_j+
482 $ work(cut+nnb+i-1,invd)*u01_ip1_j
492 IF (ipiv(cut+i) > 0)
THEN
494 work(u11+i,j)=work(cut+i,invd)*work(u11+i,j)
499 u11_i_j = work(u11+i,j)
500 u11_ip1_j = work(u11+i-1,j)
501 work(u11+i,j)=work(cut+i,invd)*work(u11+i,j) +
502 $ work(cut+i,invd+1)*u11_ip1_j
503 work(u11+i-1,j)=work(cut+i-1,invd+1)*u11_i_j+
504 $ work(cut+i-1,invd)*u11_ip1_j
512 CALL ctrmm(
'L',uplo,
'C',
'U',nnb, nnb,
513 $ cone,a(cut+1,cut+1),lda,work(u11+1,1),n+nb+1)
517 a(cut+i,cut+j)=work(u11+i,j)
521 IF ( (cut+nnb) .LT. n )
THEN
525 CALL cgemm(
'C',
'N',nnb,nnb,n-nnb-cut,cone,a(cut+nnb+1,cut+1)
526 $ ,lda,work,n+nb+1, zero, work(u11+1,1), n+nb+1)
533 a(cut+i,cut+j)=a(cut+i,cut+j)+work(u11+i,j)
539 CALL ctrmm(
'L',uplo,
'C',
'U', n-nnb-cut, nnb,
540 $ cone,a(cut+nnb+1,cut+nnb+1),lda,work,n+nb+1)
545 a(cut+nnb+i,cut+j)=work(i,j)
554 a(cut+i,cut+j)=work(u11+i,j)
567 DO WHILE ( i .GE. 1 )
568 IF( ipiv(i) .GT. 0 )
THEN
570 IF (i .LT. ip)
CALL cheswapr( uplo, n, a, lda, i ,
572 IF (i .GT. ip)
CALL cheswapr( uplo, n, a, lda, ip ,
576 IF ( i .LT. ip)
CALL cheswapr( uplo, n, a, lda, i ,
578 IF ( i .GT. ip)
CALL cheswapr( uplo, n, a, lda, ip ,