199 SUBROUTINE dlamtsqr( SIDE, TRANS, M, N, K, MB, NB, A, LDA, T,
200 $ LDT, C, LDC, WORK, LWORK, INFO )
207 CHARACTER SIDE, TRANS
208 INTEGER INFO, LDA, M, N, K, MB, NB, LDT, LWORK, LDC
211 DOUBLE PRECISION A( LDA, * ), WORK( * ), C( LDC, * ),
219 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
220 INTEGER I, II, KK, LW, CTR, Q, MINMNK, LWMIN
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' )
246 minmnk = min( m, n, k )
247 IF( minmnk.EQ.0 )
THEN
253 IF( .NOT.left .AND. .NOT.right )
THEN
255 ELSE IF( .NOT.tran .AND. .NOT.notran )
THEN
257 ELSE IF( m.LT.k )
THEN
259 ELSE IF( n.LT.0 )
THEN
261 ELSE IF( k.LT.0 )
THEN
263 ELSE IF( k.LT.nb .OR. nb.LT.1 )
THEN
265 ELSE IF( lda.LT.max( 1, q ) )
THEN
267 ELSE IF( ldt.LT.max( 1, nb ) )
THEN
269 ELSE IF( ldc.LT.max( 1, m ) )
THEN
271 ELSE IF( lwork.LT.lwmin .AND. (.NOT.lquery) )
THEN
280 CALL xerbla(
'DLAMTSQR', -info )
282 ELSE IF( lquery )
THEN
288 IF( minmnk.EQ.0 )
THEN
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 )
300 IF(left.AND.notran)
THEN
304 kk = mod((m-k),(mb-k))
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 )
315 DO i=ii-(mb-k),mb+1,-(mb-k)
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 )
328 CALL dgemqrt(
'L',
'N',mb , n, k, nb, a(1,1), lda, t
329 $ ,ldt ,c(1,1), ldc, work, info )
331 ELSE IF (left.AND.tran)
THEN
335 kk = mod((m-k),(mb-k))
338 CALL dgemqrt(
'L',
'T',mb , n, k, nb, a(1,1), lda, t
339 $ ,ldt ,c(1,1), ldc, work, info )
341 DO i=mb+1,ii-mb+k,(mb-k)
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 )
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 )
361 ELSE IF(right.AND.tran)
THEN
365 kk = mod((n-k),(mb-k))
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 )
376 DO i=ii-(mb-k),mb+1,-(mb-k)
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 )
389 CALL dgemqrt(
'R',
'T',m , mb, k, nb, a(1,1), lda, t
390 $ ,ldt ,c(1,1), ldc, work, info )
392 ELSE IF (right.AND.notran)
THEN
396 kk = mod((n-k),(mb-k))
399 CALL dgemqrt(
'R',
'N', m, mb , k, nb, a(1,1), lda, t
400 $ ,ldt ,c(1,1), ldc, work, info )
402 DO i=mb+1,ii-mb+k,(mb-k)
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 )
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 )