
PROGRAM TEST

IMPLICIT NONE

C

DOUBLE PRECISION ZERO

INTEGER LDB, LDWORK, LDWRK2, LDX, LENGTA, N, NRHS

PARAMETER (N = 3)

PARAMETER (LDB = N)

PARAMETER (LDWORK = 2 * N)

PARAMETER (LDWRK2 = N)

PARAMETER (LDX = N)

PARAMETER (LENGTA = (N * N + N) / 2)

PARAMETER (NRHS = 1)

PARAMETER (ZERO = 0.0D0)

C

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

DOUBLE PRECISION WORK2(LDWRK2)

COMPLEX*16 A(LENGTA), AF(LENGTA), B(LDB,NRHS)

COMPLEX*16 WORK(LDWORK), X(LDX,NRHS)

INTEGER ICOL, INFO, IPIVOT(N), IROW

C

EXTERNAL ZHPSVX

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 1i 1i 4+i

C A = 1+i 3 3i b = 4+6i

C 1+i 3+i 5 4+7i

C

DATA A / (1.0D0,0.0D0), (1.0D0,1.0D0), (3.0D0,0.0D0),

$ (1.0D0,1.0D0), (3.0D0,1.0D0), (5.0D0,0.0D0) /

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

PRINT 1010, CMPLX(DBLE(A(1)),ZERO), A(2), A(4)

PRINT 1010, CONJG(A(2)), CMPLX(DBLE(A(3)),ZERO), A(5)

PRINT 1010, CONJG(A(4)), CONJG(A(5)), CMPLX(DBLE(A(6)),ZERO)

PRINT 1020

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 ZHPSVX ('NOT FACTORED A', 'UPPER TRIANGLE OF A STORED',

$ N, NRHS, A, AF, IPIVOT, B, LDB, X, LDX,

$ RCOND, FERR, BERR, WORK, WORK2, INFO)

IF (INFO .LT. 0) THEN

PRINT 1030, ABS(INFO)

STOP 1

ELSE IF (INFO .GT. 0) THEN

PRINT 1040

STOP 2

END IF

C

C Print the solution and error bounds.

C

PRINT 1050

DO 210, ICOL = 1, NRHS

DO 200, IROW = 1, N

PRINT 1010, X(IROW,ICOL)

200 CONTINUE

210 CONTINUE

PRINT 1060, RCOND

DO 220, IROW = 1, NRHS

PRINT 1070, IROW, BERR(IROW)

PRINT 1080, IROW, FERR(IROW)

220 CONTINUE

C

1000 FORMAT (1X, 'A:')

1010 FORMAT (1X, 10(: 2X, '(', F4.1, ',', F4.1, ')'))

1020 FORMAT (/1X, 'b:')

1030 FORMAT (1X, 'Illegal argument to ZHPSVX, argument #', I2)

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

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

1060 FORMAT (/1X,

$ 'Estimated reciprocal condition number of A: ',

$ F5.3)

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

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

C

END

