LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
dlarf1f.f
Go to the documentation of this file.
1*> \brief \b DLARF1F 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 DLARF1F + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlarf1f.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlarf1f.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlarf1f.f">
15*> [TXT]</a>
16*
17* Definition:
18* ===========
19*
20* SUBROUTINE DLARF1F( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
21*
22* .. Scalar Arguments ..
23* CHARACTER SIDE
24* INTEGER INCV, LDC, M, N
25* DOUBLE PRECISION TAU
26* ..
27* .. Array Arguments ..
28* DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * )
29* ..
30*
31*
32*> \par Purpose:
33* =============
34*>
35*> \verbatim
36*>
37*> DLARF1F applies a real elementary reflector H to a real 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**T
41*>
42*> where tau is a real scalar and v is a real vector.
43*>
44*> If tau = 0, then H is taken to be the unit matrix.
45*> \endverbatim
46*
47* Arguments:
48* ==========
49*
50*> \param[in] SIDE
51*> \verbatim
52*> SIDE is CHARACTER*1
53*> = 'L': form H * C
54*> = 'R': form C * H
55*> \endverbatim
56*>
57*> \param[in] M
58*> \verbatim
59*> M is INTEGER
60*> The number of rows of the matrix C.
61*> \endverbatim
62*>
63*> \param[in] N
64*> \verbatim
65*> N is INTEGER
66*> The number of columns of the matrix C.
67*> \endverbatim
68*>
69*> \param[in] V
70*> \verbatim
71*> V is DOUBLE PRECISION array, dimension
72*> (1 + (M-1)*abs(INCV)) if SIDE = 'L'
73*> or (1 + (N-1)*abs(INCV)) if SIDE = 'R'
74*> The vector v in the representation of H. V is not used if
75*> TAU = 0. V(1) is not referenced or modified.
76*> \endverbatim
77*>
78*> \param[in] INCV
79*> \verbatim
80*> INCV is INTEGER
81*> The increment between elements of v. INCV <> 0.
82*> \endverbatim
83*>
84*> \param[in] TAU
85*> \verbatim
86*> TAU is DOUBLE PRECISION
87*> The value tau in the representation of H.
88*> \endverbatim
89*>
90*> \param[in,out] C
91*> \verbatim
92*> C is DOUBLE PRECISION array, dimension (LDC,N)
93*> On entry, the m by n matrix C.
94*> On exit, C is overwritten by the matrix H * C if SIDE = 'L',
95*> or C * H if SIDE = 'R'.
96*> \endverbatim
97*>
98*> \param[in] LDC
99*> \verbatim
100*> LDC is INTEGER
101*> The leading dimension of the array C. LDC >= max(1,M).
102*> \endverbatim
103*>
104*> \param[out] WORK
105*> \verbatim
106*> WORK is DOUBLE PRECISION array, dimension
107*> (N) if SIDE = 'L'
108*> or (M) if SIDE = 'R'
109*> \endverbatim
110*
111* To take advantage of the fact that v(1) = 1, we do the following
112* v = [ 1 v_2 ]**T
113* If SIDE='L'
114* |-----|
115* | C_1 |
116* C =| C_2 |
117* |-----|
118* C_1\in\mathbb{R}^{1\times n}, C_2\in\mathbb{R}^{m-1\times n}
119* So we compute:
120* C = HC = (I - \tau vv**T)C
121* = C - \tau vv**T C
122* w = C**T v = [ C_1**T C_2**T ] [ 1 v_2 ]**T
123* = C_1**T + C_2**T v ( DGEMM then DAXPY )
124* C = C - \tau vv**T C
125* = C - \tau vw**T
126* Giving us C_1 = C_1 - \tau w**T ( DAXPY )
127* and
128* C_2 = C_2 - \tau v_2w**T ( DGER )
129* If SIDE='R'
130*
131* C = [ C_1 C_2 ]
132* C_1\in\mathbb{R}^{m\times 1}, C_2\in\mathbb{R}^{m\times n-1}
133* So we compute:
134* C = CH = C(I - \tau vv**T)
135* = C - \tau Cvv**T
136*
137* w = Cv = [ C_1 C_2 ] [ 1 v_2 ]**T
138* = C_1 + C_2v_2 ( DGEMM then DAXPY )
139* C = C - \tau Cvv**T
140* = C - \tau wv**T
141* Giving us C_1 = C_1 - \tau w ( DAXPY )
142* and
143* C_2 = C_2 - \tau wv_2**T ( DGER )
144*
145* Authors:
146* ========
147*
148*> \author Univ. of Tennessee
149*> \author Univ. of California Berkeley
150*> \author Univ. of Colorado Denver
151*> \author NAG Ltd.
152*
153*> \ingroup larf
154*
155* =====================================================================
156 SUBROUTINE dlarf1f( SIDE, M, N, V, INCV, TAU, C, LDC, WORK )
157*
158* -- LAPACK auxiliary routine --
159* -- LAPACK is a software package provided by Univ. of Tennessee, --
160* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
161*
162* .. Scalar Arguments ..
163 CHARACTER SIDE
164 INTEGER INCV, LDC, M, N
165 DOUBLE PRECISION TAU
166* ..
167* .. Array Arguments ..
168 DOUBLE PRECISION C( LDC, * ), V( * ), WORK( * )
169* ..
170*
171* =====================================================================
172*
173* .. Parameters ..
174 DOUBLE PRECISION ONE, ZERO
175 parameter( one = 1.0d+0, zero = 0.0d+0 )
176* ..
177* .. Local Scalars ..
178 LOGICAL APPLYLEFT
179 INTEGER I, LASTV, LASTC
180* ..
181* .. External Subroutines ..
182 EXTERNAL dgemv, dger, daxpy, dscal
183* ..
184* .. External Functions ..
185 LOGICAL LSAME
186 INTEGER ILADLR, ILADLC
187 EXTERNAL lsame, iladlr, iladlc
188* ..
189* .. Executable Statements ..
190*
191 applyleft = lsame( side, 'L' )
192 lastv = 1
193 lastc = 0
194 IF( tau.NE.zero ) THEN
195! Set up variables for scanning V. LASTV begins pointing to the end
196! of V.
197 IF( applyleft ) THEN
198 lastv = m
199 ELSE
200 lastv = n
201 END IF
202 IF( incv.GT.0 ) THEN
203 i = 1 + (lastv-1) * incv
204 ELSE
205 i = 1
206 END IF
207! Look for the last non-zero row in V.
208! Since we are assuming that V(1) = 1, and it is not stored, so we
209! shouldn't access it.
210 DO WHILE( lastv.GT.1 .AND. v( i ).EQ.zero )
211 lastv = lastv - 1
212 i = i - incv
213 END DO
214 IF( applyleft ) THEN
215! Scan for the last non-zero column in C(1:lastv,:).
216 lastc = iladlc(lastv, n, c, ldc)
217 ELSE
218! Scan for the last non-zero row in C(:,1:lastv).
219 lastc = iladlr(m, lastv, c, ldc)
220 END IF
221 END IF
222 IF( lastc.EQ.0 ) THEN
223 RETURN
224 END IF
225 IF( applyleft ) THEN
226*
227* Form H * C
228*
229 ! Check if lastv = 1. This means v = 1, So we just need to compute
230 ! C := HC = (1-\tau)C.
231 IF( lastv.EQ.1 ) THEN
232*
233* C(1,1:lastc) := ( 1 - tau ) * C(1,1:lastc)
234*
235 CALL dscal(lastc, one - tau, c, ldc)
236 ELSE
237*
238* w(1:lastc,1) := C(1:lastv,1:lastc)**T * v(1:lastv,1)
239*
240 ! w(1:lastc,1) := C(2:lastv,1:lastc)**T * v(2:lastv,1)
241 CALL dgemv( 'Transpose', lastv-1, lastc, one, c(1+1,1),
242 $ ldc, v(1+incv), incv, zero, work, 1)
243 ! w(1:lastc,1) += C(1,1:lastc)**T * v(1,1) = C(1,1:lastc)**T
244 CALL daxpy(lastc, one, c, ldc, work, 1)
245*
246* C(1:lastv,1:lastc) := C(...) - tau * v(1:lastv,1) * w(1:lastc,1)**T
247*
248 ! C(1, 1:lastc) := C(...) - tau * v(1,1) * w(1:lastc,1)**T
249 ! = C(...) - tau * w(1:lastc,1)**T
250 CALL daxpy(lastc, -tau, work, 1, c, ldc)
251 ! C(2:lastv,1:lastc) := C(...) - tau * v(2:lastv,1)*w(1:lastc,1)**T
252 CALL dger(lastv-1, lastc, -tau, v(1+incv), incv, work, 1,
253 $ c(1+1,1), ldc)
254 END IF
255 ELSE
256*
257* Form C * H
258*
259 ! Check if n = 1. This means v = 1, so we just need to compute
260 ! C := CH = C(1-\tau).
261 IF( lastv.EQ.1 ) THEN
262*
263* C(1:lastc,1) := ( 1 - tau ) * C(1:lastc,1)
264*
265 CALL dscal(lastc, one - tau, c, 1)
266 ELSE
267*
268* w(1:lastc,1) := C(1:lastc,1:lastv) * v(1:lastv,1)
269*
270 ! w(1:lastc,1) := C(1:lastc,2:lastv) * v(2:lastv,1)
271 CALL dgemv( 'No transpose', lastc, lastv-1, one,
272 $ c(1,1+1), ldc, v(1+incv), incv, zero, work, 1 )
273 ! w(1:lastc,1) += C(1:lastc,1) v(1,1) = C(1:lastc,1)
274 CALL daxpy(lastc, one, c, 1, work, 1)
275*
276* C(1:lastc,1:lastv) := C(...) - tau * w(1:lastc,1) * v(1:lastv,1)**T
277*
278 ! C(1:lastc,1) := C(...) - tau * w(1:lastc,1) * v(1,1)**T
279 ! = C(...) - tau * w(1:lastc,1)
280 CALL daxpy(lastc, -tau, work, 1, c, 1)
281 ! C(1:lastc,2:lastv) := C(...) - tau * w(1:lastc,1) * v(2:lastv)**T
282 CALL dger( lastc, lastv-1, -tau, work, 1, v(1+incv),
283 $ incv, c(1,1+1), ldc )
284 END IF
285 END IF
286 RETURN
287*
288* End of DLARF1F
289*
290 END
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
Definition dgemv.f:158
subroutine dger(m, n, alpha, x, incx, y, incy, a, lda)
DGER
Definition dger.f:130
subroutine dlarf1f(side, m, n, v, incv, tau, c, ldc, work)
DLARF1F applies an elementary reflector to a general rectangular
Definition dlarf1f.f:157
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79