Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a Cholesky-Factored Symmetric Positive Definite Matrix in Banded Storage

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, which has been Cholesky-factored by xPBTRF, and general matrices B and X.

Calling Sequence

CALL DPBTRS 
(UPLO, N, NDIAG, NRHS, DA, LDA, DB, LDB, INFO)
CALL SPBTRS 
(UPLO, N, NDIAG, NRHS, SA, LDA, SB, LDB, INFO)
CALL ZPBTRS 
(UPLO, N, NDIAG, NRHS, ZA, LDA, ZB, LDB, INFO)
CALL CPBTRS 
(UPLO, N, NDIAG, NRHS, CA, LDA, CB, LDB, INFO)






void dpbtrs 
(char uplo, int n, int ndiag, int nrhs, double *da, int 
lda, double *db, int ldb, int *info)
void spbtrs 
(char uplo, int n, int ndiag, int nrhs, float *sa, int 
lda, float *sb, int ldb, int *info)
void zpbtrs 
(char uplo, int n, int ndiag, int nrhs, doublecomplex 
*za, int lda, doublecomplex *zb, int ldb, int *info)
void cpbtrs 
(char uplo, int n, int ndiag, int nrhs, complex *ca, 
int lda, complex *cb, int ldb, int *info)

Arguments

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

xA

Cholesky factorization of the matrix A as computed by xPBTRF.

LDA

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

xB

On entry, the N×NRHS right-hand side matrix B.
On exit, the N×NRHS solution matrix X.

LDB

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

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

The ith argument, where i = |INFO|, had an illegal value.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDB, N, NDIAG, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (NDIAG = 1)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = NDIAG + 1)
      PARAMETER        (LDB = N)
C
      DOUBLE PRECISION  A(LDA,N), B(LDB,NRHS)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DPBTRF, DPBTRS
      INTRINSIC         ABS
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     Cholesky factor A.
C
      CALL DPBTRF ('UPPER TRIANGLE OF A STORED', N, NDIAG, A, LDA,
     $             INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, INFO
        STOP 1
      END IF
C
C     Use the factored form of A to solve Ax=b then print result.
C
      CALL DPBTRS ('UPPER TRIANGLE OF A STORED', N, NDIAG, NRHS,
     $             A, LDA, B, LDB, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1060, ABS(INFO)
        STOP 1
      END IF
      PRINT 1070
      PRINT 1040, B
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 factoring A, INFO = ', I5)
 1060 FORMAT (1X, 'Illegal argument to DPBTRS, argument #', I1)
 1070 FORMAT (/1X, 'x:')
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






Previous Next Contents Generated Index Doc Set Home