LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
slamswlq.f
Go to the documentation of this file.
1*> \brief \b SLAMSWLQ
2*
3* Definition:
4* ===========
5*
6* SUBROUTINE SLAMSWLQ( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
7* $ LDT, C, LDC, WORK, LWORK, INFO )
8*
9*
10* .. Scalar Arguments ..
11* CHARACTER SIDE, TRANS
12* INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
13* ..
14* .. Array Arguments ..
15* DOUBLE A( LDA, * ), WORK( * ), C(LDC, * ),
16* $ T( LDT, * )
17*> \par Purpose:
18* =============
19*>
20*> \verbatim
21*>
22*> SLAMSWLQ overwrites the general real M-by-N matrix C with
23*>
24*>
25*> SIDE = 'L' SIDE = 'R'
26*> TRANS = 'N': Q * C C * Q
27*> TRANS = 'T': Q**T * C C * Q**T
28*> where Q is a real orthogonal matrix defined as the product of blocked
29*> elementary reflectors computed by short wide LQ
30*> factorization (SLASWLQ)
31*> \endverbatim
32*
33* Arguments:
34* ==========
35*
36*> \param[in] SIDE
37*> \verbatim
38*> SIDE is CHARACTER*1
39*> = 'L': apply Q or Q**T from the Left;
40*> = 'R': apply Q or Q**T from the Right.
41*> \endverbatim
42*>
43*> \param[in] TRANS
44*> \verbatim
45*> TRANS is CHARACTER*1
46*> = 'N': No transpose, apply Q;
47*> = 'T': Transpose, apply Q**T.
48*> \endverbatim
49*>
50*> \param[in] M
51*> \verbatim
52*> M is INTEGER
53*> The number of rows of the matrix C. M >=0.
54*> \endverbatim
55*>
56*> \param[in] N
57*> \verbatim
58*> N is INTEGER
59*> The number of columns of the matrix C. N >= 0.
60*> \endverbatim
61*>
62*> \param[in] K
63*> \verbatim
64*> K is INTEGER
65*> The number of elementary reflectors whose product defines
66*> the matrix Q.
67*> M >= K >= 0;
68*>
69*> \endverbatim
70*> \param[in] MB
71*> \verbatim
72*> MB is INTEGER
73*> The row block size to be used in the blocked LQ.
74*> M >= MB >= 1
75*> \endverbatim
76*>
77*> \param[in] NB
78*> \verbatim
79*> NB is INTEGER
80*> The column block size to be used in the blocked LQ.
81*> NB > M.
82*> \endverbatim
83*>
84*> \param[in] A
85*> \verbatim
86*> A is REAL array, dimension
87*> (LDA,M) if SIDE = 'L',
88*> (LDA,N) if SIDE = 'R'
89*> The i-th row must contain the vector which defines the blocked
90*> elementary reflector H(i), for i = 1,2,...,k, as returned by
91*> SLASWLQ in the first k rows of its array argument A.
92*> \endverbatim
93*>
94*> \param[in] LDA
95*> \verbatim
96*> LDA is INTEGER
97*> The leading dimension of the array A. LDA >= max(1,K).
98*> \endverbatim
99*>
100*> \param[in] T
101*> \verbatim
102*> T is REAL array, dimension
103*> ( M * Number of blocks(CEIL(N-K/NB-K)),
104*> The blocked upper triangular block reflectors stored in compact form
105*> as a sequence of upper triangular blocks. See below
106*> for further details.
107*> \endverbatim
108*>
109*> \param[in] LDT
110*> \verbatim
111*> LDT is INTEGER
112*> The leading dimension of the array T. LDT >= MB.
113*> \endverbatim
114*>
115*> \param[in,out] C
116*> \verbatim
117*> C is REAL array, dimension (LDC,N)
118*> On entry, the M-by-N matrix C.
119*> On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
120*> \endverbatim
121*>
122*> \param[in] LDC
123*> \verbatim
124*> LDC is INTEGER
125*> The leading dimension of the array C. LDC >= max(1,M).
126*> \endverbatim
127*>
128*> \param[out] WORK
129*> \verbatim
130*> (workspace) REAL array, dimension (MAX(1,LWORK))
131*> On exit, if INFO = 0, WORK(1) returns the minimal LWORK.
132*> \endverbatim
133*>
134*> \param[in] LWORK
135*> \verbatim
136*> LWORK is INTEGER
137*> The dimension of the array WORK.
138*>
139*> If MIN(M,N,K) = 0, LWORK >= 1.
140*> If SIDE = 'L', LWORK >= max(1,NB*MB).
141*> If SIDE = 'R', LWORK >= max(1,M*MB).
142*> If LWORK = -1, then a workspace query is assumed; the routine
143*> only calculates the minimal size of the WORK array, returns
144*> this value as the first entry of the WORK array, and no error
145*> message related to LWORK is issued by XERBLA.
146*> \endverbatim
147*>
148*> \param[out] INFO
149*> \verbatim
150*> INFO is INTEGER
151*> = 0: successful exit
152*> < 0: if INFO = -i, the i-th argument had an illegal value
153*> \endverbatim
154*
155* Authors:
156* ========
157*
158*> \author Univ. of Tennessee
159*> \author Univ. of California Berkeley
160*> \author Univ. of Colorado Denver
161*> \author NAG Ltd.
162*
163*> \par Further Details:
164* =====================
165*>
166*> \verbatim
167*> Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations,
168*> representing Q as a product of other orthogonal matrices
169*> Q = Q(1) * Q(2) * . . . * Q(k)
170*> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
171*> Q(1) zeros out the upper diagonal entries of rows 1:NB of A
172*> Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
173*> Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
174*> . . .
175*>
176*> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
177*> stored under the diagonal of rows 1:MB of A, and by upper triangular
178*> block reflectors, stored in array T(1:LDT,1:N).
179*> For more information see Further Details in GELQT.
180*>
181*> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
182*> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
183*> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
184*> The last Q(k) may use fewer rows.
185*> For more information see Further Details in TPLQT.
186*>
187*> For more details of the overall algorithm, see the description of
188*> Sequential TSQR in Section 2.2 of [1].
189*>
190*> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
191*> J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
192*> SIAM J. Sci. Comput, vol. 34, no. 1, 2012
193*> \endverbatim
194*>
195*> \ingroup lamswlq
196*>
197* =====================================================================
198 SUBROUTINE slamswlq( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
199 $ LDT, C, LDC, WORK, LWORK, INFO )
200*
201* -- LAPACK computational routine --
202* -- LAPACK is a software package provided by Univ. of Tennessee, --
203* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
204*
205* .. Scalar Arguments ..
206 CHARACTER SIDE, TRANS
207 INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
208* ..
209* .. Array Arguments ..
210 REAL A( LDA, * ), WORK( * ), C( LDC, * ),
211 $ t( ldt, * )
212* ..
213*
214* =====================================================================
215*
216* ..
217* .. Local Scalars ..
218 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
219 INTEGER I, II, KK, LW, CTR, MINMNK, LWMIN
220* ..
221* .. External Functions ..
222 LOGICAL LSAME
223 EXTERNAL lsame
224 REAL SROUNDUP_LWORK
225 EXTERNAL sroundup_lwork
226* ..
227* .. External Subroutines ..
228 EXTERNAL stpmlqt, sgemlqt, xerbla
229* ..
230* .. Executable Statements ..
231*
232* Test the input arguments
233*
234 lquery = ( lwork.EQ.-1 )
235 notran = lsame( trans, 'N' )
236 tran = lsame( trans, 'T' )
237 left = lsame( side, 'L' )
238 right = lsame( side, 'R' )
239 IF( left ) THEN
240 lw = n * mb
241 ELSE
242 lw = m * mb
243 END IF
244*
245 minmnk = min( m, n, k )
246 IF( minmnk.EQ.0 ) THEN
247 lwmin = 1
248 ELSE
249 lwmin = max( 1, lw )
250 END IF
251*
252 info = 0
253 IF( .NOT.left .AND. .NOT.right ) THEN
254 info = -1
255 ELSE IF( .NOT.tran .AND. .NOT.notran ) THEN
256 info = -2
257 ELSE IF( k.LT.0 ) THEN
258 info = -5
259 ELSE IF( m.LT.k ) THEN
260 info = -3
261 ELSE IF( n.LT.0 ) THEN
262 info = -4
263 ELSE IF( k.LT.mb .OR. mb.LT.1 ) THEN
264 info = -6
265 ELSE IF( lda.LT.max( 1, k ) ) THEN
266 info = -9
267 ELSE IF( ldt.LT.max( 1, mb ) ) THEN
268 info = -11
269 ELSE IF( ldc.LT.max( 1, m ) ) THEN
270 info = -13
271 ELSE IF( lwork.LT.lwmin .AND. (.NOT.lquery) ) THEN
272 info = -15
273 END IF
274*
275 IF( info.EQ.0 ) THEN
276 work( 1 ) = sroundup_lwork( lwmin )
277 END IF
278 IF( info.NE.0 ) THEN
279 CALL xerbla( 'SLAMSWLQ', -info )
280 RETURN
281 ELSE IF( lquery ) THEN
282 RETURN
283 END IF
284*
285* Quick return if possible
286*
287 IF( minmnk.EQ.0 ) THEN
288 RETURN
289 END IF
290*
291 IF((nb.LE.k).OR.(nb.GE.max(m,n,k))) THEN
292 CALL sgemlqt( side, trans, m, n, k, mb, a, lda,
293 $ t, ldt, c, ldc, work, info)
294 RETURN
295 END IF
296*
297 IF(left.AND.tran) THEN
298*
299* Multiply Q to the last block of C
300*
301 kk = mod((m-k),(nb-k))
302 ctr = (m-k)/(nb-k)
303*
304 IF (kk.GT.0) THEN
305 ii=m-kk+1
306 CALL stpmlqt('L','T',kk , n, k, 0, mb, a(1,ii), lda,
307 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
308 $ c(ii,1), ldc, work, info )
309 ELSE
310 ii=m+1
311 END IF
312*
313 DO i=ii-(nb-k),nb+1,-(nb-k)
314*
315* Multiply Q to the current block of C (1:M,I:I+NB)
316*
317 ctr = ctr - 1
318 CALL stpmlqt('L','T',nb-k , n, k, 0,mb, a(1,i), lda,
319 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
320 $ c(i,1), ldc, work, info )
321 END DO
322*
323* Multiply Q to the first block of C (1:M,1:NB)
324*
325 CALL sgemlqt('L','T',nb , n, k, mb, a(1,1), lda, t
326 $ ,ldt ,c(1,1), ldc, work, info )
327*
328 ELSE IF (left.AND.notran) THEN
329*
330* Multiply Q to the first block of C
331*
332 kk = mod((m-k),(nb-k))
333 ii=m-kk+1
334 ctr = 1
335 CALL sgemlqt('L','N',nb , n, k, mb, a(1,1), lda, t
336 $ ,ldt ,c(1,1), ldc, work, info )
337*
338 DO i=nb+1,ii-nb+k,(nb-k)
339*
340* Multiply Q to the current block of C (I:I+NB,1:N)
341*
342 CALL stpmlqt('L','N',nb-k , n, k, 0,mb, a(1,i), lda,
343 $ t(1,ctr * k+1), ldt, c(1,1), ldc,
344 $ c(i,1), ldc, work, info )
345 ctr = ctr + 1
346*
347 END DO
348 IF(ii.LE.m) THEN
349*
350* Multiply Q to the last block of C
351*
352 CALL stpmlqt('L','N',kk , n, k, 0, mb, a(1,ii), lda,
353 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
354 $ c(ii,1), ldc, work, info )
355*
356 END IF
357*
358 ELSE IF(right.AND.notran) THEN
359*
360* Multiply Q to the last block of C
361*
362 kk = mod((n-k),(nb-k))
363 ctr = (n-k)/(nb-k)
364 IF (kk.GT.0) THEN
365 ii=n-kk+1
366 CALL stpmlqt('R','N',m , kk, k, 0, mb, a(1, ii), lda,
367 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
368 $ c(1,ii), ldc, work, info )
369 ELSE
370 ii=n+1
371 END IF
372*
373 DO i=ii-(nb-k),nb+1,-(nb-k)
374*
375* Multiply Q to the current block of C (1:M,I:I+MB)
376*
377 ctr = ctr - 1
378 CALL stpmlqt('R','N', m, nb-k, k, 0, mb, a(1, i), lda,
379 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
380 $ c(1,i), ldc, work, info )
381
382 END DO
383*
384* Multiply Q to the first block of C (1:M,1:MB)
385*
386 CALL sgemlqt('R','N',m , nb, k, mb, a(1,1), lda, t
387 $ ,ldt ,c(1,1), ldc, work, info )
388*
389 ELSE IF (right.AND.tran) THEN
390*
391* Multiply Q to the first block of C
392*
393 kk = mod((n-k),(nb-k))
394 ii=n-kk+1
395 ctr = 1
396 CALL sgemlqt('R','T',m , nb, k, mb, a(1,1), lda, t
397 $ ,ldt ,c(1,1), ldc, work, info )
398*
399 DO i=nb+1,ii-nb+k,(nb-k)
400*
401* Multiply Q to the current block of C (1:M,I:I+MB)
402*
403 CALL stpmlqt('R','T',m , nb-k, k, 0,mb, a(1,i), lda,
404 $ t(1, ctr*k+1), ldt, c(1,1), ldc,
405 $ c(1,i), ldc, work, info )
406 ctr = ctr + 1
407*
408 END DO
409 IF(ii.LE.n) THEN
410*
411* Multiply Q to the last block of C
412*
413 CALL stpmlqt('R','T',m , kk, k, 0,mb, a(1,ii), lda,
414 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
415 $ c(1,ii), ldc, work, info )
416*
417 END IF
418*
419 END IF
420*
421 work( 1 ) = sroundup_lwork( lwmin )
422 RETURN
423*
424* End of SLAMSWLQ
425*
426 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine sgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
SGEMLQT
Definition sgemlqt.f:153
subroutine slamswlq(side, trans, m, n, k, mb, nb, a, lda, t, ldt, c, ldc, work, lwork, info)
SLAMSWLQ
Definition slamswlq.f:200
subroutine stpmlqt(side, trans, m, n, k, l, mb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
STPMLQT
Definition stpmlqt.f:213