OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
clamswlq.f File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine clamswlq (side, trans, m, n, k, mb, nb, a, lda, t, ldt, c, ldc, work, lwork, info)
 CLAMSWLQ

Function/Subroutine Documentation

◆ clamswlq()

subroutine clamswlq ( character side,
character trans,
integer m,
integer n,
integer k,
integer mb,
integer nb,
complex, dimension( lda, * ) a,
integer lda,
complex, dimension( ldt, * ) t,
integer ldt,
complex, dimension(ldc, * ) c,
integer ldc,
complex, dimension( * ) work,
integer lwork,
integer info )

CLAMSWLQ

Purpose:
!>
!>    CLAMSWLQ overwrites the general complex M-by-N matrix C with
!>
!>
!>                    SIDE = 'L'     SIDE = 'R'
!>    TRANS = 'N':      Q * C          C * Q
!>    TRANS = 'T':      Q**H * C       C * Q**H
!>    where Q is a complex unitary matrix defined as the product of blocked
!>    elementary reflectors computed by short wide LQ
!>    factorization (CLASWLQ)
!> 
Parameters
[in]SIDE
!>          SIDE is CHARACTER*1
!>          = 'L': apply Q or Q**H from the Left;
!>          = 'R': apply Q or Q**H from the Right.
!> 
[in]TRANS
!>          TRANS is CHARACTER*1
!>          = 'N':  No transpose, apply Q;
!>          = 'C':  Conjugate transpose, apply Q**H.
!> 
[in]M
!>          M is INTEGER
!>          The number of rows of the matrix C.  M >=0.
!> 
[in]N
!>          N is INTEGER
!>          The number of columns of the matrix C. N >= 0.
!> 
[in]K
!>          K is INTEGER
!>          The number of elementary reflectors whose product defines
!>          the matrix Q.
!>          M >= K >= 0;
!>
!> 
[in]MB
!>          MB is INTEGER
!>          The row block size to be used in the blocked LQ.
!>          M >= MB >= 1
!> 
[in]NB
!>          NB is INTEGER
!>          The column block size to be used in the blocked LQ.
!>          NB > M.
!> 
[in]A
!>          A is COMPLEX array, dimension
!>                               (LDA,M) if SIDE = 'L',
!>                               (LDA,N) if SIDE = 'R'
!>          The i-th row must contain the vector which defines the blocked
!>          elementary reflector H(i), for i = 1,2,...,k, as returned by
!>          CLASWLQ in the first k rows of its array argument A.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A. LDA => max(1,K).
!> 
[in]T
!>          T is COMPLEX array, dimension
!>          ( M * Number of blocks(CEIL(N-K/NB-K)),
!>          The blocked upper triangular block reflectors stored in compact form
!>          as a sequence of upper triangular blocks.  See below
!>          for further details.
!> 
[in]LDT
!>          LDT is INTEGER
!>          The leading dimension of the array T.  LDT >= MB.
!> 
[in,out]C
!>          C is COMPLEX array, dimension (LDC,N)
!>          On entry, the M-by-N matrix C.
!>          On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
!> 
[in]LDC
!>          LDC is INTEGER
!>          The leading dimension of the array C. LDC >= max(1,M).
!> 
[out]WORK
!>         (workspace) COMPLEX array, dimension (MAX(1,LWORK))
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>          If SIDE = 'L', LWORK >= max(1,NB) * MB;
!>          if SIDE = 'R', LWORK >= max(1,M) * MB.
!>          If LWORK = -1, then a workspace query is assumed; the routine
!>          only calculates the optimal size of the WORK array, returns
!>          this value as the first entry of the WORK array, and no error
!>          message related to LWORK is issued by XERBLA.
!> 
[out]INFO
!>          INFO is INTEGER
!>          = 0:  successful exit
!>          < 0:  if INFO = -i, the i-th argument had an illegal value
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
!> Short-Wide LQ (SWLQ) performs LQ by a sequence of unitary transformations,
!> representing Q as a product of other unitary matrices
!>   Q = Q(1) * Q(2) * . . . * Q(k)
!> where each Q(i) zeros out upper diagonal entries of a block of NB rows of A:
!>   Q(1) zeros out the upper diagonal entries of rows 1:NB of A
!>   Q(2) zeros out the bottom MB-N rows of rows [1:M,NB+1:2*NB-M] of A
!>   Q(3) zeros out the bottom MB-N rows of rows [1:M,2*NB-M+1:3*NB-2*M] of A
!>   . . .
!>
!> Q(1) is computed by GELQT, which represents Q(1) by Householder vectors
!> stored under the diagonal of rows 1:MB of A, and by upper triangular
!> block reflectors, stored in array T(1:LDT,1:N).
!> For more information see Further Details in GELQT.
!>
!> Q(i) for i>1 is computed by TPLQT, which represents Q(i) by Householder vectors
!> stored in columns [(i-1)*(NB-M)+M+1:i*(NB-M)+M] of A, and by upper triangular
!> block reflectors, stored in array T(1:LDT,(i-1)*M+1:i*M).
!> The last Q(k) may use fewer rows.
!> For more information see Further Details in TPLQT.
!>
!> For more details of the overall algorithm, see the description of
!> Sequential TSQR in Section 2.2 of [1].
!>
!> [1] “Communication-Optimal Parallel and Sequential QR and LU Factorizations,”
!>     J. Demmel, L. Grigori, M. Hoemmen, J. Langou,
!>     SIAM J. Sci. Comput, vol. 34, no. 1, 2012
!> 

Definition at line 193 of file clamswlq.f.

195*
196* -- LAPACK computational routine --
197* -- LAPACK is a software package provided by Univ. of Tennessee, --
198* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
199*
200* .. Scalar Arguments ..
201 CHARACTER SIDE, TRANS
202 INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
203* ..
204* .. Array Arguments ..
205 COMPLEX A( LDA, * ), WORK( * ), C(LDC, * ),
206 $ T( LDT, * )
207* ..
208*
209* =====================================================================
210*
211* ..
212* .. Local Scalars ..
213 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
214 INTEGER I, II, KK, LW, CTR
215* ..
216* .. External Functions ..
217 LOGICAL LSAME
218 EXTERNAL lsame
219* .. External Subroutines ..
220 EXTERNAL ctpmlqt, cgemlqt, xerbla
221* ..
222* .. Executable Statements ..
223*
224* Test the input arguments
225*
226 lquery = lwork.LT.0
227 notran = lsame( trans, 'N' )
228 tran = lsame( trans, 'C' )
229 left = lsame( side, 'L' )
230 right = lsame( side, 'R' )
231 IF (left) THEN
232 lw = n * mb
233 ELSE
234 lw = m * mb
235 END IF
236*
237 info = 0
238 IF( .NOT.left .AND. .NOT.right ) THEN
239 info = -1
240 ELSE IF( .NOT.tran .AND. .NOT.notran ) THEN
241 info = -2
242 ELSE IF( k.LT.0 ) THEN
243 info = -5
244 ELSE IF( m.LT.k ) THEN
245 info = -3
246 ELSE IF( n.LT.0 ) THEN
247 info = -4
248 ELSE IF( k.LT.mb .OR. mb.LT.1) THEN
249 info = -6
250 ELSE IF( lda.LT.max( 1, k ) ) THEN
251 info = -9
252 ELSE IF( ldt.LT.max( 1, mb) ) THEN
253 info = -11
254 ELSE IF( ldc.LT.max( 1, m ) ) THEN
255 info = -13
256 ELSE IF(( lwork.LT.max(1,lw)).AND.(.NOT.lquery)) THEN
257 info = -15
258 END IF
259*
260 IF( info.NE.0 ) THEN
261 CALL xerbla( 'CLAMSWLQ', -info )
262 work(1) = lw
263 RETURN
264 ELSE IF (lquery) THEN
265 work(1) = lw
266 RETURN
267 END IF
268*
269* Quick return if possible
270*
271 IF( min(m,n,k).EQ.0 ) THEN
272 RETURN
273 END IF
274*
275 IF((nb.LE.k).OR.(nb.GE.max(m,n,k))) THEN
276 CALL cgemlqt( side, trans, m, n, k, mb, a, lda,
277 $ t, ldt, c, ldc, work, info)
278 RETURN
279 END IF
280*
281 IF(left.AND.tran) THEN
282*
283* Multiply Q to the last block of C
284*
285 kk = mod((m-k),(nb-k))
286 ctr = (m-k)/(nb-k)
287 IF (kk.GT.0) THEN
288 ii=m-kk+1
289 CALL ctpmlqt('L','C',kk , n, k, 0, mb, a(1,ii), lda,
290 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
291 $ c(ii,1), ldc, work, info )
292 ELSE
293 ii=m+1
294 END IF
295*
296 DO i=ii-(nb-k),nb+1,-(nb-k)
297*
298* Multiply Q to the current block of C (1:M,I:I+NB)
299*
300 ctr = ctr - 1
301 CALL ctpmlqt('L','C',nb-k , n, k, 0,mb, a(1,i), lda,
302 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
303 $ c(i,1), ldc, work, info )
304
305 END DO
306*
307* Multiply Q to the first block of C (1:M,1:NB)
308*
309 CALL cgemlqt('L','C',nb , n, k, mb, a(1,1), lda, t
310 $ ,ldt ,c(1,1), ldc, work, info )
311*
312 ELSE IF (left.AND.notran) THEN
313*
314* Multiply Q to the first block of C
315*
316 kk = mod((m-k),(nb-k))
317 ii = m-kk+1
318 ctr = 1
319 CALL cgemlqt('L','N',nb , n, k, mb, a(1,1), lda, t
320 $ ,ldt ,c(1,1), ldc, work, info )
321*
322 DO i=nb+1,ii-nb+k,(nb-k)
323*
324* Multiply Q to the current block of C (I:I+NB,1:N)
325*
326 CALL ctpmlqt('L','N',nb-k , n, k, 0,mb, a(1,i), lda,
327 $ t(1, ctr *k+1), ldt, c(1,1), ldc,
328 $ c(i,1), ldc, work, info )
329 ctr = ctr + 1
330*
331 END DO
332 IF(ii.LE.m) THEN
333*
334* Multiply Q to the last block of C
335*
336 CALL ctpmlqt('L','N',kk , n, k, 0, mb, a(1,ii), lda,
337 $ t(1, ctr*k+1), ldt, c(1,1), ldc,
338 $ c(ii,1), ldc, work, info )
339*
340 END IF
341*
342 ELSE IF(right.AND.notran) THEN
343*
344* Multiply Q to the last block of C
345*
346 kk = mod((n-k),(nb-k))
347 ctr = (n-k)/(nb-k)
348 IF (kk.GT.0) THEN
349 ii=n-kk+1
350 CALL ctpmlqt('R','N',m , kk, k, 0, mb, a(1, ii), lda,
351 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
352 $ c(1,ii), ldc, work, info )
353 ELSE
354 ii=n+1
355 END IF
356*
357 DO i=ii-(nb-k),nb+1,-(nb-k)
358*
359* Multiply Q to the current block of C (1:M,I:I+MB)
360*
361 ctr = ctr - 1
362 CALL ctpmlqt('R','N', m, nb-k, k, 0, mb, a(1, i), lda,
363 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
364 $ c(1,i), ldc, work, info )
365 END DO
366*
367* Multiply Q to the first block of C (1:M,1:MB)
368*
369 CALL cgemlqt('R','N',m , nb, k, mb, a(1,1), lda, t
370 $ ,ldt ,c(1,1), ldc, work, info )
371*
372 ELSE IF (right.AND.tran) THEN
373*
374* Multiply Q to the first block of C
375*
376 kk = mod((n-k),(nb-k))
377 ii=n-kk+1
378 ctr = 1
379 CALL cgemlqt('R','C',m , nb, k, mb, a(1,1), lda, t
380 $ ,ldt ,c(1,1), ldc, work, info )
381*
382 DO i=nb+1,ii-nb+k,(nb-k)
383*
384* Multiply Q to the current block of C (1:M,I:I+MB)
385*
386 CALL ctpmlqt('R','C',m , nb-k, k, 0,mb, a(1,i), lda,
387 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
388 $ c(1,i), ldc, work, info )
389 ctr = ctr + 1
390*
391 END DO
392 IF(ii.LE.n) THEN
393*
394* Multiply Q to the last block of C
395*
396 CALL ctpmlqt('R','C',m , kk, k, 0,mb, a(1,ii), lda,
397 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
398 $ c(1,ii), ldc, work, info )
399*
400 END IF
401*
402 END IF
403*
404 work(1) = lw
405 RETURN
406*
407* End of CLAMSWLQ
408*
subroutine xerbla(srname, info)
XERBLA
Definition xerbla.f:60
logical function lsame(ca, cb)
LSAME
Definition lsame.f:53
subroutine cgemlqt(side, trans, m, n, k, mb, v, ldv, t, ldt, c, ldc, work, info)
CGEMLQT
Definition cgemlqt.f:153
subroutine ctpmlqt(side, trans, m, n, k, l, mb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
CTPMLQT
Definition ctpmlqt.f:199
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21