Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Hermitian Matrix (Simple Driver)

The subroutines described in this section solve a linear system AX = B for a Hermitian matrix A and general matrices B and X. Note that the expert driver xHESVX is also available.

Calling Sequence

CALL ZHESV 
(UPLO, N, NRHS, ZA, LDA, IPIVOT, ZB, LDB, DWORK, 
LDWORK, INFO)
CALL CHESV 
(UPLO, N, NRHS, CA, LDA, IPIVOT, CB, LDB, SWORK, 
LDWORK, INFO)






void zhesv 
(char uplo, int n, int nrhs, doublecomplex *za, int 
lda, int *ipivot, doublecomplex *zb, int ldb, int 
*info)
void chesv 
(char uplo, int n, int nrhs, complex *ca, int lda, int 
*ipivot, complex *cb, int ldb, 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.

NRHS

Number of right-hand sides, equal to the number of columns of the matrix B. NRHS 0.

xA

On entry, the upper or lower triangle of the matrix A.
On exit, the UDU or LDL factorization of 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

On exit, pivot indices as computed by xHETRF.

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, the N×NRHS solution matrix X.

LDB

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

xWORK

Scratch array with a dimension of LDWORK.

LDWORK

Leading dimension of the array WORK as specified in a dimension or type statement. LDWORK 1.

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 exactly zero and D is therefore singular. The UDU or LDL factorization has been completed, but the solution could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      DOUBLE PRECISION  ZERO
      INTEGER           LDA, LDB, LDWORK, N, NRHS
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = N)
      PARAMETER        (LDWORK = 1)
      PARAMETER        (NRHS = 1)
      PARAMETER        (ZERO = 0.0D0)
C
      COMPLEX*16        A(LDA,N), B(LDB,NRHS), WORK(LDWORK)
      INTEGER           ICOL, INFO, IPIVOT(N), IROW
C
      EXTERNAL          ZHESV
      INTRINSIC         ABS, CMPLX, CONJG, DBLE
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),
     $              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
      PRINT 1030
      DO 130, ICOL = 1, NRHS
        DO 120, IROW = 1, N
          PRINT 1010, B(IROW,ICOL)
  120   CONTINUE
  130 CONTINUE
C
C     Compute and print the solution.
C
      CALL ZHESV ('UPPER TRIANGLE OF A STORED', N, NRHS, A, LDA,
     $            IPIVOT, B, LDB, 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
      PRINT 1060
      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 ZHESV, argument #', I2)
 1050 FORMAT (1X, 'A is singular to working precision.')
 1060 FORMAT (/1X, 'x:')
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,****)



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



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






Previous Next Contents Generated Index Doc Set Home