LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clarf1l.f
Go to the documentation of this file.
1*> \brief \b CLARF1L applies an elementary reflector to a general rectangular
2* matrix assuming v(lastv) = 1, where lastv is the last non-zero
3*
4* =========== DOCUMENTATION ===========
5*
6* Online html documentation available at
7* http://www.netlib.org/lapack/explore-html/
8*
9*> Download CLARF1L + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clarf1l.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clarf1l.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clarf1l.f">
15*> [TXT]</a>
16*
17* Definition:
18* ===========
19*
20* SUBROUTINE CLARF1L( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
21*
22* .. Scalar Arguments ..
23* CHARACTER SIDE
24* INTEGER INCV, LDC, M, N
25* COMPLEX TAU
26* ..
27* .. Array Arguments ..
28* COMPLEX C( LDC, * ), V( * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> CLARF1L applies a complex elementary reflector H to a complex m by n matrix
38*> C, from either the left or the right. H is represented in the form
39*>
40*> H = I - tau * v * v**H
41*>
42*> where tau is a real scalar and v is a real vector assuming v(lastv) = 1,
43*> where lastv is the last non-zero element.
44*>
45*> If tau = 0, then H is taken to be the unit matrix.
46*>
47*> To apply H**H (the conjugate transpose of H), supply conjg(tau) instead
48*> tau.
49*> \endverbatim
50*
51* Arguments:
52* ==========
53*
54*> \param[in] SIDE
55*> \verbatim
56*> SIDE is CHARACTER*1
57*> = 'L': form H * C
58*> = 'R': form C * H
59*> \endverbatim
60*>
61*> \param[in] M
62*> \verbatim
63*> M is INTEGER
64*> The number of rows of the matrix C.
65*> \endverbatim
66*>
67*> \param[in] N
68*> \verbatim
69*> N is INTEGER
70*> The number of columns of the matrix C.
71*> \endverbatim
72*>
73*> \param[in] V
74*> \verbatim
75*> V is COMPLEX array, dimension
76*> (1 + (M-1)*abs(INCV)) if SIDE = 'L'
77*> or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
78*> The vector v in the representation of H. V is not used if
79*> TAU = 0.
80*> \endverbatim
81*>
82*> \param[in] INCV
83*> \verbatim
84*> INCV is INTEGER
85*> The increment between elements of v. INCV > 0.
86*> \endverbatim
87*>
88*> \param[in] TAU
89*> \verbatim
90*> TAU is COMPLEX
91*> The value tau in the representation of H.
92*> \endverbatim
93*>
94*> \param[in,out] C
95*> \verbatim
96*> C is COMPLEX array, dimension (LDC,N)
97*> On entry, the m by n matrix C.
98*> On exit, C is overwritten by the matrix H * C if SIDE = 'L',
99*> or C * H if SIDE = 'R'.
100*> \endverbatim
101*>
102*> \param[in] LDC
103*> \verbatim
104*> LDC is INTEGER
105*> The leading dimension of the array C. LDC >= max(1,M).
106*> \endverbatim
107*>
108*> \param[out] WORK
109*> \verbatim
110*> WORK is COMPLEX array, dimension
111*> (N) if SIDE = 'L'
112*> or (M) if SIDE = 'R'
113*> \endverbatim
114*
115* Authors:
116* ========
117*
118*> \author Univ. of Tennessee
119*> \author Univ. of California Berkeley
120*> \author Univ. of Colorado Denver
121*> \author NAG Ltd.
122*
123*> \ingroup larf1f
124*
125* =====================================================================
126 SUBROUTINE clarf1l( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
127*
128* -- LAPACK auxiliary routine --
129* -- LAPACK is a software package provided by Univ. of Tennessee, --
130* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
131*
132* .. Scalar Arguments ..
133 CHARACTER SIDE
134 INTEGER INCV, LDC, M, N
135 COMPLEX TAU
136* ..
137* .. Array Arguments ..
138 COMPLEX C( LDC, * ), V( * ), WORK( * )
139* ..
140*
141* =====================================================================
142*
143* .. Parameters ..
144 COMPLEX ONE, ZERO
145 parameter( one = ( 1.0e+0, 0.0e+0 ),
146 $ zero = ( 0.0e+0, 0.0e+0 ) )
147* ..
148* .. Local Scalars ..
149 LOGICAL APPLYLEFT
150 INTEGER I, J, LASTV, LASTC, FIRSTV
151* ..
152* .. External Subroutines ..
153 EXTERNAL cgemv, cgerc, cscal
154* ..
155* .. Intrinsic Functions ..
156 INTRINSIC conjg
157* ..
158* .. External Functions ..
159 LOGICAL LSAME
160 INTEGER ILACLR, ILACLC
161 EXTERNAL lsame, ilaclr, ilaclc
162* ..
163* .. Executable Statements ..
164*
165 applyleft = lsame( side, 'L' )
166 firstv = 1
167 lastc = 0
168 IF( tau.NE.zero ) THEN
169! Set up variables for scanning V. LASTV begins pointing to the end
170! of V up to V(1).
171 IF( applyleft ) THEN
172 lastv = m
173 ELSE
174 lastv = n
175 END IF
176 i = 1
177! Look for the last non-zero row in V.
178 DO WHILE( lastv.GT.firstv .AND. v( i ).EQ.zero )
179 firstv = firstv + 1
180 i = i + incv
181 END DO
182 IF( applyleft ) THEN
183! Scan for the last non-zero column in C(1:lastv,:).
184 lastc = ilaclc(lastv, n, c, ldc)
185 ELSE
186! Scan for the last non-zero row in C(:,1:lastv).
187 lastc = ilaclr(m, lastv, c, ldc)
188 END IF
189 END IF
190 IF( lastc.EQ.0 ) THEN
191 RETURN
192 END IF
193 IF( applyleft ) THEN
194*
195* Form H * C
196*
197 IF( lastv.EQ.firstv ) THEN
198*
199* C(lastv,1:lastc) := ( 1 - tau ) * C(lastv,1:lastc)
200*
201 CALL cscal( lastc, one - tau, c( lastv, 1 ), ldc )
202 ELSE
203*
204* w(1:lastc,1) := C(firstv:lastv-1,1:lastc)**T * v(firstv:lastv-1,1)
205*
206 CALL cgemv( 'Conjugate transpose', lastv - firstv, lastc,
207 $ one, c( firstv, 1 ), ldc, v( i ), incv, zero,
208 $ work, 1 )
209*
210* w(1:lastc,1) += C(lastv,1:lastc)**H * v(lastv,1)
211*
212 DO j = 1, lastc
213 work( j ) = work( j ) + conjg( c( lastv, j ) )
214 END DO
215*
216* C(lastv,1:lastc) += - tau * v(lastv,1) * w(1:lastc,1)**H
217*
218 DO j = 1, lastc
219 c( lastv, j ) = c( lastv, j )
220 $ - tau * conjg( work( j ) )
221 END DO
222*
223* C(firstv:lastv-1,1:lastc) += - tau * v(firstv:lastv-1,1) * w(1:lastc,1)**H
224*
225 CALL cgerc( lastv - firstv, lastc, -tau, v( i ), incv,
226 $ work, 1, c( firstv, 1 ), ldc)
227 END IF
228 ELSE
229*
230* Form C * H
231*
232 IF( lastv.EQ.firstv ) THEN
233*
234* C(1:lastc,lastv) := ( 1 - tau ) * C(1:lastc,lastv)
235*
236 CALL cscal( lastc, one - tau, c( 1, lastv ), 1 )
237 ELSE
238*
239* w(1:lastc,1) := C(1:lastc,firstv:lastv-1) * v(firstv:lastv-1,1)
240*
241 CALL cgemv( 'No transpose', lastc, lastv - firstv, one,
242 $ c( 1, firstv ), ldc, v( i ), incv, zero,
243 $ work, 1 )
244*
245* w(1:lastc,1) += C(1:lastc,lastv) * v(lastv,1)
246*
247 CALL caxpy( lastc, one, c( 1, lastv ), 1, work, 1 )
248*
249* C(1:lastc,lastv) += - tau * v(lastv,1) * w(1:lastc,1)
250*
251 CALL caxpy( lastc, -tau, work, 1, c( 1, lastv ), 1 )
252*
253* C(1:lastc,firstv:lastv-1) += - tau * w(1:lastc,1) * v(firstv:lastv-1)**H
254*
255 CALL cgerc( lastc, lastv - firstv, -tau, work, 1, v( i ),
256 $ incv, c( 1, firstv ), ldc )
257 END IF
258 END IF
259 RETURN
260*
261* End of CLARF1L
262*
263 END
subroutine clarf1l(side, m, n, v, incv, tau, c, ldc, work)
CLARF1L applies an elementary reflector to a general rectangular
Definition clarf1l.f:127
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
Definition caxpy.f:88
subroutine cgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
CGEMV
Definition cgemv.f:160
subroutine cgerc(m, n, alpha, x, incx, y, incy, a, lda)
CGERC
Definition cgerc.f:130
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78