5 * SUBROUTINE ZLAMSWLQ( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
6 * $ LDT, C, LDC, WORK, LWORK, INFO )
9 * .. Scalar Arguments ..
10 * CHARACTER SIDE, TRANS
11 * INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
13 * .. Array Arguments ..
14 * COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ),
21 *> ZLAMQRTS overwrites the general real M-by-N matrix C with
24 *> SIDE = 'L' SIDE = 'R'
25 *> TRANS = 'N': Q * C C * Q
26 *> TRANS = 'T': Q**T * C C * Q**T
27 *> where Q is a real orthogonal matrix defined as the product of blocked
28 *> elementary reflectors computed by short wide LQ
29 *> factorization (ZLASWLQ)
36 *> SIDE is CHARACTER*1
37 *> = 'L': apply Q or Q**T from the Left;
38 *> = 'R': apply Q or Q**T from the Right.
41 *> TRANS is CHARACTER*1
42 *> = 'N': No transpose, apply Q;
43 *> = 'T': Transpose, apply Q**T.
47 *> The number of rows of the matrix A. M >=0.
53 *> The number of columns of the matrix C. N >= M.
59 *> The number of elementary reflectors whose product defines
67 *> The row block size to be used in the blocked QR.
74 *> The column block size to be used in the blocked QR.
81 *> The block size to be used in the blocked QR.
88 *> A is COMPLEX*16 array, dimension (LDA,K)
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 *> DLASWLQ in the first k rows of its array argument A.
97 *> The leading dimension of the array A.
98 *> If SIDE = 'L', LDA >= max(1,M);
99 *> if SIDE = 'R', LDA >= max(1,N).
104 *> T is COMPLEX*16 array, dimension
105 *> ( M * Number of blocks(CEIL(N-K/NB-K)),
106 *> The blocked upper triangular block reflectors stored in compact form
107 *> as a sequence of upper triangular blocks. See below
108 *> for further details.
114 *> The leading dimension of the array T. LDT >= MB.
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**T*C or C*Q**T or C*Q.
123 *> The leading dimension of the array C. LDC >= max(1,M).
127 *> (workspace) COMPLEX*16 array, dimension (MAX(1,LWORK))
133 *> The dimension of the array WORK.
134 *> If SIDE = 'L', LWORK >= max(1,NB) * MB;
135 *> if SIDE = 'R', LWORK >= max(1,M) * MB.
136 *> If LWORK = -1, then a workspace query is assumed; the routine
137 *> only calculates the optimal size of the WORK array, returns
138 *> this value as the first entry of the WORK array, and no error
139 *> message related to LWORK is issued by XERBLA.
145 *> = 0: successful exit
146 *> < 0: if INFO = -i, the i-th argument had an illegal value
152 *> \author Univ. of Tennessee
153 *> \author Univ. of California Berkeley
154 *> \author Univ. of Colorado Denver
157 *> \par Further Details:
158 * =====================
161 *> Short-Wide LQ (SWLQ) performs LQ by a sequence of orthogonal transformations,
162 *> representing Q as a product of other orthogonal matrices
163 *> Q = Q(1) * Q(2) * . . . * Q(k)
164 *> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
165 *> Q(1) zeros out the upper diagonal entries of rows 1:NB of A
166 *> Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
167 *> Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
170 *> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
171 *> stored under the diagonal of rows 1:MB of A, and by upper triangular
172 *> block reflectors, stored in array T(1:LDT,1:N).
173 *> For more information see Further Details in GELQT.
175 *> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
176 *> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
177 *> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
178 *> The last Q(k) may use fewer rows.
179 *> For more information see Further Details in TPQRT.
181 *> For more details of the overall algorithm, see the description of
182 *> Sequential TSQR in Section 2.2 of [1].
184 *> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
185 *> J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
186 *> SIAM J. Sci. Comput, vol. 34, no. 1, 2012
189 * =====================================================================
190 SUBROUTINE ZLAMSWLQ( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
191 $ LDT, C, LDC, WORK, LWORK, INFO )
193 * -- LAPACK computational routine (version 3.5.0) --
194 * -- LAPACK is a software package provided by Univ. of Tennessee, --
195 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
198 * .. Scalar Arguments ..
199 CHARACTER SIDE, TRANS
200 INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC, LW
202 * .. Array Arguments ..
203 COMPLEX*16 A( LDA, * ), WORK( * ), C(LDC, * ),
207 * =====================================================================
210 * .. Local Scalars ..
211 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
212 INTEGER I, II, KK, CTR
214 * .. External Functions ..
217 * .. External Subroutines ..
218 EXTERNAL ZTPMLQT, ZGEMLQT, XERBLA
220 * .. Executable Statements ..
222 * Test the input arguments
225 NOTRAN = LSAME( TRANS, 'N' )
226 TRAN = LSAME( TRANS, 'C' )
227 LEFT = LSAME( SIDE, 'L' )
228 RIGHT = LSAME( SIDE, 'R' )
236 IF( .NOT.LEFT .AND. .NOT.RIGHT ) THEN
238 ELSE IF( .NOT.TRAN .AND. .NOT.NOTRAN ) THEN
240 ELSE IF( M.LT.0 ) THEN
242 ELSE IF( N.LT.0 ) THEN
244 ELSE IF( K.LT.0 ) THEN
246 ELSE IF( LDA.LT.MAX( 1, K ) ) THEN
248 ELSE IF( LDT.LT.MAX( 1, MB) ) THEN
250 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
252 ELSE IF(( LWORK.LT.MAX(1,LW)).AND.(.NOT.LQUERY)) THEN
257 CALL XERBLA( 'ZLAMSWLQ', -INFO )
260 ELSE IF (LQUERY) THEN
265 * Quick return if possible
267 IF( MIN(M,N,K).EQ.0 ) THEN
271 IF((NB.LE.K).OR.(NB.GE.MAX(M,N,K))) THEN
272 CALL ZGEMLQT( SIDE, TRANS, M, N, K, MB, A, LDA,
273 $ T, LDT, C, LDC, WORK, INFO)
277 IF(LEFT.AND.TRAN) THEN
279 * Multiply Q to the last block of C
281 KK = MOD((M-K),(NB-K))
286 CALL ZTPMLQT('L','C',KK , N, K, 0, MB, A(1,II), LDA,
287 $ T(1,CTR*K+1), LDT, C(1,1), LDC,
288 $ C(II,1), LDC, WORK, INFO )
293 DO I=II-(NB-K),NB+1,-(NB-K)
295 * Multiply Q to the current block of C (1:M,I:I+NB)
298 CALL ZTPMLQT('L','C',NB-K , N, K, 0,MB, A(1,I), LDA,
299 $ T(1,CTR*K+1),LDT, C(1,1), LDC,
300 $ C(I,1), LDC, WORK, INFO )
304 * Multiply Q to the first block of C (1:M,1:NB)
306 CALL ZGEMLQT('L','C',NB , N, K, MB, A(1,1), LDA, T
307 $ ,LDT ,C(1,1), LDC, WORK, INFO )
309 ELSE IF (LEFT.AND.NOTRAN) THEN
311 * Multiply Q to the first block of C
313 KK = MOD((M-K),(NB-K))
316 CALL ZGEMLQT('L','N',NB , N, K, MB, A(1,1), LDA, T
317 $ ,LDT ,C(1,1), LDC, WORK, INFO )
319 DO I=NB+1,II-NB+K,(NB-K)
321 * Multiply Q to the current block of C (I:I+NB,1:N)
323 CALL ZTPMLQT('L','N',NB-K , N, K, 0,MB, A(1,I), LDA,
324 $ T(1, CTR * K + 1), LDT, C(1,1), LDC,
325 $ C(I,1), LDC, WORK, INFO )
331 * Multiply Q to the last block of C
333 CALL ZTPMLQT('L','N',KK , N, K, 0, MB, A(1,II), LDA,
334 $ T(1, CTR * K + 1), LDT, C(1,1), LDC,
335 $ C(II,1), LDC, WORK, INFO )
339 ELSE IF(RIGHT.AND.NOTRAN) THEN
341 * Multiply Q to the last block of C
343 KK = MOD((N-K),(NB-K))
347 CALL ZTPMLQT('R','N',M , KK, K, 0, MB, A(1, II), LDA,
348 $ T(1, CTR * K + 1), LDT, C(1,1), LDC,
349 $ C(1,II), LDC, WORK, INFO )
354 DO I=II-(NB-K),NB+1,-(NB-K)
356 * Multiply Q to the current block of C (1:M,I:I+MB)
359 CALL ZTPMLQT('R','N', M, NB-K, K, 0, MB, A(1, I), LDA,
360 $ T(1, CTR * K + 1), LDT, C(1,1), LDC,
361 $ C(1,I), LDC, WORK, INFO )
365 * Multiply Q to the first block of C (1:M,1:MB)
367 CALL ZGEMLQT('R','N',M , NB, K, MB, A(1,1), LDA, T
368 $ ,LDT ,C(1,1), LDC, WORK, INFO )
370 ELSE IF (RIGHT.AND.TRAN) THEN
372 * Multiply Q to the first block of C
374 KK = MOD((N-K),(NB-K))
376 CALL ZGEMLQT('R','C',M , NB, K, MB, A(1,1), LDA, T
377 $ ,LDT ,C(1,1), LDC, WORK, INFO )
380 DO I=NB+1,II-NB+K,(NB-K)
382 * Multiply Q to the current block of C (1:M,I:I+MB)
384 CALL ZTPMLQT('R','C',M , NB-K, K, 0,MB, A(1,I), LDA,
385 $ T(1,CTR *K+1), LDT, C(1,1), LDC,
386 $ C(1,I), LDC, WORK, INFO )
392 * Multiply Q to the last block of C
394 CALL ZTPMLQT('R','C',M , KK, K, 0,MB, A(1,II), LDA,
395 $ T(1, CTR * K + 1),LDT, C(1,1), LDC,
396 $ C(1,II), LDC, WORK, INFO )