Previous Next Contents Generated Index Doc Set Home



LQ Factorization of a General Matrix

The subroutines described in this section compute an LQ factorization of a general matrix A.

Calling Sequence

CALL DGELQF 
(M, N, DA, LDA, DTAU, DWORK, LDWORK, INFO)
CALL SGELQF 
(M, N, SA, LDA, STAU, SWORK, LDWORK, INFO)
CALL ZGELQF 
(M, N, ZA, LDA, ZTAU, ZWORK, LDWORK, INFO)
CALL CGELQF 
(M, N, CA, LDA, CTAU, CWORK, LDWORK, INFO)






void dgelqf 
(int m, int n, double *da, int lda, double *dtau, int 
*info)
void sgelqf 
(int m, int n, float *sa, int lda, float *stau, int 
*info)
void zgelqf 
(int m, int n, doublecomplex *za, int lda, 
doublecomplex *ztau, int *info)
void cgelqf 
(int m, int n, complex *ca, int lda, complex *ctau, int 
*info)

Arguments

M

Number of rows of the matrix A. M 0.

N

Number of columns of the matrix A. N 0.

xA

On entry, the matrix A.
On exit, A and TAU contain an LQ factorization of the matrix A.

LDA

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

xTAU

On exit, the min(M, N) scalar factors of the elementary reflectors. The elementary reflectors in xTAU together with xA contain an LQ factorization of the matrix A that can be used by other LAPACK subroutines that operate on the matrix A.

xWORK

Scratch array with a dimension of LDWORK.

LDWORK

Leading dimension of the array WORK as specified in a dimension or type statement. LDWORK max(1, M).

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, LDWORK, M, N
      PARAMETER        (M = 4)
      PARAMETER        (N = 4)
      PARAMETER        (LDA = M)
      PARAMETER        (LDWORK = M)
C
      DOUBLE PRECISION  A(LDA,N), TAU(N), WORK(LDWORK)
      INTEGER           ICOL, INFO, IROW
C
      EXTERNAL          DGELQF, DORGLQ
      INTRINSIC         ABS, MIN
C
C     Initialize the array A to store the matrix A shown below.
C
C         1   1   1   1
C     A = 1  -1   1  -1
C         5  -5  -1   1
C         9  -1  -5  -3
C
      DATA A / 1.0D0,  1.0D0,  5.0D0,  9.0D0,
     $         1.0D0, -1.0D0, -5.0D0, -1.0D0,
     $         1.0D0,  1.0D0, -1.0D0, -5.0D0,
     $         1.0D0, -1.0D0,  1.0D0, -3.0D0 /
C
C     Compute the LQ factorization of A and print L.
C
      PRINT 1000
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, M)
      CALL DGELQF (M, N, A, LDA, TAU, WORK, LDWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1020, ABS(INFO)
        STOP 1
      END IF
      PRINT 1030
      DO 100, IROW = 1, M
        PRINT 1010, (A(IROW,ICOL), ICOL = 1, MIN(N,IROW)),
     $              (0.0D0, ICOL = IROW + 1, N)
  100 CONTINUE
C
C     Compute and print the matrix Q used in the LQ factorization
C     of A.
C
      CALL DORGLQ (N, N, N, A, LDA, TAU, WORK, LDWORK, INFO)
      IF (INFO .NE. 0) THEN
        PRINT 1040, ABS(INFO)
        STOP 2
      END IF
      PRINT 1050
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, N)
C
 1000 FORMAT (1X, 'A:')
 1010 FORMAT (4(3X, F8.4))
 1020 FORMAT (1X, 'Illegal value for argument #', I1, 
     $        ' in DGELQF.')
 1030 FORMAT (/1X, 'L:')
 1040 FORMAT (1X, 'Illegal value for argument #', I1,
     $        ' in DORGLQ.')
 1050 FORMAT (/1X, 'Q:')
C
      END
 

Sample Output

 
 A:
     1.0000     1.0000     1.0000     1.0000
     1.0000    -1.0000     1.0000    -1.0000
     5.0000    -5.0000    -1.0000     1.0000
     9.0000    -1.0000    -5.0000    -3.0000



 L:
    -2.0000     0.0000     0.0000     0.0000
     0.0000     2.0000     0.0000     0.0000
     0.0000     4.0000     6.0000     0.0000
     0.0000     4.0000     6.0000    -8.0000



 Q:
    -0.5000    -0.5000    -0.5000    -0.5000
     0.5000    -0.5000     0.5000    -0.5000
     0.5000    -0.5000    -0.5000     0.5000
    -0.5000    -0.5000     0.5000     0.5000






Previous Next Contents Generated Index Doc Set Home