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