# cqrdc.f

          SUBROUTINE CQRDC (X, LDX, N, P, QRAUX, JPVT, WORK, JOB)
    C***BEGIN PROLOGUE  CQRDC
    C***PURPOSE  Use Householder transformations to compute the QR
    C            factorization of an N by P matrix.  Column pivoting is a
    C            users option.
    C***LIBRARY   SLATEC (LINPACK)
    C***CATEGORY  D5
    C***TYPE      COMPLEX (SQRDC-S, DQRDC-D, CQRDC-C)
    C***KEYWORDS  LINEAR ALGEBRA, LINPACK, MATRIX, ORTHOGONAL TRIANGULAR,
    C             QR DECOMPOSITION
    C***AUTHOR  Stewart, G. W., (U. of Maryland)
    C***DESCRIPTION
    C
    C     CQRDC uses Householder transformations to compute the QR
    C     factorization of an N by P matrix X.  Column pivoting
    C     based on the 2-norms of the reduced columns may be
    C     performed at the users option.
    C
    C     On Entry
    C
    C        X       COMPLEX(LDX,P), where LDX .GE. N.
    C                X contains the matrix whose decomposition is to be
    C                computed.
    C
    C        LDX     INTEGER.
    C                LDX is the leading dimension of the array X.
    C
    C        N       INTEGER.
    C                N is the number of rows of the matrix X.
    C
    C        P       INTEGER.
    C                P is the number of columns of the matrix X.
    C
    C        JVPT    INTEGER(P).
    C                JVPT contains integers that control the selection
    C                of the pivot columns.  The K-th column X(K) of X
    C                is placed in one of three classes according to the
    C                value of JVPT(K).
    C
    C                   If JVPT(K) .GT. 0, then X(K) is an initial
    C                                      column.
    C
    C                   If JVPT(K) .EQ. 0, then X(K) is a free column.
    C
    C                   If JVPT(K) .LT. 0, then X(K) is a final column.
    C
    C                Before the decomposition is computed, initial columns
    C                are moved to the beginning of the array X and final
    C                columns to the end.  Both initial and final columns
    C                are frozen in place during the computation and only
    C                free columns are moved.  At the K-th stage of the
    C                reduction, if X(K) is occupied by a free column
    C                it is interchanged with the free column of largest
    C                reduced norm.  JVPT is not referenced if
    C                JOB .EQ. 0.
    C
    C        WORK    COMPLEX(P).
    C                WORK is a work array.  WORK is not referenced if
    C                JOB .EQ. 0.
    C
    C        JOB     INTEGER.
    C                JOB is an integer that initiates column pivoting.
    C                If JOB .EQ. 0, no pivoting is done.
    C                If JOB .NE. 0, pivoting is done.
    C
    C     On Return
    C
    C        X       X contains in its upper triangle the upper
    C                triangular matrix R of the QR factorization.
    C                Below its diagonal X contains information from
    C                which the unitary part of the decomposition
    C                can be recovered.  Note that if pivoting has
    C                been requested, the decomposition is not that
    C                of the original matrix X but that of X
    C                with its columns permuted as described by JVPT.
    C
    C        QRAUX   COMPLEX(P).
    C                QRAUX contains further information required to recover
    C                the unitary part of the decomposition.
    C
    C        JVPT    JVPT(K) contains the index of the column of the
    C                original matrix that has been interchanged into
    C                the K-th column, if pivoting was requested.
    C
    C***REFERENCES  J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
    C                 Stewart, LINPACK Users' Guide, SIAM, 1979.
    C***ROUTINES CALLED  CAXPY, CDOTC, CSCAL, CSWAP, SCNRM2
    C***REVISION HISTORY  (YYMMDD)
    C   780814  DATE WRITTEN
    C   890531  Changed all specific intrinsics to generic.  (WRB)
    C   890831  Modified array declarations.  (WRB)
    C   890831  REVISION DATE from Version 3.2
    C   891214  Prologue converted to Version 4.0 format.  (BAB)
    C   900326  Removed duplicate information from DESCRIPTION section.
    C           (WRB)
    C   920501  Reformatted the REFERENCES section.  (WRB)
    C***END PROLOGUE  CQRDC