Previous Next Contents Generated Index Doc Set Home



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

The subroutines described in this section solve a linear system AX = B for a real symmetric (or Hermitian) positive definite 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, estimate the condition number of the matrix A and, optionally, equilibrate the system before computing a solution. Note that the simple driver xPPSV is also available.

Calling Sequence

CALL DPPSVX 
(FACT, UPLO, N, NRHS, DA, DAF, EQUED, DSCALE, DB, LDB, 
DX, LDX, DRCOND, DFERR, DBERR, DWORK, IWORK2, INFO)
CALL SPPSVX 
(FACT, UPLO, N, NRHS, SA, SAF, EQUED, SSCALE, SB, LDB, 
SX, LDX, SRCOND, SFERR, SBERR, SWORK, IWORK2, INFO)
CALL ZPPSVX 
(FACT, UPLO, N, NRHS, ZA, ZAF, EQUED, DSCALE, ZB, LDB, 
ZX, LDX, DRCOND, DFERR, DBERR, ZWORK, DWORK2, INFO)
CALL CPPSVX 
(FACT, UPLO, N, NRHS, CA, CAF, EQUED, SSCALE, CB, LDB, 
CX, LDX, SRCOND, SFERR, SBERR, CWORK, SWORK2, INFO)






void dppsvx 
(char fact, char uplo, int n, int nrhs, double *da, 
double *daf, char *equed, double *dscale, double *db, 
int ldb, double *dx, int ldx, double *drcond, double 
*dferr, double *dberr, int *info)
void sppsvx 
(char fact, char uplo, int n, int nrhs, float *sa, 
float *saf, char *equed, float *sscale, float *sb, int 
ldb, float *sx, int ldx, float *srcond, float *sferr, 
float *sberr, int *info)
void zppsvx 
(char fact, char uplo, int n, int nrhs, doublecomplex 
*za, doublecomplex *zaf, char *equed, double *dscale, 
doublecomplex *zb, int ldb, doublecomplex *zx, int ldx, 
double *drcond, double *dferr, double *dberr, int 
*info)
void cppsvx 
(char fact, char uplo, int n, int nrhs, complex *ca, 
complex *caf, char *equed, float *sscale, 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 the matrix A is supplied on entry, and if not, whether the matrix A will be equilibrated before it is factored. FACT interacts with EQUED, A, and AF as shown in the table below:



FACT
EQUED entry
EQUED exit
A entry
A exit
AF entry
AF exit

'F', 'f'

'N', 'n'

Unchanged

Matrix A

Unchanged

Cholesky-factored A

Unchanged

'F', 'f'

'Y', 'y'

Unchanged

Equilibrated A

Unchanged

Cholesky-factored equilibrated A

Unchanged

'E', 'e'

Not used

'N'

Matrix A

Unchanged

Not used

Cholesky-factored A

'E', 'e'

Not used

'Y'

Matrix A

Equilibrated A

Not used

Cholesky-factored equilibrated A

'N', 'n'

Not used

'N'

Matrix A

Unchanged

Not used

Cholesky-factored A



The above table uses the following abbreviations:

Cholesky-factored = the UTU or LLT factored form of A as computed by xPPTRF

Equilibrated A = diag(SCALE) × A × diag(SCALE)

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

The contents of A vary depending on the values of FACT and EQUED. See the table for the argument FACT above.
The dimension of xA is (N × N + N) / 2.

xAF

The contents of AF vary depending on the values of FACT and EQUED. See the table for the argument FACT above. The dimension of xAF is (N × N + N) / 2.

EQUED

EQUED interacts with FACT as shown in the table above for the argument FACT.

Note that one must be careful about specifying lowercase letters for the entry value of EQUED when FACT = 'F' or 'f' because ordinarily LAPACK will always return a capital letter. If the caller specifies 'n', or 'y' on entry then the lowercase letter will still be in EQUED on exit. The caller may later draw incorrect conclusions if the code contains a series of IF statements to determine whether EQUED = 'N' or 'Y'.

xSCALE

On entry, if FACT = 'F' or 'f' and EQUED = 'Y' or 'y' then SCALE contains the N scale factors that were used to equilibrate A. Each element of SCALE must be positive. If FACT or EQUED have other values, the entry values of SCALE are not used.
On exit, if FACT = 'E' or 'e' and EQUED = 'Y' then SCALE contains the N scale factors that were used to equilibrate A. If FACT or EQUED have other values, SCALE is unchanged.

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, if EQUED = 'N', then B is not modified; if EQUED = 'Y', then B is overwritten by diag(SCALE) × 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 for the original problem. Note that if the exit value of EQUED = 'Y' then A and B are modified on exit and the solution to the equilibrated system is diag(SCALE)-1 × 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 after equilibration, if any, 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

The leading minor of order i of A, where i = INFO, is not positive definite. The factorization has not been completed, and the solution and error bounds could not be computed.

INFO = N+1

RCOND is less than machine precision. The factorization has been completed, but the matrix is singular to working precision, and 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, SCALE(N), WORK(LDWORK)
      DOUBLE PRECISION  X(LDX,NRHS)
      INTEGER           I, INFO, IWORK(LDIWRK)
      CHARACTER*1       EQUED
C
      EXTERNAL          DPPSVX
C
C     Initialize the array A to store in symmetric form the
C     4x4 symmetric positive definite matrix A shown below. 
C     Initialize the array B to store the right hand side 
C     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 DPPSVX ('EQUILIBRATE A IF NECESSARY',
     $             'UPPER TRIANGLE OF A STORED', N, NRHS, A, AF,
     $             EQUED, SCALE, 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
      IF (EQUED .EQ. 'N') PRINT 1080
      IF (EQUED .EQ. 'R') PRINT 1090
      IF (EQUED .EQ. 'C') PRINT 1100
      IF (EQUED .EQ. 'B') PRINT 1110
      PRINT 1120, (I, BERR(I), I = 1, NRHS)
      PRINT 1130, (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, 'No equilibration was required for A.')
 1090 FORMAT (1X, 'Row equilibration was done on A.')
 1100 FORMAT (1X, 'Column equilibration was done on A.')
 1110 FORMAT (1X, 'Row and column equilibration was done on A.')
 1120 FORMAT (/1X, 'Backward error for system #', I1, ': ', E12.6)
 1130 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
 No equilibration was required for A.



 Backward error for system #1: 0.000000E+00
 Forward error for system #1:  0.577316E-14






Previous Next Contents Generated Index Doc Set Home