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