LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
clamswlq.f
Go to the documentation of this file.
1*> \brief \b CLAMSWLQ
2*
3* Definition:
4* ===========
5*
6* SUBROUTINE CLAMSWLQ( 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 A( LDA, * ), WORK( * ), C(LDC, * ),
16* $ T( LDT, * )
17*> \par Purpose:
18* =============
19*>
20*> \verbatim
21*>
22*> CLAMSWLQ 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 = 'T': 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 (CLASWLQ)
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 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*> CLASWLQ 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 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 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 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*> If MIN(M,N,K) = 0, LWORK >= 1.
139*> If SIDE = 'L', LWORK >= max(1,NB*MB).
140*> If SIDE = 'R', LWORK >= max(1,M*MB).
141*>
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 unitary transformations,
168*> representing Q as a product of other unitary 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 clamswlq( 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 COMPLEX 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 REAL SROUNDUP_LWORK
224 EXTERNAL lsame, sroundup_lwork
225* ..
226* .. External Subroutines ..
227 EXTERNAL ctpmlqt, cgemlqt, xerbla
228* ..
229* .. Executable Statements ..
230*
231* Test the input arguments
232*
233 info = 0
234 lquery = ( lwork.EQ.-1 )
235 notran = lsame( trans, 'N' )
236 tran = lsame( trans, 'C' )
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 IF( .NOT.left .AND. .NOT.right ) THEN
253 info = -1
254 ELSE IF( .NOT.tran .AND. .NOT.notran ) THEN
255 info = -2
256 ELSE IF( k.LT.0 ) THEN
257 info = -5
258 ELSE IF( m.LT.k ) THEN
259 info = -3
260 ELSE IF( n.LT.0 ) THEN
261 info = -4
262 ELSE IF( k.LT.mb .OR. mb.LT.1 ) THEN
263 info = -6
264 ELSE IF( lda.LT.max( 1, k ) ) THEN
265 info = -9
266 ELSE IF( ldt.LT.max( 1, mb ) ) THEN
267 info = -11
268 ELSE IF( ldc.LT.max( 1, m ) ) THEN
269 info = -13
270 ELSE IF( lwork.LT.lwmin .AND. (.NOT.lquery) ) THEN
271 info = -15
272 END IF
273*
274 IF( info.EQ.0 ) THEN
275 work( 1 ) = sroundup_lwork( lwmin )
276 END IF
277 IF( info.NE.0 ) THEN
278 CALL xerbla( 'CLAMSWLQ', -info )
279 RETURN
280 ELSE IF( lquery ) THEN
281 RETURN
282 END IF
283*
284* Quick return if possible
285*
286 IF( minmnk.EQ.0 ) THEN
287 RETURN
288 END IF
289*
290 IF((nb.LE.k).OR.(nb.GE.max(m,n,k))) THEN
291 CALL cgemlqt( side, trans, m, n, k, mb, a, lda,
292 $ t, ldt, c, ldc, work, info )
293 RETURN
294 END IF
295*
296 IF(left.AND.tran) THEN
297*
298* Multiply Q to the last block of C
299*
300 kk = mod((m-k),(nb-k))
301 ctr = (m-k)/(nb-k)
302 IF (kk.GT.0) THEN
303 ii=m-kk+1
304 CALL ctpmlqt('L','C',kk , n, k, 0, mb, a(1,ii), lda,
305 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
306 $ c(ii,1), ldc, work, info )
307 ELSE
308 ii=m+1
309 END IF
310*
311 DO i=ii-(nb-k),nb+1,-(nb-k)
312*
313* Multiply Q to the current block of C (1:M,I:I+NB)
314*
315 ctr = ctr - 1
316 CALL ctpmlqt('L','C',nb-k , n, k, 0,mb, a(1,i), lda,
317 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
318 $ c(i,1), ldc, work, info )
319
320 END DO
321*
322* Multiply Q to the first block of C (1:M,1:NB)
323*
324 CALL cgemlqt('L','C',nb , n, k, mb, a(1,1), lda, t
325 $ ,ldt ,c(1,1), ldc, work, info )
326*
327 ELSE IF (left.AND.notran) THEN
328*
329* Multiply Q to the first block of C
330*
331 kk = mod((m-k),(nb-k))
332 ii = m-kk+1
333 ctr = 1
334 CALL cgemlqt('L','N',nb , n, k, mb, a(1,1), lda, t
335 $ ,ldt ,c(1,1), ldc, work, info )
336*
337 DO i=nb+1,ii-nb+k,(nb-k)
338*
339* Multiply Q to the current block of C (I:I+NB,1:N)
340*
341 CALL ctpmlqt('L','N',nb-k , n, k, 0,mb, a(1,i), lda,
342 $ t(1, ctr *k+1), ldt, c(1,1), ldc,
343 $ c(i,1), ldc, work, info )
344 ctr = ctr + 1
345*
346 END DO
347 IF(ii.LE.m) THEN
348*
349* Multiply Q to the last block of C
350*
351 CALL ctpmlqt('L','N',kk , n, k, 0, mb, a(1,ii), lda,
352 $ t(1, ctr*k+1), ldt, c(1,1), ldc,
353 $ c(ii,1), ldc, work, info )
354*
355 END IF
356*
357 ELSE IF(right.AND.notran) THEN
358*
359* Multiply Q to the last block of C
360*
361 kk = mod((n-k),(nb-k))
362 ctr = (n-k)/(nb-k)
363 IF (kk.GT.0) THEN
364 ii=n-kk+1
365 CALL ctpmlqt('R','N',m , kk, k, 0, mb, a(1, ii), lda,
366 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
367 $ c(1,ii), ldc, work, info )
368 ELSE
369 ii=n+1
370 END IF
371*
372 DO i=ii-(nb-k),nb+1,-(nb-k)
373*
374* Multiply Q to the current block of C (1:M,I:I+MB)
375*
376 ctr = ctr - 1
377 CALL ctpmlqt('R','N', m, nb-k, k, 0, mb, a(1, i), lda,
378 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
379 $ c(1,i), ldc, work, info )
380 END DO
381*
382* Multiply Q to the first block of C (1:M,1:MB)
383*
384 CALL cgemlqt('R','N',m , nb, k, mb, a(1,1), lda, t
385 $ ,ldt ,c(1,1), ldc, work, info )
386*
387 ELSE IF (right.AND.tran) THEN
388*
389* Multiply Q to the first block of C
390*
391 kk = mod((n-k),(nb-k))
392 ii=n-kk+1
393 ctr = 1
394 CALL cgemlqt('R','C',m , nb, k, mb, a(1,1), lda, t
395 $ ,ldt ,c(1,1), ldc, work, info )
396*
397 DO i=nb+1,ii-nb+k,(nb-k)
398*
399* Multiply Q to the current block of C (1:M,I:I+MB)
400*
401 CALL ctpmlqt('R','C',m , nb-k, k, 0,mb, a(1,i), lda,
402 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
403 $ c(1,i), ldc, work, info )
404 ctr = ctr + 1
405*
406 END DO
407 IF(ii.LE.n) THEN
408*
409* Multiply Q to the last block of C
410*
411 CALL ctpmlqt('R','C',m , kk, k, 0,mb, a(1,ii), lda,
412 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
413 $ c(1,ii), ldc, work, info )
414*
415 END IF
416*
417 END IF
418*
419 work( 1 ) = sroundup_lwork( lwmin )
420 RETURN
421*
422* End of CLAMSWLQ
423*
424 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
CGEMLQT
Definition cgemlqt.f:153
subroutine clamswlq(side, trans, m, n, k, mb, nb, a, lda, t, ldt, c, ldc, work, lwork, info)
CLAMSWLQ
Definition clamswlq.f:200
subroutine ctpmlqt(side, trans, m, n, k, l, mb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
CTPMLQT
Definition ctpmlqt.f:200