```001:       SUBROUTINE CTZRQF( M, N, A, LDA, TAU, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       INTEGER            INFO, LDA, M, N
010: *     ..
011: *     .. Array Arguments ..
012:       COMPLEX            A( LDA, * ), TAU( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  This routine is deprecated and has been replaced by routine CTZRZF.
019: *
020: *  CTZRQF reduces the M-by-N ( M<=N ) complex upper trapezoidal matrix A
021: *  to upper triangular form by means of unitary transformations.
022: *
023: *  The upper trapezoidal matrix A is factored as
024: *
025: *     A = ( R  0 ) * Z,
026: *
027: *  where Z is an N-by-N unitary matrix and R is an M-by-M upper
028: *  triangular matrix.
029: *
030: *  Arguments
031: *  =========
032: *
033: *  M       (input) INTEGER
034: *          The number of rows of the matrix A.  M >= 0.
035: *
036: *  N       (input) INTEGER
037: *          The number of columns of the matrix A.  N >= M.
038: *
039: *  A       (input/output) COMPLEX array, dimension (LDA,N)
040: *          On entry, the leading M-by-N upper trapezoidal part of the
041: *          array A must contain the matrix to be factorized.
042: *          On exit, the leading M-by-M upper triangular part of A
043: *          contains the upper triangular matrix R, and elements M+1 to
044: *          N of the first M rows of A, with the array TAU, represent the
045: *          unitary matrix Z as a product of M elementary reflectors.
046: *
047: *  LDA     (input) INTEGER
048: *          The leading dimension of the array A.  LDA >= max(1,M).
049: *
050: *  TAU     (output) COMPLEX array, dimension (M)
051: *          The scalar factors of the elementary reflectors.
052: *
053: *  INFO    (output) INTEGER
054: *          = 0: successful exit
055: *          < 0: if INFO = -i, the i-th argument had an illegal value
056: *
057: *  Further Details
058: *  ===============
059: *
060: *  The  factorization is obtained by Householder's method.  The kth
061: *  transformation matrix, Z( k ), whose conjugate transpose is used to
062: *  introduce zeros into the (m - k + 1)th row of A, is given in the form
063: *
064: *     Z( k ) = ( I     0   ),
065: *              ( 0  T( k ) )
066: *
067: *  where
068: *
069: *     T( k ) = I - tau*u( k )*u( k )',   u( k ) = (   1    ),
070: *                                                 (   0    )
071: *                                                 ( z( k ) )
072: *
073: *  tau is a scalar and z( k ) is an ( n - m ) element vector.
074: *  tau and z( k ) are chosen to annihilate the elements of the kth row
075: *  of X.
076: *
077: *  The scalar tau is returned in the kth element of TAU and the vector
078: *  u( k ) in the kth row of A, such that the elements of z( k ) are
079: *  in  a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in
080: *  the upper triangular part of A.
081: *
082: *  Z is given by
083: *
084: *     Z =  Z( 1 ) * Z( 2 ) * ... * Z( m ).
085: *
086: * =====================================================================
087: *
088: *     .. Parameters ..
089:       COMPLEX            CONE, CZERO
090:       PARAMETER          ( CONE = ( 1.0E+0, 0.0E+0 ),
091:      \$                   CZERO = ( 0.0E+0, 0.0E+0 ) )
092: *     ..
093: *     .. Local Scalars ..
094:       INTEGER            I, K, M1
095:       COMPLEX            ALPHA
096: *     ..
097: *     .. Intrinsic Functions ..
098:       INTRINSIC          CONJG, MAX, MIN
099: *     ..
100: *     .. External Subroutines ..
101:       EXTERNAL           CAXPY, CCOPY, CGEMV, CGERC, CLACGV, CLARFP,
102:      \$                   XERBLA
103: *     ..
104: *     .. Executable Statements ..
105: *
106: *     Test the input parameters.
107: *
108:       INFO = 0
109:       IF( M.LT.0 ) THEN
110:          INFO = -1
111:       ELSE IF( N.LT.M ) THEN
112:          INFO = -2
113:       ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
114:          INFO = -4
115:       END IF
116:       IF( INFO.NE.0 ) THEN
117:          CALL XERBLA( 'CTZRQF', -INFO )
118:          RETURN
119:       END IF
120: *
121: *     Perform the factorization.
122: *
123:       IF( M.EQ.0 )
124:      \$   RETURN
125:       IF( M.EQ.N ) THEN
126:          DO 10 I = 1, N
127:             TAU( I ) = CZERO
128:    10    CONTINUE
129:       ELSE
130:          M1 = MIN( M+1, N )
131:          DO 20 K = M, 1, -1
132: *
133: *           Use a Householder reflection to zero the kth row of A.
134: *           First set up the reflection.
135: *
136:             A( K, K ) = CONJG( A( K, K ) )
137:             CALL CLACGV( N-M, A( K, M1 ), LDA )
138:             ALPHA = A( K, K )
139:             CALL CLARFP( N-M+1, ALPHA, A( K, M1 ), LDA, TAU( K ) )
140:             A( K, K ) = ALPHA
141:             TAU( K ) = CONJG( TAU( K ) )
142: *
143:             IF( TAU( K ).NE.CZERO .AND. K.GT.1 ) THEN
144: *
145: *              We now perform the operation  A := A*P( k )'.
146: *
147: *              Use the first ( k - 1 ) elements of TAU to store  a( k ),
148: *              where  a( k ) consists of the first ( k - 1 ) elements of
149: *              the  kth column  of  A.  Also  let  B  denote  the  first
150: *              ( k - 1 ) rows of the last ( n - m ) columns of A.
151: *
152:                CALL CCOPY( K-1, A( 1, K ), 1, TAU, 1 )
153: *
154: *              Form   w = a( k ) + B*z( k )  in TAU.
155: *
156:                CALL CGEMV( 'No transpose', K-1, N-M, CONE, A( 1, M1 ),
157:      \$                     LDA, A( K, M1 ), LDA, CONE, TAU, 1 )
158: *
159: *              Now form  a( k ) := a( k ) - conjg(tau)*w
160: *              and       B      := B      - conjg(tau)*w*z( k )'.
161: *
162:                CALL CAXPY( K-1, -CONJG( TAU( K ) ), TAU, 1, A( 1, K ),
163:      \$                     1 )
164:                CALL CGERC( K-1, N-M, -CONJG( TAU( K ) ), TAU, 1,
165:      \$                     A( K, M1 ), LDA, A( 1, M1 ), LDA )
166:             END IF
167:    20    CONTINUE
168:       END IF
169: *
170:       RETURN
171: *
172: *     End of CTZRQF
173: *
174:       END
175: ```