Previous Next Contents Generated Index Doc Set Home



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

The subroutines described in this section solve a linear system AX = B for a symmetric matrix A in packed storage 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 xSPSV is also available.

Calling Sequence

CALL DSPSVX 
(FACT, UPLO, N, NRHS, DA, DAF, IPIVOT, DB, LDB, DX, 
LDX, DRCOND, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL SSPSVX 
(FACT, UPLO, N, NRHS, SA, SAF, IPIVOT, SB, LDB, SX, 
LDX, SRCOND, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZSPSVX 
(FACT, UPLO, N, NRHS, ZA, ZAF, IPIVOT, ZB, LDB, ZX, 
LDX, DRCOND, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CSPSVX 
(FACT, UPLO, N, NRHS, CA, CAF, IPIVOT, CB, LDB, CX, 
LDX, SRCOND, SFERR, SBERR, CWORK, SWORK2, INFO)






void dspsvx 
(char fact, char uplo, int n, int nrhs, double *da, 
double *daf, int *ipivot, double *db, int ldb, double 
*dx, int ldx, double *drcond, double *dferr, double 
*dberr, int *info)
void sspsvx 
(char fact, char uplo, int n, int nrhs, float *sa, 
float *saf, int *ipivot, float *sb, int ldb, float *sx, 
int ldx, float *srcond, float *sferr, float *sberr, int 
*info)
void zspsvx 
(char fact, char uplo, int n, int nrhs, doublecomplex 
*za, doublecomplex *zaf, int *ipivot, doublecomplex 
*zb, int ldb, doublecomplex *zx, int ldx, double 
*drcond, double *dferr, double *dberr, int *info)
void cspsvx 
(char fact, char uplo, int n, int nrhs, complex *ca, 
complex *caf, 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. 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.
The dimension of xA is (N × N + N) / 2.

xAF

The dimension of xAF is (N × N + N) / 2.

On entry, if FACT = 'F' or 'f', then AF contains the UDU or LDL factorization of A, as computed by xSPTRF. 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 xSPTRF. Otherwise AF is unchanged.

IPIVOT

On entry, if FACT = 'F' or 'f', then IPIVOT contains the pivot indices as computed by xSPTRF. 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 xSPTRF. 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 3 × N for real subroutines or 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 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 = 4)
      PARAMETER        (LDA = (N * (N + 1)) / 2)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDX = N)
      PARAMETER        (LDWORK = 3 * N)
      PARAMETER        (NRHS = 1)
C
      DOUBLE PRECISION  A(LDA), AF(LDAF), B(LDB,NRHS), BERR(NRHS)
      DOUBLE PRECISION  FERR(NRHS), RCOND, WORK(LDWORK)
      DOUBLE PRECISION  X(LDX,NRHS)
      INTEGER           I, INFO, IPIVOT(N), IWORK(LDIWRK)
C
      EXTERNAL          DSPSVX
C
C     Initialize the array A to store in packed symmetric form
C     the 4x4 symmetric matrix A shown below.  Initialize the
C     array B to store the right hand side vector b shown below.
C
C          2  -1   0   0          6
C     A = -1   2  -1   0     b = 12
C          0  -1   2  -1         12
C          0   0  -1   2          6
C
      DATA A /  2.0D0, -1.0D0, 2.0D0, 0.0D0, -1.0D0, 2.0D0,
     $          0.0D0, 0.0D0, -1.0D0, 2.0D0 /
      DATA B / 6.0D0, 1.2D1, 1.2D1, 6.0D0 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      PRINT 1010, A(1), A(2), A(4), A(7)
      PRINT 1010, A(2), A(3), A(5), A(8)
      PRINT 1010, A(4), A(5), A(6), A(9)
      PRINT 1010, A(7), A(8), A(9), A(10)
      PRINT 1020
      PRINT 1030, B
C
C     Solve Ax=b and print the solution.
C
      CALL DSPSVX ('NOT FACTORED A', 'UPPER TRIANGLE OF A STORED',
     $             N, NRHS, A, AF, IPIVOT, B, LDB, X, LDX, RCOND,
     $             FERR, BERR, WORK, IWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        IF (INFO .EQ. (N + 1)) THEN
          PRINT 1050
          STOP 1
        END IF
        STOP 2
      END IF
      PRINT 1060
      PRINT 1030, X
      PRINT 1070, 1.0D0 / RCOND
      PRINT 1080, (I, BERR(I), I = 1, NRHS)
      PRINT 1090, (I, FERR(I), I = 1, NRHS)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F6.3))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F6.2)
 1040 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1050 FORMAT (1X, 'Matrix is singular to working precision.')
 1060 FORMAT (/1X, 'x:')
 1070 FORMAT (/1X, 'Estimated condition number of A: ', F7.2)
 1080 FORMAT (/1X, 'Backward error for system #', I1, ': ', E12.6)
 1090 FORMAT (1X, 'Forward error for system #', I1, ':  ', E12.6)
C
      END
 

Sample Output

 
 A:
    2.000   -1.000    0.000    0.000
   -1.000    2.000   -1.000    0.000
    0.000   -1.000    2.000   -1.000
    0.000    0.000   -1.000    2.000



 b:
   6.00
  12.00
  12.00
   6.00



 x:
  18.00
  30.00
  30.00
  18.00



 Estimated condition number of A:   12.00



 Backward error for system #1: 0.296059E-16
 Forward error for system #1:  0.601001E-14






Previous Next Contents Generated Index Doc Set Home