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

◆ slamtsqr()

subroutine slamtsqr ( 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 )

SLAMTSQR

Purpose:
!>
!>      SLAMTSQR 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 tall skinny
!>      QR factorization (SLATSQR)
!> 
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 A.  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 block size to be used in the blocked QR.
!>          MB > N. (must be the same as SLATSQR)
!> 
[in]NB
!>          NB is INTEGER
!>          The column block size to be used in the blocked QR.
!>          N >= NB >= 1.
!> 
[in]A
!>          A is REAL array, dimension (LDA,K)
!>          The i-th column must contain the vector which defines the
!>          blockedelementary reflector H(i), for i = 1,2,...,k, as
!>          returned by SLATSQR in the first k columns of
!>          its array argument A.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.
!>          If SIDE = 'L', LDA >= max(1,M);
!>          if SIDE = 'R', LDA >= max(1,N).
!> 
[in]T
!>          T is REAL array, dimension
!>          ( N * Number of blocks(CEIL(M-K/MB-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 >= NB.
!> 
[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,N*NB).
!>          If SIDE = 'R', LWORK >= max(1,MB*NB).
!>
!>          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:
!> Tall-Skinny QR (TSQR) performs QR 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 subdiagonal entries of a block of MB rows of A:
!>   Q(1) zeros out the subdiagonal entries of rows 1:MB of A
!>   Q(2) zeros out the bottom MB-N rows of rows [1:N,MB+1:2*MB-N] of A
!>   Q(3) zeros out the bottom MB-N rows of rows [1:N,2*MB-N+1:3*MB-2*N] of A
!>   . . .
!>
!> Q(1) is computed by GEQRT, 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 GEQRT.
!>
!> Q(i) for i>1 is computed by TPQRT, which represents Q(i) by Householder vectors
!> stored in rows [(i-1)*(MB-N)+N+1:i*(MB-N)+N] of A, and by upper triangular
!> block reflectors, stored in array T(1:LDT,(i-1)*N+1:i*N).
!> The last Q(k) may use fewer rows.
!> For more information see Further Details in TPQRT.
!>
!> 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 199 of file slamtsqr.f.

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