Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Symmetric Matrix (Expert Driver)

The subroutines described in this section solve a linear system AX = B for a symmetric matrix A and general matrices B and X. These subroutines also compute forward error bounds and backward error estimates for the solution, and estimate the condition number of the matrix A. Note that the simple driver xSYSV is also available.

Calling Sequence

CALL DSYSVX 
(FACT, UPLO, N, NRHS, DA, LDA, DAF, LDAF, IPIVOT, DB, 
LDB, DX, LDX, DRCOND, DFERR, DBERR, DWORK, LDWORK, 
IWORK2, INFO)
CALL SSYSVX 
(FACT, UPLO, N, NRHS, SA, LDA, SAF, LDAF, IPIVOT, SB, 
LDB, SX, LDX, SRCOND, SFERR, SBERR, SWORK, LDWORK, 
IWORK2, INFO)
CALL ZSYSVX 
(FACT, UPLO, N, NRHS, ZA, LDA, ZAF, LDAF, IPIVOT, ZB, 
LDB, ZX, LDX, DRCOND, DFERR, DBERR, ZWORK, LDWORK, 
DWORK2, INFO)
CALL CSYSVX 
(FACT, UPLO, N, NRHS, CA, LDA, CAF, LDAF, IPIVOT, CB, 
LDB, CX, LDX, SRCOND, SFERR, SBERR, CWORK, LDWORK, 
SWORK2, INFO)






void dsysvx 
(char fact, char uplo, int n, int nrhs, double *da, int 
lda, double *daf, int ldaf, int *ipivot, double *db, 
int ldb, double *dx, int ldx, double *drcond, double 
*dferr, double *dberr, int *info)
void ssysvx 
(char fact, char uplo, int n, int nrhs, float *sa, int 
lda, float *saf, int ldaf, int *ipivot, float *sb, int 
ldb, float *sx, int ldx, float *srcond, float *sferr, 
float *sberr, int *info)
void zsysvx 
(char fact, char uplo, int n, int nrhs, doublecomplex 
*za, int lda, doublecomplex *zaf, int ldaf, int 
*ipivot, doublecomplex *zb, int ldb, doublecomplex 
*zx, int ldx, double *drcond, double *dferr, double 
*dberr, int *info)
void csysvx 
(char fact, char uplo, int n, int nrhs, complex *ca, 
int lda, complex *caf,int ldaf, int *ipivot, complex 
*cb, int ldb, complex *cx, int ldx, float *srcond, 
float *sferr, float *sberr, int *info)

Arguments

FACT

Indicates whether or not the factored form of A has been supplied on entry.

'F' or 'f'

On entry, AF and IPIVOT contain the factored form of A. AF and IPIVOT will not be modified.

'N' or 'n'

On entry, the matrix A will be copied to AF and factored.

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 matrices B and X. NRHS 0.

xA

Upper or lower triangle of the matrix A.

LDA

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

xAF

On entry, if FACT = 'F' or 'f' then AF contains the UDU or LDL factorization of A, as computed by xSYTRF. Otherwise the entry value of AF is not used.
On exit, if FACT = 'N' or 'n' then AF contains the UDU or LDL factorization of A, as computed by xSYTRF. Otherwise AF is unchanged.

LDAF

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

IPIVOT

On entry, if FACT = 'F' or 'f' then IPIVOT contains pivot indices as computed by xSYTRF. Otherwise the entry values of IPIVOT are not used.
On exit, if FACT = 'N' or 'n' then IPIVOT contains the pivot indices as computed by xSYTRF. Otherwise IPIVOT is unchanged.

xB

The N×NRHS right-hand side matrix B.

LDB

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

xX

On exit, the N×NRHS solution matrix X.

LDX

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

xRCOND

On exit, an estimate of the reciprocal condition number of the matrix A, where the reciprocal condition number is defined to be
1 / (||A|| × ||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. In this case, INFO > 0 is returned and the solution and error bounds are not computed.

xFERR

On exit, the estimated forward error bound for each solution vector X(*, j) for 1 j NRHS. If X' is the true solution corresponding to
X(*, j) then FERR(j) is an upper bound on the magnitude of the largest element in X(*, j) - X' divided by the magnitude of the largest element in X(*, j).

xBERR

On exit, BERR(j) is the smallest relative change in any element of A or B(*, j) that makes X(*, j) an exact solution to AX(*, j) = B(*, j) for 1 j NRHS.

xWORK

Scratch array with a dimension of LDWORK.

LDWORK

Leading dimension of the array WORK as specified in a dimension or type statement. LDWORK 3 × N for real subroutines or
LDWORK 2 × N for complex subroutines.

xWORK2

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.

1 INFO N

D(i,i), where i = INFO, is exactly zero and D is therefore singular. The factorization has has been completed, but the solution and error bounds could not be computed.

INFO = N+1

The block diagonal matrix D is nonsingular, but RCOND is less than machine precision. The factorization has been completed, but the matrix is singular to working precision, so the solution and error bounds could not be computed.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDAF, LDB, LDIWRK, LDWORK, LDX
      INTEGER           N, NRHS
      PARAMETER        (N = 3)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = N)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = LDA)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (LDX = N)
C
      DOUBLE PRECISION  A(LDA,N), AF(LDAF,N), B(LDB,NRHS)
      DOUBLE PRECISION  BERR(NRHS), FERR(NRHS), RCOND
      DOUBLE PRECISION  WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW, IPIVOT(N), IWORK(LDIWRK)
C
      EXTERNAL          DSYSVX
C
C     Initialize the array A to store the coefficient matrix A
C     shown below.  Initialize the array B to store the right
C     hand vector b shown below.
C
C         1  2  2        15
C     A = 2  1  2    b = 15
C         2  2  1        15
C
      DATA A / 1.0D0, 8D8, 8D8, 2.0D0, 1.0D0, 8D8, 2.0D0, 2.0D0,
     $         1.0D0 /
      DATA B / 1.5D1, 1.5D1, 1.5D1 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (0.0D0, ICOL = 1, IROW - 1),
     $              (A(IROW, ICOL), ICOL = IROW, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, LDA
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
      PRINT 1030
      PRINT 1040, B
C
C     Solve the system Ax=b, then print the result.
C
      CALL DSYSVX ('NOT FACTORED A', 'UPPER TRIANGLE OF A STORED',
     $             N, NRHS, A, LDA, AF, LDAF, IPIVOT, B, LDB,
     $             X, LDX, RCOND, FERR, BERR, WORK, LDWORK, 
     $             IWORK, INFO)
      IF (INFO .EQ. 0) THEN
        PRINT 1050
        PRINT 1040, X
        PRINT 1060, (1.0D0 / RCOND)
        PRINT 1070, (IROW, BERR(IROW), IROW = 1, NRHS)
        PRINT 1080, (IROW, FERR(IROW), IROW = 1, NRHS)
      ELSE
        PRINT 1090, INFO
      END IF
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, 'A in symmetric form:  (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, 2X, F4.1)
 1050 FORMAT (/1X, 'x:')
 1060 FORMAT (/1X, 'Estimated condition number: ', F6.3)
 1070 FORMAT (/1X, 'Backward error for system #', I1, ': ', E12.6)
 1080 FORMAT (1X, 'Forward error for system #', I1, ':  ', E12.6)
 1090 FORMAT (1X, 'Solve failed with INFO = ', I6)
C
      END
 

Sample Output

 
 A in full form:
    1.0    2.0    2.0
    0.0    1.0    2.0
    0.0    0.0    1.0



 A in symmetric form:  (* in unused elements)
    1.0    2.0    2.0
   ****    1.0    2.0
   ****   ****    1.0



 b:
   15.0
   15.0
   15.0



 x:
    3.0
    3.0
    3.0



 Estimated condition number:  7.000



 Backward error for system #1: 0.592119E-16
 Forward error for system #1:  0.645410E-14






Previous Next Contents Generated Index Doc Set Home