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