LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zlamswlq.f
Go to the documentation of this file.
1*> \brief \b ZLAMSWLQ
2*
3* Definition:
4* ===========
5*
6* SUBROUTINE ZLAMSWLQ( 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* COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ),
16* $ T( LDT, * )
17*> \par Purpose:
18* =============
19*>
20*> \verbatim
21*>
22*> ZLAMSWLQ overwrites the general complex M-by-N matrix C with
23*>
24*>
25*> SIDE = 'L' SIDE = 'R'
26*> TRANS = 'N': Q * C C * Q
27*> TRANS = 'C': Q**H * C C * Q**H
28*> where Q is a complex unitary matrix defined as the product of blocked
29*> elementary reflectors computed by short wide LQ
30*> factorization (ZLASWLQ)
31*> \endverbatim
32*
33* Arguments:
34* ==========
35*
36*> \param[in] SIDE
37*> \verbatim
38*> SIDE is CHARACTER*1
39*> = 'L': apply Q or Q**H from the Left;
40*> = 'R': apply Q or Q**H from the Right.
41*> \endverbatim
42*>
43*> \param[in] TRANS
44*> \verbatim
45*> TRANS is CHARACTER*1
46*> = 'N': No transpose, apply Q;
47*> = 'C': Conjugate Transpose, apply Q**H.
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 COMPLEX*16 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*> ZLASWLQ 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 COMPLEX*16 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 COMPLEX*16 array, dimension (LDC,N)
118*> On entry, the M-by-N matrix C.
119*> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H 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) COMPLEX*16 array, dimension (MAX(1,LWORK))
131*> \endverbatim
132*>
133*> \param[in] LWORK
134*> \verbatim
135*> LWORK is INTEGER
136*> The dimension of the array WORK.
137*> If SIDE = 'L', LWORK >= max(1,NB) * MB;
138*> if SIDE = 'R', LWORK >= max(1,M) * MB.
139*> If LWORK = -1, then a workspace query is assumed; the routine
140*> only calculates the optimal size of the WORK array, returns
141*> this value as the first entry of the WORK array, and no error
142*> message related to LWORK is issued by XERBLA.
143*> \endverbatim
144*>
145*> \param[out] INFO
146*> \verbatim
147*> INFO is INTEGER
148*> = 0: successful exit
149*> < 0: if INFO = -i, the i-th argument had an illegal value
150*> \endverbatim
151*
152* Authors:
153* ========
154*
155*> \author Univ. of Tennessee
156*> \author Univ. of California Berkeley
157*> \author Univ. of Colorado Denver
158*> \author NAG Ltd.
159*
160*> \par Further Details:
161* =====================
162*>
163*> \verbatim
164*> Short-Wide LQ (SWLQ) performs LQ by a sequence of unitary transformations,
165*> representing Q as a product of other unitary matrices
166*> Q = Q(1) * Q(2) * . . . * Q(k)
167*> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
168*> Q(1) zeros out the upper diagonal entries of rows 1:NB of A
169*> Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
170*> Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
171*> . . .
172*>
173*> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
174*> stored under the diagonal of rows 1:MB of A, and by upper triangular
175*> block reflectors, stored in array T(1:LDT,1:N).
176*> For more information see Further Details in GELQT.
177*>
178*> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
179*> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
180*> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
181*> The last Q(k) may use fewer rows.
182*> For more information see Further Details in TPLQT.
183*>
184*> For more details of the overall algorithm, see the description of
185*> Sequential TSQR in Section 2.2 of [1].
186*>
187*> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
188*> J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
189*> SIAM J. Sci. Comput, vol. 34, no. 1, 2012
190*> \endverbatim
191*>
192*> \ingroup lamswlq
193*>
194* =====================================================================
195 SUBROUTINE zlamswlq( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
196 $ LDT, C, LDC, WORK, LWORK, INFO )
197*
198* -- LAPACK computational routine --
199* -- LAPACK is a software package provided by Univ. of Tennessee, --
200* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
201*
202* .. Scalar Arguments ..
203 CHARACTER SIDE, TRANS
204 INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
205* ..
206* .. Array Arguments ..
207 COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ),
208 $ t( ldt, * )
209* ..
210*
211* =====================================================================
212*
213* ..
214* .. Local Scalars ..
215 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
216 INTEGER I, II, KK, LW, CTR
217* ..
218* .. External Functions ..
219 LOGICAL LSAME
220 EXTERNAL lsame
221* .. External Subroutines ..
222 EXTERNAL ztpmlqt, zgemlqt, xerbla
223* ..
224* .. Executable Statements ..
225*
226* Test the input arguments
227*
228 lquery = lwork.LT.0
229 notran = lsame( trans, 'N' )
230 tran = lsame( trans, 'C' )
231 left = lsame( side, 'L' )
232 right = lsame( side, 'R' )
233 IF (left) THEN
234 lw = n * mb
235 ELSE
236 lw = m * mb
237 END IF
238*
239 info = 0
240 IF( .NOT.left .AND. .NOT.right ) THEN
241 info = -1
242 ELSE IF( .NOT.tran .AND. .NOT.notran ) THEN
243 info = -2
244 ELSE IF( k.LT.0 ) THEN
245 info = -5
246 ELSE IF( m.LT.k ) THEN
247 info = -3
248 ELSE IF( n.LT.0 ) THEN
249 info = -4
250 ELSE IF( k.LT.mb .OR. mb.LT.1) THEN
251 info = -6
252 ELSE IF( lda.LT.max( 1, k ) ) THEN
253 info = -9
254 ELSE IF( ldt.LT.max( 1, mb) ) THEN
255 info = -11
256 ELSE IF( ldc.LT.max( 1, m ) ) THEN
257 info = -13
258 ELSE IF(( lwork.LT.max(1,lw)).AND.(.NOT.lquery)) THEN
259 info = -15
260 END IF
261*
262 IF( info.NE.0 ) THEN
263 CALL xerbla( 'ZLAMSWLQ', -info )
264 work(1) = lw
265 RETURN
266 ELSE IF (lquery) THEN
267 work(1) = lw
268 RETURN
269 END IF
270*
271* Quick return if possible
272*
273 IF( min(m,n,k).EQ.0 ) THEN
274 RETURN
275 END IF
276*
277 IF((nb.LE.k).OR.(nb.GE.max(m,n,k))) THEN
278 CALL zgemlqt( side, trans, m, n, k, mb, a, lda,
279 $ t, ldt, c, ldc, work, info)
280 RETURN
281 END IF
282*
283 IF(left.AND.tran) THEN
284*
285* Multiply Q to the last block of C
286*
287 kk = mod((m-k),(nb-k))
288 ctr = (m-k)/(nb-k)
289*
290 IF (kk.GT.0) THEN
291 ii=m-kk+1
292 CALL ztpmlqt('L','C',kk , n, k, 0, mb, a(1,ii), lda,
293 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
294 $ c(ii,1), ldc, work, info )
295 ELSE
296 ii=m+1
297 END IF
298*
299 DO i=ii-(nb-k),nb+1,-(nb-k)
300*
301* Multiply Q to the current block of C (1:M,I:I+NB)
302*
303 ctr = ctr - 1
304 CALL ztpmlqt('L','C',nb-k , n, k, 0,mb, a(1,i), lda,
305 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
306 $ c(i,1), ldc, work, info )
307
308 END DO
309*
310* Multiply Q to the first block of C (1:M,1:NB)
311*
312 CALL zgemlqt('L','C',nb , n, k, mb, a(1,1), lda, t
313 $ ,ldt ,c(1,1), ldc, work, info )
314*
315 ELSE IF (left.AND.notran) THEN
316*
317* Multiply Q to the first block of C
318*
319 kk = mod((m-k),(nb-k))
320 ii=m-kk+1
321 ctr = 1
322 CALL zgemlqt('L','N',nb , n, k, mb, a(1,1), lda, t
323 $ ,ldt ,c(1,1), ldc, work, info )
324*
325 DO i=nb+1,ii-nb+k,(nb-k)
326*
327* Multiply Q to the current block of C (I:I+NB,1:N)
328*
329 CALL ztpmlqt('L','N',nb-k , n, k, 0,mb, a(1,i), lda,
330 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
331 $ c(i,1), ldc, work, info )
332 ctr = ctr + 1
333*
334 END DO
335 IF(ii.LE.m) THEN
336*
337* Multiply Q to the last block of C
338*
339 CALL ztpmlqt('L','N',kk , n, k, 0, mb, a(1,ii), lda,
340 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
341 $ c(ii,1), ldc, work, info )
342*
343 END IF
344*
345 ELSE IF(right.AND.notran) THEN
346*
347* Multiply Q to the last block of C
348*
349 kk = mod((n-k),(nb-k))
350 ctr = (n-k)/(nb-k)
351 IF (kk.GT.0) THEN
352 ii=n-kk+1
353 CALL ztpmlqt('R','N',m , kk, k, 0, mb, a(1, ii), lda,
354 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
355 $ c(1,ii), ldc, work, info )
356 ELSE
357 ii=n+1
358 END IF
359*
360 DO i=ii-(nb-k),nb+1,-(nb-k)
361*
362* Multiply Q to the current block of C (1:M,I:I+MB)
363*
364 ctr = ctr - 1
365 CALL ztpmlqt('R','N', m, nb-k, k, 0, mb, a(1, i), lda,
366 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
367 $ c(1,i), ldc, work, info )
368
369 END DO
370*
371* Multiply Q to the first block of C (1:M,1:MB)
372*
373 CALL zgemlqt('R','N',m , nb, k, mb, a(1,1), lda, t
374 $ ,ldt ,c(1,1), ldc, work, info )
375*
376 ELSE IF (right.AND.tran) THEN
377*
378* Multiply Q to the first block of C
379*
380 kk = mod((n-k),(nb-k))
381 ii=n-kk+1
382 CALL zgemlqt('R','C',m , nb, k, mb, a(1,1), lda, t
383 $ ,ldt ,c(1,1), ldc, work, info )
384 ctr = 1
385*
386 DO i=nb+1,ii-nb+k,(nb-k)
387*
388* Multiply Q to the current block of C (1:M,I:I+MB)
389*
390 CALL ztpmlqt('R','C',m , nb-k, k, 0,mb, a(1,i), lda,
391 $ t(1,ctr *k+1), ldt, c(1,1), ldc,
392 $ c(1,i), ldc, work, info )
393 ctr = ctr + 1
394*
395 END DO
396 IF(ii.LE.n) THEN
397*
398* Multiply Q to the last block of C
399*
400 CALL ztpmlqt('R','C',m , kk, k, 0,mb, a(1,ii), lda,
401 $ t(1, ctr * k + 1),ldt, c(1,1), ldc,
402 $ c(1,ii), ldc, work, info )
403*
404 END IF
405*
406 END IF
407*
408 work(1) = lw
409 RETURN
410*
411* End of ZLAMSWLQ
412*
413 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
ZGEMLQT
Definition zgemlqt.f:168
subroutine zlamswlq(side, trans, m, n, k, mb, nb, a, lda, t, ldt, c, ldc, work, lwork, info)
ZLAMSWLQ
Definition zlamswlq.f:197
subroutine ztpmlqt(side, trans, m, n, k, l, mb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
ZTPMLQT
Definition ztpmlqt.f:214