199 SUBROUTINE zlamtsqr( 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 COMPLEX*16 A( LDA, * ), WORK( * ), C( LDC, * ),
219 LOGICAL LEFT, RIGHT, TRAN, NOTRAN, LQUERY
220 INTEGER I, II, KK, LW, CTR, Q, MINMNK, LWMIN
234 lquery = ( lwork.EQ.-1 )
235 notran = lsame( trans,
'N' )
236 tran = lsame( trans,
'C' )
237 left = lsame( side,
'L' )
238 right = lsame( side,
'R' )
247 minmnk = min( m, n, k )
248 IF( minmnk.EQ.0 )
THEN
254 IF( .NOT.left .AND. .NOT.right )
THEN
256 ELSE IF( .NOT.tran .AND. .NOT.notran )
THEN
258 ELSE IF( m.LT.k )
THEN
260 ELSE IF( n.LT.0 )
THEN
262 ELSE IF( k.LT.0 )
THEN
264 ELSE IF( k.LT.nb .OR. nb.LT.1 )
THEN
266 ELSE IF( lda.LT.max( 1, q ) )
THEN
268 ELSE IF( ldt.LT.max( 1, nb ) )
THEN
270 ELSE IF( ldc.LT.max( 1, m ) )
THEN
272 ELSE IF( lwork.LT.lwmin .AND. (.NOT.lquery) )
THEN
281 CALL xerbla(
'ZLAMTSQR', -info )
283 ELSE IF( lquery )
THEN
289 IF( minmnk.EQ.0 )
THEN
295 IF((mb.LE.k).OR.(mb.GE.max(m,n,k)))
THEN
296 CALL zgemqrt( side, trans, m, n, k, nb, a, lda,
297 $ t, ldt, c, ldc, work, info )
301 IF(left.AND.notran)
THEN
305 kk = mod((m-k),(mb-k))
309 CALL ztpmqrt(
'L',
'N',kk , n, k, 0, nb, a(ii,1), lda,
310 $ t(1, ctr * k + 1),ldt , c(1,1), ldc,
311 $ c(ii,1), ldc, work, info )
316 DO i=ii-(mb-k),mb+1,-(mb-k)
321 CALL ztpmqrt(
'L',
'N',mb-k , n, k, 0,nb, a(i,1), lda,
322 $ t(1,ctr * k + 1),ldt, c(1,1), ldc,
323 $ c(i,1), ldc, work, info )
329 CALL zgemqrt(
'L',
'N',mb , n, k, nb, a(1,1), lda, t
330 $ ,ldt ,c(1,1), ldc, work, info )
332 ELSE IF (left.AND.tran)
THEN
336 kk = mod((m-k),(mb-k))
339 CALL zgemqrt(
'L',
'C',mb , n, k, nb, a(1,1), lda, t
340 $ ,ldt ,c(1,1), ldc, work, info )
342 DO i=mb+1,ii-mb+k,(mb-k)
346 CALL ztpmqrt(
'L',
'C',mb-k , n, k, 0,nb, a(i,1), lda,
347 $ t(1,ctr * k + 1),ldt, c(1,1), ldc,
348 $ c(i,1), ldc, work, info )
356 CALL ztpmqrt(
'L',
'C',kk , n, k, 0,nb, a(ii,1), lda,
357 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
358 $ c(ii,1), ldc, work, info )
362 ELSE IF(right.AND.tran)
THEN
366 kk = mod((n-k),(mb-k))
370 CALL ztpmqrt(
'R',
'C',m , kk, k, 0, nb, a(ii,1), lda,
371 $ t(1,ctr * k + 1), ldt, c(1,1), ldc,
372 $ c(1,ii), ldc, work, info )
377 DO i=ii-(mb-k),mb+1,-(mb-k)
382 CALL ztpmqrt(
'R',
'C',m , mb-k, k, 0,nb, a(i,1), lda,
383 $ t(1, ctr * k + 1), ldt, c(1,1), ldc,
384 $ c(1,i), ldc, work, info )
390 CALL zgemqrt(
'R',
'C',m , mb, k, nb, a(1,1), lda, t
391 $ ,ldt ,c(1,1), ldc, work, info )
393 ELSE IF (right.AND.notran)
THEN
397 kk = mod((n-k),(mb-k))
400 CALL zgemqrt(
'R',
'N', m, mb , k, nb, a(1,1), lda, t
401 $ ,ldt ,c(1,1), ldc, work, info )
403 DO i=mb+1,ii-mb+k,(mb-k)
407 CALL ztpmqrt(
'R',
'N', m, mb-k, k, 0,nb, a(i,1), lda,
408 $ t(1, ctr * k + 1),ldt, c(1,1), ldc,
409 $ c(1,i), ldc, work, info )
417 CALL ztpmqrt(
'R',
'N', m, kk , k, 0,nb, a(ii,1), lda,
418 $ t(1,ctr * k + 1),ldt, c(1,1), ldc,
419 $ c(1,ii), ldc, work, info )