001:       SUBROUTINE CLATRZ( M, N, L, A, LDA, TAU, WORK )
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            L, LDA, M, N
010: *     ..
011: *     .. Array Arguments ..
012:       COMPLEX            A( LDA, * ), TAU( * ), WORK( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  CLATRZ factors the M-by-(M+L) complex upper trapezoidal matrix
019: *  [ A1 A2 ] = [ A(1:M,1:M) A(1:M,N-L+1:N) ] as ( R  0 ) * Z by means
020: *  of unitary transformations, where  Z is an (M+L)-by-(M+L) unitary
021: *  matrix and, R and A1 are M-by-M upper triangular matrices.
022: *
023: *  Arguments
024: *  =========
025: *
026: *  M       (input) INTEGER
027: *          The number of rows of the matrix A.  M >= 0.
028: *
029: *  N       (input) INTEGER
030: *          The number of columns of the matrix A.  N >= 0.
031: *
032: *  L       (input) INTEGER
033: *          The number of columns of the matrix A containing the
034: *          meaningful part of the Householder vectors. N-M >= L >= 0.
035: *
036: *  A       (input/output) COMPLEX array, dimension (LDA,N)
037: *          On entry, the leading M-by-N upper trapezoidal part of the
038: *          array A must contain the matrix to be factorized.
039: *          On exit, the leading M-by-M upper triangular part of A
040: *          contains the upper triangular matrix R, and elements N-L+1 to
041: *          N of the first M rows of A, with the array TAU, represent the
042: *          unitary matrix Z as a product of M elementary reflectors.
043: *
044: *  LDA     (input) INTEGER
045: *          The leading dimension of the array A.  LDA >= max(1,M).
046: *
047: *  TAU     (output) COMPLEX array, dimension (M)
048: *          The scalar factors of the elementary reflectors.
049: *
050: *  WORK    (workspace) COMPLEX array, dimension (M)
051: *
052: *  Further Details
053: *  ===============
054: *
055: *  Based on contributions by
056: *    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
057: *
058: *  The factorization is obtained by Householder's method.  The kth
059: *  transformation matrix, Z( k ), which is used to introduce zeros into
060: *  the ( m - k + 1 )th row of A, is given in the form
061: *
062: *     Z( k ) = ( I     0   ),
063: *              ( 0  T( k ) )
064: *
065: *  where
066: *
067: *     T( k ) = I - tau*u( k )*u( k )',   u( k ) = (   1    ),
068: *                                                 (   0    )
069: *                                                 ( z( k ) )
070: *
071: *  tau is a scalar and z( k ) is an l element vector. tau and z( k )
072: *  are chosen to annihilate the elements of the kth row of A2.
073: *
074: *  The scalar tau is returned in the kth element of TAU and the vector
075: *  u( k ) in the kth row of A2, such that the elements of z( k ) are
076: *  in  a( k, l + 1 ), ..., a( k, n ). The elements of R are returned in
077: *  the upper triangular part of A1.
078: *
079: *  Z is given by
080: *
081: *     Z =  Z( 1 ) * Z( 2 ) * ... * Z( m ).
082: *
083: *  =====================================================================
084: *
085: *     .. Parameters ..
086:       COMPLEX            ZERO
087:       PARAMETER          ( ZERO = ( 0.0E+0, 0.0E+0 ) )
088: *     ..
089: *     .. Local Scalars ..
090:       INTEGER            I
091:       COMPLEX            ALPHA
092: *     ..
093: *     .. External Subroutines ..
094:       EXTERNAL           CLACGV, CLARFP, CLARZ
095: *     ..
096: *     .. Intrinsic Functions ..
097:       INTRINSIC          CONJG
098: *     ..
099: *     .. Executable Statements ..
100: *
101: *     Quick return if possible
102: *
103:       IF( M.EQ.0 ) THEN
104:          RETURN
105:       ELSE IF( M.EQ.N ) THEN
106:          DO 10 I = 1, N
107:             TAU( I ) = ZERO
108:    10    CONTINUE
109:          RETURN
110:       END IF
111: *
112:       DO 20 I = M, 1, -1
113: *
114: *        Generate elementary reflector H(i) to annihilate
115: *        [ A(i,i) A(i,n-l+1:n) ]
116: *
117:          CALL CLACGV( L, A( I, N-L+1 ), LDA )
118:          ALPHA = CONJG( A( I, I ) )
119:          CALL CLARFP( L+1, ALPHA, A( I, N-L+1 ), LDA, TAU( I ) )
120:          TAU( I ) = CONJG( TAU( I ) )
121: *
122: *        Apply H(i) to A(1:i-1,i:n) from the right
123: *
124:          CALL CLARZ( 'Right', I-1, N-I+1, L, A( I, N-L+1 ), LDA,
125:      $               CONJG( TAU( I ) ), A( 1, I ), LDA, WORK )
126:          A( I, I ) = CONJG( ALPHA )
127: *
128:    20 CONTINUE
129: *
130:       RETURN
131: *
132: *     End of CLATRZ
133: *
134:       END
135: