Previous Next Contents Generated Index Doc Set Home



Solution to a Linear System in a UDU- or LDL-Factored Symmetric Matrix in Packed Storage

The subroutines described in this section solve a linear system AX = B for a symmetric matrix A in packed storage, which has been UDU-factored or LDL-factored by xSPTRF, and general matrices B and X.

Calling Sequence

CALL DSPTRS 
(UPLO, N, NRHS, DA, IPIVOT, DB, LDB, INFO)
CALL SSPTRS 
(UPLO, N, NRHS, SA, IPIVOT, SB, LDB, INFO)
CALL ZSPTRS 
(UPLO, N, NRHS, ZA, IPIVOT, ZB, LDB, INFO)
CALL CSPTRS 
(UPLO, N, NRHS, CA, IPIVOT, CB, LDB, INFO)






void dsptrs 
(char uplo, int n, int nrhs, double *da, int *ipivot, 
double *db, int ldb, int *info)
void ssptrs 
(char uplo, int n, int nrhs, float *sa, int *ipivot, 
float *sb, int ldb, int *info)
void zsptrs 
(char uplo, int n, int nrhs, doublecomplex *za, int 
*ipivot, doublecomplex *zb, int ldb, int *info)
void csptrs 
(char uplo, int n, int nrhs, complex *ca, int *ipivot, 
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.

NRHS

Number of right-hand sides, equal to the number of columns of the matrix B. NRHS 0.

xA

UDU or LDL factorization of the matrix A, as computed by xSPTRF. The dimension of xA is (N × N + N) / 2.

IPIVOT

Pivot indices as computed by xSPTRF.

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, NRHS
      PARAMETER        (N = 4)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = (N * (N + 1)) / 2)
      PARAMETER        (LDB = N)
C
      DOUBLE PRECISION  A(LDA), B(LDB,NRHS)
      INTEGER           INFO, IPIVOT(N)
C
      EXTERNAL          DSPTRF, DSPTRS
      INTRINSIC         ABS
C
C     Initialize the array A to store in packed symmetric form the
C     4x4 symmetric coefficient matrix A shown below.  Initialize
C     the array B to store the right hand side vector b shown
C     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     LDL factor A.
C
      CALL DSPTRF ('UPPER TRIANGLE OF A STORED', N, A, IPIVOT,
     $             INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, INFO
        STOP 2
      END IF
C
C     Use the factored form of A to solve Ax=b then print
C     the result.
C
      CALL DSPTRS ('UPPER TRIANGLE OF A STORED', N, NRHS, A,
     $             IPIVOT, B, LDB, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1050, ABS(INFO)
        STOP 1
      END IF
      PRINT 1060
      PRINT 1030, B
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F6.3))
 1020 FORMAT (/1X, 'b:')
 1030 FORMAT (1X, F6.2)
 1040 FORMAT (1X, 'Error factoring A, INFO = ', I5)
 1050 FORMAT (1X, 'Illegal argument to DSPTRS, argument #', I1)
 1060 FORMAT (/1X, 'x:')
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






Previous Next Contents Generated Index Doc Set Home