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

◆ dlamtsqr()

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

DLAMTSQR

Purpose:
!>
!>      DLAMTSQR 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 (DLATSQR)
!> 
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 DLATSQR)
!> 
[in]NB
!>          NB is INTEGER
!>          The column block size to be used in the blocked QR.
!>          N >= NB >= 1.
!> 
[in]A
!>          A is DOUBLE PRECISION 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 DLATSQR 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 DOUBLE PRECISION 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 DOUBLE PRECISION 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) DOUBLE PRECISION 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 dlamtsqr.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 DOUBLE PRECISION 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* .. External Subroutines ..
226 EXTERNAL dgemqrt, dtpmqrt, xerbla
227* ..
228* .. Executable Statements ..
229*
230* Test the input arguments
231*
232 info = 0
233 lquery = ( lwork.EQ.-1 )
234 notran = lsame( trans, 'N' )
235 tran = lsame( trans, 'T' )
236 left = lsame( side, 'L' )
237 right = lsame( side, 'R' )
238 IF( left ) THEN
239 lw = n * nb
240 q = m
241 ELSE
242 lw = mb * nb
243 q = n
244 END IF
245*
246 minmnk = min( m, n, k )
247 IF( minmnk.EQ.0 ) THEN
248 lwmin = 1
249 ELSE
250 lwmin = max( 1, lw )
251 END IF
252*
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( m.LT.k ) THEN
258 info = -3
259 ELSE IF( n.LT.0 ) THEN
260 info = -4
261 ELSE IF( k.LT.0 ) THEN
262 info = -5
263 ELSE IF( k.LT.nb .OR. nb.LT.1 ) THEN
264 info = -7
265 ELSE IF( lda.LT.max( 1, q ) ) THEN
266 info = -9
267 ELSE IF( ldt.LT.max( 1, nb ) ) 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 ) = lwmin
277 END IF
278*
279 IF( info.NE.0 ) THEN
280 CALL xerbla( 'DLAMTSQR', -info )
281 RETURN
282 ELSE IF( lquery ) THEN
283 RETURN
284 END IF
285*
286* Quick return if possible
287*
288 IF( minmnk.EQ.0 ) THEN
289 RETURN
290 END IF
291*
292* Determine the block size if it is tall skinny or short and wide
293*
294 IF((mb.LE.k).OR.(mb.GE.max(m,n,k))) THEN
295 CALL dgemqrt( side, trans, m, n, k, nb, a, lda,
296 $ t, ldt, c, ldc, work, info )
297 RETURN
298 END IF
299*
300 IF(left.AND.notran) THEN
301*
302* Multiply Q to the last block of C
303*
304 kk = mod((m-k),(mb-k))
305 ctr = (m-k)/(mb-k)
306 IF (kk.GT.0) THEN
307 ii=m-kk+1
308 CALL dtpmqrt('L','N',kk , n, k, 0, nb, a(ii,1), lda,
309 $ t(1,ctr*k+1),ldt , c(1,1), ldc,
310 $ c(ii,1), ldc, work, info )
311 ELSE
312 ii=m+1
313 END IF
314*
315 DO i=ii-(mb-k),mb+1,-(mb-k)
316*
317* Multiply Q to the current block of C (I:I+MB,1:N)
318*
319 ctr = ctr - 1
320 CALL dtpmqrt('L','N',mb-k , n, k, 0,nb, a(i,1), lda,
321 $ t(1,ctr*k+1),ldt, c(1,1), ldc,
322 $ c(i,1), ldc, work, info )
323*
324 END DO
325*
326* Multiply Q to the first block of C (1:MB,1:N)
327*
328 CALL dgemqrt('L','N',mb , n, k, nb, a(1,1), lda, t
329 $ ,ldt ,c(1,1), ldc, work, info )
330*
331 ELSE IF (left.AND.tran) THEN
332*
333* Multiply Q to the first block of C
334*
335 kk = mod((m-k),(mb-k))
336 ii=m-kk+1
337 ctr = 1
338 CALL dgemqrt('L','T',mb , n, k, nb, a(1,1), lda, t
339 $ ,ldt ,c(1,1), ldc, work, info )
340*
341 DO i=mb+1,ii-mb+k,(mb-k)
342*
343* Multiply Q to the current block of C (I:I+MB,1:N)
344*
345 CALL dtpmqrt('L','T',mb-k , n, k, 0,nb, a(i,1), lda,
346 $ t(1,ctr * k + 1),ldt, c(1,1), ldc,
347 $ c(i,1), ldc, work, info )
348 ctr = ctr + 1
349*
350 END DO
351 IF(ii.LE.m) THEN
352*
353* Multiply Q to the last block of C
354*
355 CALL dtpmqrt('L','T',kk , n, k, 0,nb, a(ii,1), lda,
356 $ t(1,ctr * k + 1), ldt, c(1,1), ldc,
357 $ c(ii,1), ldc, work, info )
358*
359 END IF
360*
361 ELSE IF(right.AND.tran) THEN
362*
363* Multiply Q to the last block of C
364*
365 kk = mod((n-k),(mb-k))
366 ctr = (n-k)/(mb-k)
367 IF (kk.GT.0) THEN
368 ii=n-kk+1
369 CALL dtpmqrt('R','T',m , kk, k, 0, nb, a(ii,1), lda,
370 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
371 $ c(1,ii), ldc, work, info )
372 ELSE
373 ii=n+1
374 END IF
375*
376 DO i=ii-(mb-k),mb+1,-(mb-k)
377*
378* Multiply Q to the current block of C (1:M,I:I+MB)
379*
380 ctr = ctr - 1
381 CALL dtpmqrt('R','T',m , mb-k, k, 0,nb, a(i,1), lda,
382 $ t(1,ctr*k+1), ldt, c(1,1), ldc,
383 $ c(1,i), ldc, work, info )
384*
385 END DO
386*
387* Multiply Q to the first block of C (1:M,1:MB)
388*
389 CALL dgemqrt('R','T',m , mb, k, nb, a(1,1), lda, t
390 $ ,ldt ,c(1,1), ldc, work, info )
391*
392 ELSE IF (right.AND.notran) THEN
393*
394* Multiply Q to the first block of C
395*
396 kk = mod((n-k),(mb-k))
397 ii=n-kk+1
398 ctr = 1
399 CALL dgemqrt('R','N', m, mb , k, nb, a(1,1), lda, t
400 $ ,ldt ,c(1,1), ldc, work, info )
401*
402 DO i=mb+1,ii-mb+k,(mb-k)
403*
404* Multiply Q to the current block of C (1:M,I:I+MB)
405*
406 CALL dtpmqrt('R','N', m, mb-k, k, 0,nb, a(i,1), lda,
407 $ t(1, ctr * k + 1),ldt, c(1,1), ldc,
408 $ c(1,i), ldc, work, info )
409 ctr = ctr + 1
410*
411 END DO
412 IF(ii.LE.n) THEN
413*
414* Multiply Q to the last block of C
415*
416 CALL dtpmqrt('R','N', m, kk , k, 0,nb, a(ii,1), lda,
417 $ t(1, ctr * k + 1),ldt, c(1,1), ldc,
418 $ c(1,ii), ldc, work, info )
419*
420 END IF
421*
422 END IF
423*
424 work( 1 ) = lwmin
425*
426 RETURN
427*
428* End of DLAMTSQR
429*
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine dgemqrt(side, trans, m, n, k, nb, v, ldv, t, ldt, c, ldc, work, info)
DGEMQRT
Definition dgemqrt.f:166
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine dtpmqrt(side, trans, m, n, k, l, nb, v, ldv, t, ldt, a, lda, b, ldb, work, info)
DTPMQRT
Definition dtpmqrt.f:215
Here is the call graph for this function:
Here is the caller graph for this function: