Previous Next Contents Generated Index Doc Set Home



UDU or LDL Factorization of a Symmetric Matrix

The subroutines described in this section compute a UDU or LDL factorization of a symmetric matrix A. It is typical to follow a call to xSYTRF with a call to xSYSVX or xSYTRS to solve a linear system AX = B, to xSYCON to estimate the condition number of A, or to xSYTRI to compute A-1.

Calling Sequence

CALL DSYTRF 
(UPLO, N, DA, LDA, IPIVOT, DWORK, LDWORK, INFO)
CALL SSYTRF 
(UPLO, N, SA, LDA, IPIVOT, SWORK, LDWORK, INFO)
CALL ZSYTRF 
(UPLO, N, ZA, LDA, IPIVOT, ZWORK, LDWORK, INFO)
CALL CSYTRF 
(UPLO, N, CA, LDA, IPIVOT, CWORK, LDWORK, INFO)






void dsytrf 
(char uplo, int n, double *da, int lda, int *ipivot, 
int *info)
void ssytrf 
(char uplo, int n, float *sa, int lda, int *ipivot, int 
*info)
void zsytrf 
(char uplo, int n, doublecomplex *za, int lda, int 
*ipivot, int *info)
void csytrf 
(char uplo, int n, complex *ca, int lda, int *ipivot, 
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.

xA

On entry, the upper or lower triangle of the matrix A.
On exit, a UDU or LDL factorization of A.

LDA

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

IPIVOT

On exit, an N-element array containing details of the row interchanges and block structure of D.

xWORK

Scratch array with a dimension of LDWORK.

LDWORK

Leading dimension of the array WORK as specified in a dimension or type statement. LDWORK 1.

INFO

On exit:

INFO = 0

Subroutine completed normally.

INFO < 0

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

INFO > 0

D(i,i), where i = INFO, is exactly zero, and D is therefore singular. The factorization is complete, but division by zero will occur if this factorization is used to solve a linear system.

Sample Program




      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           LDA, LDB, LDWORK, N, NRHS
      PARAMETER        (N = 3)
      PARAMETER        (NRHS = 1)
      PARAMETER        (LDA = N)
      PARAMETER        (LDB = LDA)
      PARAMETER        (LDWORK = 1)
C
      DOUBLE PRECISION  A(LDA,N), B(LDB,NRHS), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW, IPIVOT(N)
C
      EXTERNAL          DSYTRF, DSYTRS
C
C     Initialize the array A to store the coefficient matrix A
C     shown below.  Initialize the array B to store the right
C     hand side vector b shown below.
C
C         1  2  2        15
C     A = 2  1  2    b = 15
C         2  2  1        15
C
      DATA A / 1.0D0, 8D8, 8D8, 2.0D0, 1.0D0, 8D8, 2.0D0, 2.0D0,
     $         1.0D0 /
      DATA B / N*1.5D1 /
C
C     Print the initial values of the arrays.
C
      PRINT 1000
      DO 100, IROW = 1, N
        PRINT 1010, (A(ICOL,IROW), ICOL = 1, IROW - 1),
     $              (A(IROW,ICOL), ICOL = IROW, N)
  100 CONTINUE
      PRINT 1020
      DO 110, IROW = 1, LDA
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, N)
  110 CONTINUE
      PRINT 1030
      PRINT 1040, B
C
C     Solve the system Ax=b, then print the result.
C
      CALL DSYTRF ('UPPER TRIANGLE OF A STORED', N, A, LDA,
     $             IPIVOT, WORK, LDWORK, INFO)
      IF (INFO .EQ. 0) THEN
        CALL DSYTRS ('UPPER TRIANGULAR FACTOR', N, NRHS, A, LDA,
     $               IPIVOT, B, LDB, INFO)
        IF (INFO .EQ. 0) THEN
          PRINT 1050
          PRINT 1040, B
        ELSE
          PRINT 1060, INFO
        END IF
      ELSE
        PRINT 1070, INFO
      END IF
C
 1000 FORMAT (1X, 'A in full form:')
 1010 FORMAT (3(3X, F4.1))
 1020 FORMAT (/1X, 'A in symmetric form:  (* in unused elements)')
 1030 FORMAT (/1X, 'b:')
 1040 FORMAT (1X, 2X, F4.1)
 1050 FORMAT (/1X, 'x:')
 1060 FORMAT (1X, 'Solve failed with INFO = ', I6)
 1070 FORMAT (1X, 'Factorization failed with INFO = ', I6)
C
      END
 

Sample Output

 
 A in full form:
    1.0    2.0    2.0
    2.0    1.0    2.0
    2.0    2.0    1.0



 A in symmetric form:  (* in unused elements)
    1.0    2.0    2.0
   ****    1.0    2.0
   ****   ****    1.0



 b:
   15.0
   15.0
   15.0



 x:
    3.0
    3.0
    3.0






Previous Next Contents Generated Index Doc Set Home