001:       SUBROUTINE DLATRZ( 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:       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( * )
013: *     ..
014: *
015: *  Purpose
016: *  =======
017: *
018: *  DLATRZ factors the M-by-(M+L) real 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 orthogonal transformations.  Z is an (M+L)-by-(M+L) orthogonal
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) DOUBLE PRECISION 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: *          orthogonal 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) DOUBLE PRECISION array, dimension (M)
048: *          The scalar factors of the elementary reflectors.
049: *
050: *  WORK    (workspace) DOUBLE PRECISION 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:       DOUBLE PRECISION   ZERO
087:       PARAMETER          ( ZERO = 0.0D+0 )
088: *     ..
089: *     .. Local Scalars ..
090:       INTEGER            I
091: *     ..
092: *     .. External Subroutines ..
093:       EXTERNAL           DLARFP, DLARZ
094: *     ..
095: *     .. Executable Statements ..
096: *
097: *     Test the input arguments
098: *
099: *     Quick return if possible
100: *
101:       IF( M.EQ.0 ) THEN
102:          RETURN
103:       ELSE IF( M.EQ.N ) THEN
104:          DO 10 I = 1, N
105:             TAU( I ) = ZERO
106:    10    CONTINUE
107:          RETURN
108:       END IF
109: *
110:       DO 20 I = M, 1, -1
111: *
112: *        Generate elementary reflector H(i) to annihilate
113: *        [ A(i,i) A(i,n-l+1:n) ]
114: *
115:          CALL DLARFP( L+1, A( I, I ), A( I, N-L+1 ), LDA, TAU( I ) )
116: *
117: *        Apply H(i) to A(1:i-1,i:n) from the right
118: *
119:          CALL DLARZ( 'Right', I-1, N-I+1, L, A( I, N-L+1 ), LDA,
120:      $               TAU( I ), A( 1, I ), LDA, WORK )
121: *
122:    20 CONTINUE
123: *
124:       RETURN
125: *
126: *     End of DLATRZ
127: *
128:       END
129: