Previous Next Contents Generated Index Doc Set Home



Generation of Q Defined in LQ Factorization

The subroutines described in this section generate a matrix Q with orthnormal rows that was defined in an LQ factorization computed by xGELQF.

Calling Sequence

CALL DORGLQ 
(M, N, K, DA, LDA, DTAU, DWORK, LDWORK, INFO)
CALL SORGLQ 
(M, N, K, SA, LDA, STAU, SWORK, LDWORK, INFO)






void dorglq 
(int m, int n, int k, double *da, int lda, double *dtau, 
int *info)
void sorglq 
(int m, int n, int k, float *sa, int lda, float *stau, 
int *info)

Arguments

M

Number of rows of the matrix Q. M 0.

N

Number of columns of the matrix Q. N M.

K

Number of elementary reflectors whose product defines the matrix Q. 0 K M.

xA

On entry, A and TAU contain the LQ factorization of the matrix A as computed by xGELQF.
On exit, the M×N matrix Q.

LDA

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

xTAU

TAU(i) contains the scalar factor of the elementary reflector H(i) for 1 i K as computed by xGELQF.

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          DCOPY, 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     Print the initial value of A.
C
      PRINT 1000
      PRINT 1010, ((A(IROW,ICOL), ICOL = 1, N), IROW = 1, M)
C
C     Compute the LQ factorization of A.
C
      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