001:       SUBROUTINE DLARZ( SIDE, M, N, L, V, INCV, TAU, C, LDC, 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:       CHARACTER          SIDE
009:       INTEGER            INCV, L, LDC, M, N
010:       DOUBLE PRECISION   TAU
011: *     ..
012: *     .. Array Arguments ..
013:       DOUBLE PRECISION   C( LDC, * ), V( * ), WORK( * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  DLARZ applies a real elementary reflector H to a real M-by-N
020: *  matrix C, from either the left or the right. H is represented in the
021: *  form
022: *
023: *        H = I - tau * v * v'
024: *
025: *  where tau is a real scalar and v is a real vector.
026: *
027: *  If tau = 0, then H is taken to be the unit matrix.
028: *
029: *
030: *  H is a product of k elementary reflectors as returned by DTZRZF.
031: *
032: *  Arguments
033: *  =========
034: *
035: *  SIDE    (input) CHARACTER*1
036: *          = 'L': form  H * C
037: *          = 'R': form  C * H
038: *
039: *  M       (input) INTEGER
040: *          The number of rows of the matrix C.
041: *
042: *  N       (input) INTEGER
043: *          The number of columns of the matrix C.
044: *
045: *  L       (input) INTEGER
046: *          The number of entries of the vector V containing
047: *          the meaningful part of the Householder vectors.
048: *          If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
049: *
050: *  V       (input) DOUBLE PRECISION array, dimension (1+(L-1)*abs(INCV))
051: *          The vector v in the representation of H as returned by
052: *          DTZRZF. V is not used if TAU = 0.
053: *
054: *  INCV    (input) INTEGER
055: *          The increment between elements of v. INCV <> 0.
056: *
057: *  TAU     (input) DOUBLE PRECISION
058: *          The value tau in the representation of H.
059: *
060: *  C       (input/output) DOUBLE PRECISION array, dimension (LDC,N)
061: *          On entry, the M-by-N matrix C.
062: *          On exit, C is overwritten by the matrix H * C if SIDE = 'L',
063: *          or C * H if SIDE = 'R'.
064: *
065: *  LDC     (input) INTEGER
066: *          The leading dimension of the array C. LDC >= max(1,M).
067: *
068: *  WORK    (workspace) DOUBLE PRECISION array, dimension
069: *                         (N) if SIDE = 'L'
070: *                      or (M) if SIDE = 'R'
071: *
072: *  Further Details
073: *  ===============
074: *
075: *  Based on contributions by
076: *    A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
077: *
078: *  =====================================================================
079: *
080: *     .. Parameters ..
081:       DOUBLE PRECISION   ONE, ZERO
082:       PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
083: *     ..
084: *     .. External Subroutines ..
085:       EXTERNAL           DAXPY, DCOPY, DGEMV, DGER
086: *     ..
087: *     .. External Functions ..
088:       LOGICAL            LSAME
089:       EXTERNAL           LSAME
090: *     ..
091: *     .. Executable Statements ..
092: *
093:       IF( LSAME( SIDE, 'L' ) ) THEN
094: *
095: *        Form  H * C
096: *
097:          IF( TAU.NE.ZERO ) THEN
098: *
099: *           w( 1:n ) = C( 1, 1:n )
100: *
101:             CALL DCOPY( N, C, LDC, WORK, 1 )
102: *
103: *           w( 1:n ) = w( 1:n ) + C( m-l+1:m, 1:n )' * v( 1:l )
104: *
105:             CALL DGEMV( 'Transpose', L, N, ONE, C( M-L+1, 1 ), LDC, V,
106:      $                  INCV, ONE, WORK, 1 )
107: *
108: *           C( 1, 1:n ) = C( 1, 1:n ) - tau * w( 1:n )
109: *
110:             CALL DAXPY( N, -TAU, WORK, 1, C, LDC )
111: *
112: *           C( m-l+1:m, 1:n ) = C( m-l+1:m, 1:n ) - ...
113: *                               tau * v( 1:l ) * w( 1:n )'
114: *
115:             CALL DGER( L, N, -TAU, V, INCV, WORK, 1, C( M-L+1, 1 ),
116:      $                 LDC )
117:          END IF
118: *
119:       ELSE
120: *
121: *        Form  C * H
122: *
123:          IF( TAU.NE.ZERO ) THEN
124: *
125: *           w( 1:m ) = C( 1:m, 1 )
126: *
127:             CALL DCOPY( M, C, 1, WORK, 1 )
128: *
129: *           w( 1:m ) = w( 1:m ) + C( 1:m, n-l+1:n, 1:n ) * v( 1:l )
130: *
131:             CALL DGEMV( 'No transpose', M, L, ONE, C( 1, N-L+1 ), LDC,
132:      $                  V, INCV, ONE, WORK, 1 )
133: *
134: *           C( 1:m, 1 ) = C( 1:m, 1 ) - tau * w( 1:m )
135: *
136:             CALL DAXPY( M, -TAU, WORK, 1, C, 1 )
137: *
138: *           C( 1:m, n-l+1:n ) = C( 1:m, n-l+1:n ) - ...
139: *                               tau * w( 1:m ) * v( 1:l )'
140: *
141:             CALL DGER( M, L, -TAU, WORK, 1, V, INCV, C( 1, N-L+1 ),
142:      $                 LDC )
143: *
144:          END IF
145: *
146:       END IF
147: *
148:       RETURN
149: *
150: *     End of DLARZ
151: *
152:       END
153: