Previous Next Contents Generated Index Doc Set Home



QR Factorization of a General Matrix

The subroutines described in this section compute the QR factorization of a general matrix A. It is typical to follow a call to xQRDC with a call to xQRSL to solve Ax = b or to xPODI to compute the determinant of A.

Calling Sequence

CALL DQRDC 
(DA, LDA, N, P, DQRAUX, IPIVOT, DWORK, JOB)
CALL SQRDC 
(SA, LDA, N, P, SQRAUX, IPIVOT, SWORK, JOB)
CALL ZQRDC 
(ZA, LDA, N, P, ZQRAUX, IPIVOT, ZWORK, JOB)
CALL CQRDC 
(CA, LDA, N, P, CQRAUX, IPIVOT, CWORK, JOB)






void dqrdc 
(double *da, int lda, int n, int p, double *dqraux, int 
*ipivot, int job)
void sqrdc 
(float *sa, int lda, int n, int p, float *sqraux, int 
*ipivot, int job)
void zqrdc 
(doublecomplex *za, int lda, int n, int p, 
doublecomplex *zqraux, int *ipivot, int job)
void cqrdc 
(complex *ca, int lda, int n, int p, complex *cqraux, 
int *ipivot, int job)

Arguments

xA

On entry, the matrix A.
On exit, the upper triangle of A contains the matrix R and the strict lower triangle of A contains information that will allow construction of the matrix Q. If pivoting was requested, A contains the factorization of the original matrix A permuted by the requested pivots.

LDA

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

N

Number of rows in the matrix A. N 0.

P

Number of columns in the matrix A. P 0.

xQRAUX

On exit, contains information required to construct the orthogonal matrix Q.

IPIVOT

If JOB selected no pivoting, then IPIVOT is not referenced. If JOB selected pivoting, then on entry to the subroutines, IPIVOT contains integers representing array indices that control the selection of pivot elements from the diagonal of A according to the system below:

IPIVOT(k) > 0

A(k,k) is an initial element.

IPIVOT(k) = 0

A(k,k) is a free element.

IPIVOT(k) < 0

A(k,k) is a final element.

Before the decomposition is computed, symmetric row and column interchanges are used to move initial elements to the beginning of A and final elements to the end of A. During the computation, symmetric row and column interchanges are used to move the largest remaining free diagonal element into the pivot position.

On exit, IPIVOT(k) contains the index of the diagonal element of A that was moved into the kth position.

xWORK

Scratch array with a dimension of N. WORK is not referenced if
JOB = 0.

JOB

Determines how the factorization is done:

0

with no pivoting

not 0

with pivoting

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           IDOB, IDORSD, IDOXB, LDA, N, NCOLA, NOPIV
      INTEGER           NROWA
      PARAMETER        (IDOB = 100)
      PARAMETER        (IDORSD = 10)
      PARAMETER        (IDOXB = 1)
      PARAMETER        (N = 3)
      PARAMETER        (LDA = N)
      PARAMETER        (NCOLA = 2)
      PARAMETER        (NOPIV = 0)
      PARAMETER        (NROWA = N)
C
      DOUBLE PRECISION  A(LDA,NCOLA), B(NCOLA), NULL(N), QRAUX(N)
      DOUBLE PRECISION  RESID(N), WORK(N), Y(N)
      INTEGER           ICOL, INFO, IROW, JOB, JPIVOT
C
      EXTERNAL          DQRDC, DQRSL
C
C      Initialize the array A to store the matrix A shown below.
C      Initialize the array Y to store the vector y shown below.
C
C          1  1         1
C      A = 1  0    y =  0
C          0  1        -5
C
      DATA A / 1.0D0, 1.0D0, 0.0D0, 1.0D0, 0.0D0, 1.0D0 /
      DATA Y / 1.0D0, 0.0D0, -5.0D0 /
C
      PRINT 1000
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, NCOLA), IROW = 1,
     $   NROWA)
      PRINT 1020
      PRINT 1030, Y
      JOB = NOPIV
      CALL DQRDC (A, LDA, NROWA, NCOLA, QRAUX, JPIVOT, WORK, JOB)
      JOB = IDOB + IDORSD + IDOXB
      CALL DQRSL (A, LDA, NROWA, NCOLA, QRAUX, Y, NULL, NULL, B,
     $            RESID, NULL, JOB, INFO)
      IF (INFO .EQ. 0) THEN
        PRINT 1040
        PRINT 1050, B
        PRINT 1060
        PRINT 1050, RESID
      ELSE
        PRINT 1070
      END IF
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (2(3X, F4.1))
 1020 FORMAT (/1X, 'y:')
 1030 FORMAT (3X, F4.1)
 1040 FORMAT (/1X, 'Least squares solution:')
 1050 FORMAT (3X, F4.1)
 1060 FORMAT (/1X, 'Residual:')
 1070 FORMAT (1X, 'A is singular.')
C
      END
 

Sample Output

 
 A:
    1.0    1.0
    1.0    0.0
    0.0    1.0



 y:
    1.0
    0.0
   -5.0



 Least squares solution:
    2.0
   -3.0



 Residual:
    2.0
   -2.0
   -2.0






Previous Next Contents Generated Index Doc Set Home