3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZSYTRI2X + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zsytri2x.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zsytri2x.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zsytri2x.f">
21 * SUBROUTINE ZSYTRI2X( UPLO, N, A, LDA, IPIV, WORK, NB, INFO )
23 * .. Scalar Arguments ..
25 * INTEGER INFO, LDA, N, NB
27 * .. Array Arguments ..
29 * COMPLEX*16 A( LDA, * ), WORK( N+NB+1,* )
38 *> ZSYTRI2X computes the inverse of a complex symmetric indefinite matrix
39 *> A using the factorization A = U*D*U**T or A = L*D*L**T computed by
48 *> UPLO is CHARACTER*1
49 *> Specifies whether the details of the factorization are stored
50 *> as an upper or lower triangular matrix.
51 *> = 'U': Upper triangular, form is A = U*D*U**T;
52 *> = 'L': Lower triangular, form is A = L*D*L**T.
58 *> The order of the matrix A. N >= 0.
63 *> A is COMPLEX*16 array, dimension (LDA,N)
64 *> On entry, the NNB diagonal matrix D and the multipliers
65 *> used to obtain the factor U or L as computed by ZSYTRF.
67 *> On exit, if INFO = 0, the (symmetric) inverse of the original
68 *> matrix. If UPLO = 'U', the upper triangular part of the
69 *> inverse is formed and the part of A below the diagonal is not
70 *> referenced; if UPLO = 'L' the lower triangular part of the
71 *> inverse is formed and the part of A above the diagonal is
78 *> The leading dimension of the array A. LDA >= max(1,N).
83 *> IPIV is INTEGER array, dimension (N)
84 *> Details of the interchanges and the NNB structure of D
85 *> as determined by ZSYTRF.
90 *> WORK is COMPLEX*16 array, dimension (N+NNB+1,NNB+3)
102 *> = 0: successful exit
103 *> < 0: if INFO = -i, the i-th argument had an illegal value
104 *> > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its
105 *> inverse could not be computed.
111 *> \author Univ. of Tennessee
112 *> \author Univ. of California Berkeley
113 *> \author Univ. of Colorado Denver
116 *> \date November 2011
118 *> \ingroup complex16SYcomputational
120 * =====================================================================
121 SUBROUTINE ZSYTRI2X( UPLO, N, A, LDA, IPIV, WORK, NB, INFO )
123 * -- LAPACK computational routine (version 3.4.0) --
124 * -- LAPACK is a software package provided by Univ. of Tennessee, --
125 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
128 * .. Scalar Arguments ..
130 INTEGER INFO, LDA, N, NB
132 * .. Array Arguments ..
134 COMPLEX*16 A( LDA, * ), WORK( N+NB+1,* )
137 * =====================================================================
141 PARAMETER ( ONE = ( 1.0D+0, 0.0D+0 ),
142 $ ZERO = ( 0.0D+0, 0.0D+0 ) )
144 * .. Local Scalars ..
146 INTEGER I, IINFO, IP, K, CUT, NNB
150 COMPLEX*16 AK, AKKP1, AKP1, D, T
151 COMPLEX*16 U01_I_J, U01_IP1_J
152 COMPLEX*16 U11_I_J, U11_IP1_J
154 * .. External Functions ..
158 * .. External Subroutines ..
159 EXTERNAL ZSYCONV, XERBLA, ZTRTRI
160 EXTERNAL ZGEMM, ZTRMM, ZSYSWAPR
162 * .. Intrinsic Functions ..
165 * .. Executable Statements ..
167 * Test the input parameters.
170 UPPER = LSAME( UPLO, 'U' )
171 IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
173 ELSE IF( N.LT.0 ) THEN
175 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
179 * Quick return if possible
183 CALL XERBLA( 'ZSYTRI2X', -INFO )
190 * Workspace got Non-diag elements of D
192 CALL ZSYCONV( UPLO, 'C', N, A, LDA, IPIV, WORK, IINFO )
194 * Check that the diagonal matrix D is nonsingular.
198 * Upper triangular storage: examine D from bottom to top
201 IF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO )
206 * Lower triangular storage: examine D from top to bottom.
209 IF( IPIV( INFO ).GT.0 .AND. A( INFO, INFO ).EQ.ZERO )
215 * Splitting Workspace
216 * U01 is a block (N,NB+1)
217 * The first element of U01 is in WORK(1,1)
218 * U11 is a block (NB+1,NB+1)
219 * The first element of U11 is in WORK(N+1,1)
221 * INVD is a block (N,2)
222 * The first element of INVD is in WORK(1,INVD)
227 * invA = P * inv(U**T)*inv(D)*inv(U)*P**T.
229 CALL ZTRTRI( UPLO, 'U', N, A, LDA, INFO )
231 * inv(D) and inv(D)*inv(U)
234 DO WHILE ( K .LE. N )
235 IF( IPIV( K ).GT.0 ) THEN
237 WORK(K,INVD) = 1/ A( K, K )
244 AKP1 = A( K+1, K+1 ) / T
245 AKKP1 = WORK(K+1,1) / T
246 D = T*( AK*AKP1-ONE )
247 WORK(K,INVD) = AKP1 / D
248 WORK(K+1,INVD+1) = AK / D
249 WORK(K,INVD+1) = -AKKP1 / D
250 WORK(K+1,INVD) = -AKKP1 / D
255 * inv(U**T) = (inv(U))**T
257 * inv(U**T)*inv(D)*inv(U)
260 DO WHILE (CUT .GT. 0)
262 IF (CUT .LE. NNB) THEN
266 * count negative elements,
268 IF (IPIV(I) .LT. 0) COUNT=COUNT+1
270 * need a even number for a clear cut
271 IF (MOD(COUNT,2) .EQ. 1) NNB=NNB+1
292 WORK(U11+I,J)=A(CUT+I,CUT+J)
299 DO WHILE (I .LE. CUT)
300 IF (IPIV(I) > 0) THEN
302 WORK(I,J)=WORK(I,INVD)*WORK(I,J)
308 U01_IP1_J = WORK(I+1,J)
309 WORK(I,J)=WORK(I,INVD)*U01_I_J+
310 $ WORK(I,INVD+1)*U01_IP1_J
311 WORK(I+1,J)=WORK(I+1,INVD)*U01_I_J+
312 $ WORK(I+1,INVD+1)*U01_IP1_J
321 DO WHILE (I .LE. NNB)
322 IF (IPIV(CUT+I) > 0) THEN
324 WORK(U11+I,J)=WORK(CUT+I,INVD)*WORK(U11+I,J)
329 U11_I_J = WORK(U11+I,J)
330 U11_IP1_J = WORK(U11+I+1,J)
331 WORK(U11+I,J)=WORK(CUT+I,INVD)*WORK(U11+I,J) +
332 $ WORK(CUT+I,INVD+1)*WORK(U11+I+1,J)
333 WORK(U11+I+1,J)=WORK(CUT+I+1,INVD)*U11_I_J+
334 $ WORK(CUT+I+1,INVD+1)*U11_IP1_J
340 * U11**T*invD1*U11->U11
342 CALL ZTRMM('L','U','T','U',NNB, NNB,
343 $ ONE,A(CUT+1,CUT+1),LDA,WORK(U11+1,1),N+NB+1)
347 A(CUT+I,CUT+J)=WORK(U11+I,J)
351 * U01**T*invD*U01->A(CUT+I,CUT+J)
353 CALL ZGEMM('T','N',NNB,NNB,CUT,ONE,A(1,CUT+1),LDA,
354 $ WORK,N+NB+1, ZERO, WORK(U11+1,1), N+NB+1)
356 * U11 = U11**T*invD1*U11 + U01**T*invD*U01
360 A(CUT+I,CUT+J)=A(CUT+I,CUT+J)+WORK(U11+I,J)
364 * U01 = U00**T*invD0*U01
366 CALL ZTRMM('L',UPLO,'T','U',CUT, NNB,
367 $ ONE,A,LDA,WORK,N+NB+1)
382 * Apply PERMUTATIONS P and P**T: P * inv(U**T)*inv(D)*inv(U) *P**T
385 DO WHILE ( I .LE. N )
386 IF( IPIV(I) .GT. 0 ) THEN
388 IF (I .LT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, I ,IP )
389 IF (I .GT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, IP ,I )
394 $ CALL ZSYSWAPR( UPLO, N, A, LDA, I-1 ,IP )
396 $ CALL ZSYSWAPR( UPLO, N, A, LDA, IP ,I-1 )
404 * invA = P * inv(U**T)*inv(D)*inv(U)*P**T.
406 CALL ZTRTRI( UPLO, 'U', N, A, LDA, INFO )
408 * inv(D) and inv(D)*inv(U)
411 DO WHILE ( K .GE. 1 )
412 IF( IPIV( K ).GT.0 ) THEN
414 WORK(K,INVD) = 1/ A( K, K )
420 AK = A( K-1, K-1 ) / T
422 AKKP1 = WORK(K-1,1) / T
423 D = T*( AK*AKP1-ONE )
424 WORK(K-1,INVD) = AKP1 / D
425 WORK(K,INVD) = AK / D
426 WORK(K,INVD+1) = -AKKP1 / D
427 WORK(K-1,INVD+1) = -AKKP1 / D
432 * inv(U**T) = (inv(U))**T
434 * inv(U**T)*inv(D)*inv(U)
437 DO WHILE (CUT .LT. N)
439 IF (CUT + NNB .GE. N) THEN
443 * count negative elements,
445 IF (IPIV(I) .LT. 0) COUNT=COUNT+1
447 * need a even number for a clear cut
448 IF (MOD(COUNT,2) .EQ. 1) NNB=NNB+1
453 WORK(I,J)=A(CUT+NNB+I,CUT+J)
463 WORK(U11+I,J)=A(CUT+I,CUT+J)
471 IF (IPIV(CUT+NNB+I) > 0) THEN
473 WORK(I,J)=WORK(CUT+NNB+I,INVD)*WORK(I,J)
479 U01_IP1_J = WORK(I-1,J)
480 WORK(I,J)=WORK(CUT+NNB+I,INVD)*U01_I_J+
481 $ WORK(CUT+NNB+I,INVD+1)*U01_IP1_J
482 WORK(I-1,J)=WORK(CUT+NNB+I-1,INVD+1)*U01_I_J+
483 $ WORK(CUT+NNB+I-1,INVD)*U01_IP1_J
493 IF (IPIV(CUT+I) > 0) THEN
495 WORK(U11+I,J)=WORK(CUT+I,INVD)*WORK(U11+I,J)
500 U11_I_J = WORK(U11+I,J)
501 U11_IP1_J = WORK(U11+I-1,J)
502 WORK(U11+I,J)=WORK(CUT+I,INVD)*WORK(U11+I,J) +
503 $ WORK(CUT+I,INVD+1)*U11_IP1_J
504 WORK(U11+I-1,J)=WORK(CUT+I-1,INVD+1)*U11_I_J+
505 $ WORK(CUT+I-1,INVD)*U11_IP1_J
511 * L11**T*invD1*L11->L11
513 CALL ZTRMM('L',UPLO,'T','U',NNB, NNB,
514 $ ONE,A(CUT+1,CUT+1),LDA,WORK(U11+1,1),N+NB+1)
518 A(CUT+I,CUT+J)=WORK(U11+I,J)
523 IF ( (CUT+NNB) .LT. N ) THEN
525 * L21**T*invD2*L21->A(CUT+I,CUT+J)
527 CALL ZGEMM('T','N',NNB,NNB,N-NNB-CUT,ONE,A(CUT+NNB+1,CUT+1)
528 $ ,LDA,WORK,N+NB+1, ZERO, WORK(U11+1,1), N+NB+1)
531 * L11 = L11**T*invD1*L11 + U01**T*invD*U01
535 A(CUT+I,CUT+J)=A(CUT+I,CUT+J)+WORK(U11+I,J)
539 * U01 = L22**T*invD2*L21
541 CALL ZTRMM('L',UPLO,'T','U', N-NNB-CUT, NNB,
542 $ ONE,A(CUT+NNB+1,CUT+NNB+1),LDA,WORK,N+NB+1)
547 A(CUT+NNB+I,CUT+J)=WORK(I,J)
552 * L11 = L11**T*invD1*L11
556 A(CUT+I,CUT+J)=WORK(U11+I,J)
566 * Apply PERMUTATIONS P and P**T: P * inv(U**T)*inv(D)*inv(U) *P**T
569 DO WHILE ( I .GE. 1 )
570 IF( IPIV(I) .GT. 0 ) THEN
572 IF (I .LT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, I ,IP )
573 IF (I .GT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, IP ,I )
576 IF ( I .LT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, I ,IP )
577 IF ( I .GT. IP) CALL ZSYSWAPR( UPLO, N, A, LDA, IP ,I )