Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Symmetric Positive Definite Matrix in Banded 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 banded 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 xPBSV is also available.

Calling Sequence

CALL DPBSVX 
(FACT, UPLO, N, NDIAG, NRHS, DA, LDA, DAF, LDAF, EQUED, 
DSCALE, DB, LDB, DX, LDX, DRCOND, DFERR, DBERR, DWORK, 
IWORK2, INFO)
CALL SPBSVX 
(FACT, UPLO, N, NDIAG, NRHS, SA, LDA, SAF, LDAF, EQUED, 
SSCALE, SB, LDB, SX, LDX, SRCOND, SFERR, SBERR, SWORK, 
IWORK2, INFO)
CALL ZPBSVX 
(FACT, UPLO, N, NDIAG, NRHS, ZA, LDA, ZAF, LDAF, EQUED, 
DSCALE, ZB, LDB, ZX, LDX, DRCOND, DFERR, DBERR, ZWORK, 
DWORK2, INFO)
CALL CPBSVX 
(FACT, UPLO, N, NDIAG, NRHS, CA, LDA, CAF, LDAF, EQUED, 
SSCALE, CB, LDB, CX, LDX, SRCOND, SFERR, SBERR, CWORK, 
SWORK2, INFO)






void dpbsvx 
(char fact, char uplo, int n, int ndiag, int nrhs, 
double *da, int lda, double *daf, int ldaf, char 
*equed, double *dscale, double *db, int ldb, double 
*dx, int ldx, double *drcond, double *dferr, double 
*dberr, int *info)
void spbsvx 
(char fact, char uplo, int n, int ndiag, int nrhs, 
float *sa, int lda, float *saf, int ldaf, char *equed, 
float *sscale, float *sb, int ldb, float *sx, int ldx, 
float *srcond, float *sferr, float *sberr, int *info)
void zpbsvx 
(char fact, char uplo, int n, int ndiag, int nrhs, 
doublecomplex *za, int lda, doublecomplex *zaf, int 
ldaf, char *equed, double *dscale, doublecomplex *zb, 
int ldb, doublecomplex *zx, int ldx, double *drcond, 
double *dferr, double *dberr, int *info)
void cpbsvx 
(char fact, char uplo, int n, int ndiag, int nrhs, 
complex *ca, int lda, complex *caf, int ldaf, 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 xPBTRF

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.

NDIAG

Number of superdiagonals or subdiagonals of the matrix A. N-1 NDIAG 0 but if N = 0 then NDIAG = 0.

If UPLO = 'U' or 'u', NDIAG is the number of superdiagonals.

If UPLO = 'L' or 'l', NDIAG is the number of subdiagonals.

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.

LDA

Leading dimension of the array A as specified in a dimension or type statement. LDA NDIAG + 1.

xAF

The contents of AF vary depending on the values of FACT and EQUED. See the table for the argument FACT above.

LDAF

Leading dimension of the array AF as specified in a dimension or type statement. LDAF NDIAG + 1.

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, N
      INTEGER           NDIAG, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = NDIAG + 1)
      PARAMETER        (LDAF = LDA)
      PARAMETER        (LDB = N)
      PARAMETER        (LDIWRK = N)
      PARAMETER        (LDX = N)
      PARAMETER        (LDWORK = 3 * N)
C
      DOUBLE PRECISION  A(LDA,N), AF(LDAF,N), B(LDB,NRHS)
      DOUBLE PRECISION  BERR(NRHS), FERR(NRHS), RCOND, SCALE(N)
      DOUBLE PRECISION  WORK(LDWORK), X(LDX,NRHS)
      INTEGER           ICOL, INFO, IROW, IWORK(LDIWRK)
      CHARACTER*1       EQUED
C
      EXTERNAL          DPBSVX
C
C     Initialize the array A to store in symmetric banded form
C     the 4x4 symmetric positive definite coefficient matrix A
C     with one subdiagonal and one superdiagonal 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 /    8D8, 2.0D0, -1.0D0, 2.0D0,
     $         -1.0D0, 2.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(2,1), A(1,2),  0.0D0, 0.0D0
      PRINT 1010, A(1,2), A(2,2), A(1,3), 0.0D0
      PRINT 1010,  0.0D0, A(1,3), A(2,3), A(1,4)
      PRINT 1010,  0.0D0,  0.0D0, A(1,4), A(2,4)
      PRINT 1020
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, LDA)
      PRINT 1030
      PRINT 1040, B
C
C     Solve the system and print the results.
C
      CALL DPBSVX ('EQUILIBRATE A', 'UPPER TRIANGLE OF A STORED',
     $             N, NDIAG, NRHS, A, LDA, AF, LDAF, EQUED, SCALE,
     $             B, LDB, X, LDX, RCOND, FERR, BERR, WORK, IWORK,
     $             INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        IF (INFO .EQ. (N + 1)) THEN
          PRINT 1060
          STOP 1
        END IF
        STOP 2
      END IF
      PRINT 1070
      PRINT 1040, X
      PRINT 1080, 1.0D0 / RCOND
      IF (EQUED .EQ. 'N') THEN
        PRINT 1090
      ELSE
        PRINT 1100
      END IF
      PRINT 1110, (IROW, BERR(IROW), IROW = 1, NRHS)
      PRINT 1120, (IROW, FERR(IROW), IROW = 1, NRHS)
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (4(3X, F6.3))
 1020 FORMAT (/1X, 'A in banded form:  (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, F6.2)
 1050 FORMAT (1X, 'Error solving Ax=b, INFO = ', I5)
 1060 FORMAT (1X, 'Matrix is singular to working precision.')
 1070 FORMAT (/1X, 'x:')
 1080 FORMAT (/1X, 'Estimated condition number of A: ', F7.2)
 1090 FORMAT (1X, 'No equilibration was required for A.')
 1100 FORMAT (1X, 'Diagonal equilibration was done on A.')
 1110 FORMAT (/1X, 'Backward error bound for system #', I1, ': ',
     $        E12.5)
 1120 FORMAT (1X, 'Forward error bound for system #', I1, ':  ',
     $        E12.5)
C
      END
 

Sample Output

 
 A in full form:
    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



 A in banded form:  (* in unused elements)
   ******   -1.000   -1.000   -1.000
    2.000    2.000    2.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 bound for system #1:  0.00000E+00
 Forward error bound for system #1:   0.46185E-14






Previous Next Contents Generated Index Doc Set Home