Previous Next Contents Generated Index Doc Set Home



Reciprocal Condition Number of a UDU- or LDL-Factored Hermitian Matrix

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

Calling Sequence

CALL ZHECON 
(UPLO, N, ZA, LDA, IPIVOT, DANORM, DRCOND, ZWORK, INFO)
CALL CHECON 
(UPLO, N, CA, LDA, IPIVOT, SANORM, SRCOND, CWORK, INFO)






void zhecon 
(char uplo, int n, doublecomplex *za, int lda, int 
*ipivot, double danorm, double *drcond, int *info)
void checon 
(char uplo, int n, complex *ca, int lda, int *ipivot, 
float sanorm, float *srcond, 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

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

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.

xANORM

The 1-norm or -norm of matrix A.

xRCOND

On exit, the estimated reciprocal of the condition number of the matrix A where the reciprocal condition number of A is defined to be 1 / (ANORM × ||A-1||). The reciprocal of the condition number is estimated instead of the condition number itself to avoid overflow or division by zero. If RCOND is less than machine precision (in particular, if RCOND = 0) then A is singular to working precision.

xWORK

Scratch array with a dimension of 2 × N.

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

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

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDB, LDWORK, N, NRHS
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = N)
      PARAMETER        (LDWORK = 2 * N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  ANORM, ANORM1, RCOND
      COMPLEX*16        A(LDA,N), B(LDB,NRHS), WORK(LDWORK)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW
C
      EXTERNAL          ZHECON, ZHETRF, ZHETRS
      INTRINSIC         ABS, CONJG, DBLE, MAX
C
C     Initialize the array A to store the coefficient array A
C     shown below.  Initialize the array B to store the right
C     hand side vector b shown below.
C
C         1    1-i  1-i        4+i
C     A = 1+i   3   3-i    b = 4+6i
C         1+i  3+i   5         4+7i
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) /
      DATA B / (4.0D0,1.0D0), (4.0D0,6.0D0), (4.0D0,7.0D0) /
C
C     Print the initial value of the arrays.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (CONJG(A(ICOL,IROW)), ICOL = 1, IROW - 1),
     $              (A(IROW,ICOL), ICOL = IROW, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, N
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
      PRINT 1030
      DO 130, ICOL = 1, NRHS
        DO 120, IROW = 1, N
          PRINT 1010, B(IROW,ICOL)
  120   CONTINUE
  130 CONTINUE
C
C     Compute the 1-norm of A.  This will be used by ZHECON to
C     estimate the condition number of A.
C
      ANORM = 0.0D0
      DO 160, IROW = 1, N
        ANORM1 = 0.0D0
        DO 140, ICOL = 1, IROW - 1
          ANORM1 = ANORM1 + ABS(A(ICOL,IROW))
  140   CONTINUE
        ANORM1 = ANORM1 + ABS(DBLE(A(IROW,IROW)))
        DO 150, ICOL = IROW + 1, N
          ANORM1 = ANORM1 + ABS(A(IROW,ICOL))
  150   CONTINUE
        IF (ANORM .LT. ANORM1) THEN
          ANORM = ANORM1
        END IF
  160 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     Estimate the condition number.  Print a warning if it is
C     unreasonably high.
C
      CALL ZHECON ('UPPER TRIANGULAR FACTOR OF A', N, A, LDA,
     $             IPIVOT, ANORM, RCOND, WORK, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1060, ABS(INFO)
        STOP 3
      END IF
      PRINT 1070, RCOND
      IF ((1.0D0 + RCOND) .EQ. 1.0D0) THEN
        PRINT 1080
      END IF
C
C     Compute and print the solution.
C
      CALL ZHETRS ('UPPER TRIANGULAR FACTOR OF A', N, NRHS,
     $             A, LDA, IPIVOT, B, LDB, INFO)
      IF (INFO .LT. 0) THEN
        PRINT 1090, ABS(INFO)
        STOP 4
      END IF
      PRINT 1100
      DO 210, ICOL = 1, NRHS
        DO 200, IROW = 1, N
          PRINT 1010, B(IROW,ICOL)
  200   CONTINUE
  210 CONTINUE
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (1X, 10(: 2X, '(', F4.1, ',', F4.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 ZHECON, argument #', I2)
 1070 FORMAT (/1X,
     $        'Estimated reciprocal condition number of A: ',
     $        F5.3)
 1080 FORMAT (1X, 'A may be singular to working precision.')
 1090 FORMAT (1X, 'Illegal argument to ZHETRS, argument #', I2)
 1100 FORMAT (/1X, 'x:')
C
      END
 

Sample Output

 
 A in full form:
   ( 1.0,****)  ( 1.0,-1.0)  ( 1.0,-1.0)
   ( 1.0, 1.0)  ( 3.0,****)  ( 3.0,-1.0)
   ( 1.0, 1.0)  ( 3.0, 1.0)  ( 5.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,****)



 b:
   ( 4.0, 1.0)
   ( 4.0, 6.0)
   ( 4.0, 7.0)



 Estimated reciprocal condition number of A: 0.011



 x:
   ( 1.0, 0.0)
   ( 0.0, 2.0)
   ( 1.0, 0.0)






Previous Next Contents Generated Index Doc Set Home