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