Previous Next Contents Generated Index Doc Set Home



Inverse of a UDU- or LDL-Factored Hermitian Matrix

The subroutines described in this section compute the inverse of a Hermitian matrix A, which has been UDU-factored or LDL-factored by xHETRF.

Calling Sequence

CALL ZHETRI 
(UPLO, N, ZA, LDA, IPIVOT, ZWORK, INFO)
CALL CHETRI 
(UPLO, N, CA, LDA, IPIVOT, CWORK, INFO)






void zhetri 
(char uplo, int n, doublecomplex *za, int lda, int 
*ipivot, int *info)
void chetri 
(char uplo, int n, complex *ca, int lda, int *ipivot, 
int *info)

Arguments

UPLO

Indicates whether xA contains the upper or lower triangle of the matrix. The legal values for UPLO are listed below. Any values not listed below are illegal.

'U' or 'u'

xA contains the upper triangle.

'L' or 'l'

xA contains the lower triangle.

N

Order of the matrix A. N 0.

xA

On entry, the UDU or LDL factorization of the matrix A, as computed by xHETRF.

On exit, the Hermitian inverse of the matrix A.

If UPLO = 'U' or 'u', the upper triangular part of the inverse is formed and the part of A below the diagonal is not used.

If UPLO = 'L' or 'l' the lower triangular part of the inverse is formed and the part of A above the diagonal is not used.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA max(1, N).

IPIVOT

Pivot indices as computed by xHETRF.

xWORK

Scratch array with a dimension of N.

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

INFO > 0

D(i,i), where i = INFO, is zero. The matrix is therefore singular and its inverse could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      DOUBLE PRECISION  ZERO
      INTEGER           LDA, LDWORK, N
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDWORK = 2 * N)
      PARAMETER        (ZERO = 0.0D0)
C
      COMPLEX*16        A(LDA,N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW
C
      EXTERNAL          ZHETRF, ZHETRI
      INTRINSIC         ABS, CMPLX, CONJG, DBLE
C
C     Initialize the array A to store the coefficient array A
C     shown below.
C
C          1    1-i   1-i
C     A = 1+i    3    3-i
C         1+i   3+i    5
C
      DATA A / (1.0D0,8D8),    (8D8,8D8),      (8D8,8D8),
     $         (1.0D0,-1.0D0), (3.0D0,8D8),    (8D8,8D8),
     $         (1.0D0,-1.0D0), (3.0D0,-1.0D0), (5.0D0,8D8) /
C
C     Print the initial value of A.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (CONJG(A(ICOL,IROW)), ICOL = 1, IROW - 1),
     $              CMPLX(DBLE(A(IROW,IROW)), ZERO),
     $              (A(IROW,ICOL), ICOL = IROW + 1, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, N
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
C
C     Factor the matrix.
C
      CALL ZHETRF ('UPPER TRIANGLE OF A STORED', N, A, LDA,
     $             IPIVOT, WORK, LDWORK, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1040, ABS(INFO)
        STOP 1
      ELSE IF (INFO .GT. 0) THEN
        PRINT 1050
        STOP 2
      END IF
C
C     Compute and print the inverse.
C
      CALL ZHETRI ('UPPER TRIANGULAR FACTOR OF A', N, A, LDA,
     $             IPIVOT, WORK, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1060, ABS(INFO)
        STOP 3
      END IF
      PRINT 1070
      DO 200, IROW = 1, N
        PRINT 1010, (CONJG(A(ICOL,IROW)), ICOL = 1, IROW - 1),
     $              (A(IROW,ICOL), ICOL = IROW, N)
  200 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 10(: 2X, '(', F5.1, ',', F5.1, ')'))
 1020 FORMAT (/1X, 'A in Hermitian form:  (* in unused entries)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, 'Illegal argument to ZHETRF, argument #', I2)
 1050 FORMAT (1X, 'A is singular to working precision.')
 1060 FORMAT (1X, 'Illegal argument to ZHETRI, argument #', I2)
 1070 FORMAT (/1X, 'A**(-1):')
C
      END
 

Sample Output

 
 A in full form:
   (  1.0,  0.0)  (  1.0, -1.0)  (  1.0, -1.0)
   (  1.0,  1.0)  (  3.0,  0.0)  (  3.0, -1.0)
   (  1.0,  1.0)  (  3.0,  1.0)  (  5.0,  0.0)



 A in Hermitian form:  (* in unused entries)
   (  1.0,*****)  (  1.0, -1.0)  (  1.0, -1.0)
   (*****,*****)  (  3.0,*****)  (  3.0, -1.0)
   (*****,*****)  (*****,*****)  (  5.0,*****)



 A**(-1):
   (  5.0,  0.0)  ( -1.0,  3.0)  ( -1.0, -1.0)
   ( -1.0, -3.0)  (  3.0,  0.0)  ( -1.0,  1.0)
   ( -1.0,  1.0)  ( -1.0, -1.0)  (  1.0,  0.0)






Previous Next Contents Generated Index Doc Set Home