LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ slamswlq()

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

SLAMSWLQ

Purpose:
!>
!>    SLAMSWLQ overwrites the general real M-by-N matrix C with
!>
!>
!>                    SIDE = 'L'     SIDE = 'R'
!>    TRANS = 'N':      Q * C          C * Q
!>    TRANS = 'T':      Q**T * C       C * Q**T
!>    where Q is a real orthogonal matrix defined as the product of blocked
!>    elementary reflectors computed by short wide LQ
!>    factorization (SLASWLQ)
!> 
Parameters
[in]SIDE
!>          SIDE is CHARACTER*1
!>          = 'L': apply Q or Q**T from the Left;
!>          = 'R': apply Q or Q**T from the Right.
!> 
[in]TRANS
!>          TRANS is CHARACTER*1
!>          = 'N':  No transpose, apply Q;
!>          = 'T':  Transpose, apply Q**T.
!> 
[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 REAL 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
!>          SLASWLQ 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 REAL 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 REAL array, dimension (LDC,N)
!>          On entry, the M-by-N matrix C.
!>          On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
!> 
[in]LDC
!>          LDC is INTEGER
!>          The leading dimension of the array C. LDC >= max(1,M).
!> 
[out]WORK
!>          (workspace) REAL array, dimension (MAX(1,LWORK))
!>          On exit, if INFO = 0, WORK(1) returns the minimal LWORK.
!> 
[in]LWORK
!>          LWORK is INTEGER
!>          The dimension of the array WORK.
!>
!>          If MIN(M,N,K) = 0, LWORK >= 1.
!>          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 minimal 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 orthogonal transformations,
!> representing Q as a product of other orthogonal 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 198 of file slamswlq.f.

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