LAPACK  3.9.0
LAPACK: Linear Algebra PACKage
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 *> ZLAMQRTS 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 = 'C': Q**H * C C * Q**H
28 *> where Q is a real orthogonal 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 >= M.
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 QR.
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 QR.
81 *> NB > M.
82 *> \endverbatim
83 *>
84 *> \param[in] NB
85 *> \verbatim
86 *> NB is INTEGER
87 *> The block size to be used in the blocked QR.
88 *> MB > M.
89 *>
90 *> \endverbatim
91 *>
92 *> \param[in] A
93 *> \verbatim
94 *> A is COMPLEX*16 array, dimension
95 *> (LDA,M) if SIDE = 'L',
96 *> (LDA,N) if SIDE = 'R'
97 *> The i-th row must contain the vector which defines the blocked
98 *> elementary reflector H(i), for i = 1,2,...,k, as returned by
99 *> ZLASWLQ in the first k rows of its array argument A.
100 *> \endverbatim
101 *>
102 *> \param[in] LDA
103 *> \verbatim
104 *> LDA is INTEGER
105 *> The leading dimension of the array A.
106 *> If SIDE = 'L', LDA >= max(1,M);
107 *> if SIDE = 'R', LDA >= max(1,N).
108 *> \endverbatim
109 *>
110 *> \param[in] T
111 *> \verbatim
112 *> T is COMPLEX*16 array, dimension
113 *> ( M * Number of blocks(CEIL(N-K/NB-K)),
114 *> The blocked upper triangular block reflectors stored in compact form
115 *> as a sequence of upper triangular blocks. See below
116 *> for further details.
117 *> \endverbatim
118 *>
119 *> \param[in] LDT
120 *> \verbatim
121 *> LDT is INTEGER
122 *> The leading dimension of the array T. LDT >= MB.
123 *> \endverbatim
124 *>
125 *> \param[in,out] C
126 *> \verbatim
127 *> C is COMPLEX*16 array, dimension (LDC,N)
128 *> On entry, the M-by-N matrix C.
129 *> On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
130 *> \endverbatim
131 *>
132 *> \param[in] LDC
133 *> \verbatim
134 *> LDC is INTEGER
135 *> The leading dimension of the array C. LDC >= max(1,M).
136 *> \endverbatim
137 *>
138 *> \param[out] WORK
139 *> \verbatim
140 *> (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK))
141 *> \endverbatim
142 *>
143 *> \param[in] LWORK
144 *> \verbatim
145 *> LWORK is INTEGER
146 *> The dimension of the array WORK.
147 *> If SIDE = 'L', LWORK >= max(1,NB) * MB;
148 *> if SIDE = 'R', LWORK >= max(1,M) * MB.
149 *> If LWORK = -1, then a workspace query is assumed; the routine
150 *> only calculates the optimal size of the WORK array, returns
151 *> this value as the first entry of the WORK array, and no error
152 *> message related to LWORK is issued by XERBLA.
153 *> \endverbatim
154 *>
155 *> \param[out] INFO
156 *> \verbatim
157 *> INFO is INTEGER
158 *> = 0: successful exit
159 *> < 0: if INFO = -i, the i-th argument had an illegal value
160 *> \endverbatim
161 *
162 * Authors:
163 * ========
164 *
165 *> \author Univ. of Tennessee
166 *> \author Univ. of California Berkeley
167 *> \author Univ. of Colorado Denver
168 *> \author NAG Ltd.
169 *
170 *> \par Further Details:
171 * =====================
172 *>
173 *> \verbatim
174 *> Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations,
175 *> representing Q as a product of other orthogonal matrices
176 *> Q = Q(1) * Q(2) * . . . * Q(k)
177 *> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
178 *> Q(1) zeros out the upper diagonal entries of rows 1:NB of A
179 *> Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
180 *> Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
181 *> . . .
182 *>
183 *> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
184 *> stored under the diagonal of rows 1:MB of A, and by upper triangular
185 *> block reflectors, stored in array T(1:LDT,1:N).
186 *> For more information see Further Details in GELQT.
187 *>
188 *> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
189 *> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
190 *> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
191 *> The last Q(k) may use fewer rows.
192 *> For more information see Further Details in TPQRT.
193 *>
194 *> For more details of the overall algorithm, see the description of
195 *> Sequential TSQR in Section 2.2 of [1].
196 *>
197 *> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
198 *> J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
199 *> SIAM J. Sci. Comput, vol. 34, no. 1, 2012
200 *> \endverbatim
201 *>
202 * =====================================================================
203  SUBROUTINE zlamswlq( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
204  $ LDT, C, LDC, WORK, LWORK, INFO )
205 *
206 * -- LAPACK computational routine (version 3.7.1) --
207 * -- LAPACK is a software package provided by Univ. of Tennessee, --
208 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
209 * June 2017
210 *
211 * .. Scalar Arguments ..
212  CHARACTER SIDE, TRANS
213  INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
214 * ..
215 * .. Array Arguments ..
216  COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ),
217  $ t( ldt, * )
218 * ..
219 *
220 * =====================================================================
221 *
222 * ..
223 * .. Local Scalars ..
224  LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
225  INTEGER I, II, KK, LW, CTR
226 * ..
227 * .. External Functions ..
228  LOGICAL LSAME
229  EXTERNAL lsame
230 * .. External Subroutines ..
231  EXTERNAL ztpmlqt, zgemlqt, xerbla
232 * ..
233 * .. Executable Statements ..
234 *
235 * Test the input arguments
236 *
237  lquery = lwork.LT.0
238  notran = lsame( trans, 'N' )
239  tran = lsame( trans, 'C' )
240  left = lsame( side, 'L' )
241  right = lsame( side, 'R' )
242  IF (left) THEN
243  lw = n * mb
244  ELSE
245  lw = m * mb
246  END IF
247 *
248  info = 0
249  IF( .NOT.left .AND. .NOT.right ) THEN
250  info = -1
251  ELSE IF( .NOT.tran .AND. .NOT.notran ) THEN
252  info = -2
253  ELSE IF( m.LT.0 ) THEN
254  info = -3
255  ELSE IF( n.LT.0 ) THEN
256  info = -4
257  ELSE IF( k.LT.0 ) THEN
258  info = -5
259  ELSE IF( lda.LT.max( 1, k ) ) THEN
260  info = -9
261  ELSE IF( ldt.LT.max( 1, mb) ) THEN
262  info = -11
263  ELSE IF( ldc.LT.max( 1, m ) ) THEN
264  info = -13
265  ELSE IF(( lwork.LT.max(1,lw)).AND.(.NOT.lquery)) THEN
266  info = -15
267  END IF
268 *
269  IF( info.NE.0 ) THEN
270  CALL xerbla( 'ZLAMSWLQ', -info )
271  work(1) = lw
272  RETURN
273  ELSE IF (lquery) THEN
274  work(1) = lw
275  RETURN
276  END IF
277 *
278 * Quick return if possible
279 *
280  IF( min(m,n,k).EQ.0 ) THEN
281  RETURN
282  END IF
283 *
284  IF((nb.LE.k).OR.(nb.GE.max(m,n,k))) THEN
285  CALL zgemlqt( side, trans, m, n, k, mb, a, lda,
286  $ t, ldt, c, ldc, work, info)
287  RETURN
288  END IF
289 *
290  IF(left.AND.tran) THEN
291 *
292 * Multiply Q to the last block of C
293 *
294  kk = mod((m-k),(nb-k))
295  ctr = (m-k)/(nb-k)
296 *
297  IF (kk.GT.0) THEN
298  ii=m-kk+1
299  CALL ztpmlqt('L','C',kk , n, k, 0, mb, a(1,ii), 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-(nb-k),nb+1,-(nb-k)
307 *
308 * Multiply Q to the current block of C (1:M,I:I+NB)
309 *
310  ctr = ctr - 1
311  CALL ztpmlqt('L','C',nb-k , n, k, 0,mb, a(1,i), 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:M,1:NB)
318 *
319  CALL zgemlqt('L','C',nb , n, k, mb, a(1,1), lda, t
320  $ ,ldt ,c(1,1), ldc, work, info )
321 *
322  ELSE IF (left.AND.notran) THEN
323 *
324 * Multiply Q to the first block of C
325 *
326  kk = mod((m-k),(nb-k))
327  ii=m-kk+1
328  ctr = 1
329  CALL zgemlqt('L','N',nb , n, k, mb, a(1,1), lda, t
330  $ ,ldt ,c(1,1), ldc, work, info )
331 *
332  DO i=nb+1,ii-nb+k,(nb-k)
333 *
334 * Multiply Q to the current block of C (I:I+NB,1:N)
335 *
336  CALL ztpmlqt('L','N',nb-k , n, k, 0,mb, a(1,i), 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 ztpmlqt('L','N',kk , n, k, 0, mb, a(1,ii), 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.notran) THEN
353 *
354 * Multiply Q to the last block of C
355 *
356  kk = mod((n-k),(nb-k))
357  ctr = (n-k)/(nb-k)
358  IF (kk.GT.0) THEN
359  ii=n-kk+1
360  CALL ztpmlqt('R','N',m , kk, k, 0, mb, a(1, ii), 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-(nb-k),nb+1,-(nb-k)
368 *
369 * Multiply Q to the current block of C (1:M,I:I+MB)
370 *
371  ctr = ctr - 1
372  CALL ztpmlqt('R','N', m, nb-k, k, 0, mb, a(1, i), 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 zgemlqt('R','N',m , nb, k, mb, a(1,1), lda, t
381  $ ,ldt ,c(1,1), ldc, work, info )
382 *
383  ELSE IF (right.AND.tran) THEN
384 *
385 * Multiply Q to the first block of C
386 *
387  kk = mod((n-k),(nb-k))
388  ii=n-kk+1
389  CALL zgemlqt('R','C',m , nb, k, mb, a(1,1), lda, t
390  $ ,ldt ,c(1,1), ldc, work, info )
391  ctr = 1
392 *
393  DO i=nb+1,ii-nb+k,(nb-k)
394 *
395 * Multiply Q to the current block of C (1:M,I:I+MB)
396 *
397  CALL ztpmlqt('R','C',m , nb-k, k, 0,mb, a(1,i), 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 ztpmlqt('R','C',m , kk, k, 0,mb, a(1,ii), 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 ZLAMSWLQ
419 *
420  END
ztpmlqt
subroutine ztpmlqt(SIDE, TRANS, M, N, K, L, MB, V, LDV, T, LDT, A, LDA, B, LDB, WORK, INFO)
ZTPMLQT
Definition: ztpmlqt.f:218
zlamswlq
subroutine zlamswlq(SIDE, TRANS, M, N, K, MB, NB, A, LDA, T, LDT, C, LDC, WORK, LWORK, INFO)
ZLAMSWLQ
Definition: zlamswlq.f:205
xerbla
subroutine xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:62
zgemlqt
subroutine zgemlqt(SIDE, TRANS, M, N, K, MB, V, LDV, T, LDT, C, LDC, WORK, INFO)
ZGEMLQT
Definition: zgemlqt.f:170