
PROGRAM TEST

IMPLICIT NONE

C

DOUBLE PRECISION ZERO

INTEGER LDA, LDAF, LDB, LDWORK, LDWRK2, LDX

INTEGER N, NRHS

PARAMETER (N = 3)

PARAMETER (LDA = N)

PARAMETER (LDAF = N)

PARAMETER (LDB = N)

PARAMETER (LDWORK = 2 * N)

PARAMETER (LDWRK2 = N)

PARAMETER (LDX = N)

PARAMETER (NRHS = 1)

PARAMETER (ZERO = 0.0D0)

C

DOUBLE PRECISION BERR(NRHS), FERR(NRHS), RCOND

DOUBLE PRECISION WORK2(LDWRK2)

COMPLEX*16 A(LDA,N), AF(LDAF,N), B(LDB,NRHS)

COMPLEX*16 WORK(LDWORK)

COMPLEX*16 X(LDX,NRHS)

INTEGER ICOL, INFO, IPIVOT(N), IROW

C

EXTERNAL ZHESVX

INTRINSIC ABS, CMPLX, CONJG

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

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(A(IROW,IROW), ZERO),

$ (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 solution.

C

CALL ZHESVX ('NOT FACTORED A', 'UPPER TRIANGLE OF A STORED',

$ N, NRHS, A, LDA, AF, LDAF, IPIVOT, B, LDB, X,

$ LDX, RCOND, FERR, BERR, WORK, LDWORK, WORK2,

$ 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 Print the solution and error bounds.

C

PRINT 1060

DO 210, ICOL = 1, NRHS

DO 200, IROW = 1, N

PRINT 1010, X(IROW,ICOL)

200 CONTINUE

210 CONTINUE

PRINT 1070, RCOND

DO 220, IROW = 1, NRHS

PRINT 1080, IROW, BERR(IROW)

PRINT 1090, IROW, FERR(IROW)

220 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 ZHESVX, argument #', I2)

1050 FORMAT (1X, 'A is singular to working precision.')

1060 FORMAT (/1X, 'x:')

1070 FORMAT (/1X,

$ 'Estimated reciprocal condition number of A: ',

$ F5.3)

1080 FORMAT (/1X, 'Backward error for system #', I2, ': ', E12.5)

1090 FORMAT (1X, 'Forward error for system #', I2, ': ', E12.5)

C

END

