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