290 SUBROUTINE ztgsyl( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC,
292 $ LDD, E, LDE, F, LDF, SCALE, DIF, WORK, LWORK,
301 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF,
303 DOUBLE PRECISION DIF, SCALE
307 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
308 $ D( LDD, * ), E( LDE, * ), F( LDF, * ),
317 DOUBLE PRECISION ZERO, ONE
318 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0 )
320 parameter( czero = (0.0d+0, 0.0d+0) )
323 LOGICAL LQUERY, NOTRAN
324 INTEGER I, IE, IFUNC, IROUND, IS, ISOLVE, J, JE, JS, K,
325 $ LINFO, LWMIN, MB, NB, P, PQ, Q
326 DOUBLE PRECISION DSCALE, DSUM, SCALE2, SCALOC
331 EXTERNAL LSAME, ILAENV
338 INTRINSIC dble, dcmplx, max, sqrt
345 notran = lsame( trans,
'N' )
346 lquery = ( lwork.EQ.-1 )
348 IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
350 ELSE IF( notran )
THEN
351 IF( ( ijob.LT.0 ) .OR. ( ijob.GT.4 ) )
THEN
358 ELSE IF( n.LE.0 )
THEN
360 ELSE IF( lda.LT.max( 1, m ) )
THEN
362 ELSE IF( ldb.LT.max( 1, n ) )
THEN
364 ELSE IF( ldc.LT.max( 1, m ) )
THEN
366 ELSE IF( ldd.LT.max( 1, m ) )
THEN
368 ELSE IF( lde.LT.max( 1, n ) )
THEN
370 ELSE IF( ldf.LT.max( 1, m ) )
THEN
377 IF( ijob.EQ.1 .OR. ijob.EQ.2 )
THEN
378 lwmin = max( 1, 2*m*n )
387 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
393 CALL xerbla(
'ZTGSYL', -info )
395 ELSE IF( lquery )
THEN
401 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
413 mb = ilaenv( 2,
'ZTGSYL', trans, m, n, -1, -1 )
414 nb = ilaenv( 5,
'ZTGSYL', trans, m, n, -1, -1 )
421 CALL zlaset(
'F', m, n, czero, czero, c, ldc )
422 CALL zlaset(
'F', m, n, czero, czero, f, ldf )
423 ELSE IF( ijob.GE.1 .AND. notran )
THEN
428 IF( ( mb.LE.1 .AND. nb.LE.1 ) .OR. ( mb.GE.m .AND. nb.GE.n ) )
433 DO 30 iround = 1, isolve
439 CALL ztgsy2( trans, ifunc, m, n, a, lda, b, ldb, c, ldc,
441 $ ldd, e, lde, f, ldf, scale, dsum, dscale,
443 IF( dscale.NE.zero )
THEN
444 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
445 dif = sqrt( dble( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
447 dif = sqrt( dble( pq ) ) / ( dscale*sqrt( dsum ) )
450 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
455 CALL zlacpy(
'F', m, n, c, ldc, work, m )
456 CALL zlacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
457 CALL zlaset(
'F', m, n, czero, czero, c, ldc )
458 CALL zlaset(
'F', m, n, czero, czero, f, ldf )
459 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
460 CALL zlacpy(
'F', m, n, work, m, c, ldc )
461 CALL zlacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
485 IF( iwork( p ).EQ.iwork( p+1 ) )
505 IF( iwork( q ).EQ.iwork( q+1 ) )
509 DO 150 iround = 1, isolve
522 je = iwork( j+1 ) - 1
526 ie = iwork( i+1 ) - 1
528 CALL ztgsy2( trans, ifunc, mb, nb, a( is, is ),
530 $ b( js, js ), ldb, c( is, js ), ldc,
531 $ d( is, is ), ldd, e( js, js ), lde,
532 $ f( is, js ), ldf, scaloc, dsum, dscale,
537 IF( scaloc.NE.one )
THEN
539 CALL zscal( m, dcmplx( scaloc, zero ),
541 CALL zscal( m, dcmplx( scaloc, zero ),
545 CALL zscal( is-1, dcmplx( scaloc, zero ),
547 CALL zscal( is-1, dcmplx( scaloc, zero ),
551 CALL zscal( m-ie, dcmplx( scaloc, zero ),
553 CALL zscal( m-ie, dcmplx( scaloc, zero ),
557 CALL zscal( m, dcmplx( scaloc, zero ),
559 CALL zscal( m, dcmplx( scaloc, zero ),
568 CALL zgemm(
'N',
'N', is-1, nb, mb,
569 $ dcmplx( -one, zero ), a( 1, is ), lda,
570 $ c( is, js ), ldc, dcmplx( one, zero ),
572 CALL zgemm(
'N',
'N', is-1, nb, mb,
573 $ dcmplx( -one, zero ), d( 1, is ), ldd,
574 $ c( is, js ), ldc, dcmplx( one, zero ),
578 CALL zgemm(
'N',
'N', mb, n-je, nb,
579 $ dcmplx( one, zero ), f( is, js ), ldf,
580 $ b( js, je+1 ), ldb,
581 $ dcmplx( one, zero ), c( is, je+1 ),
583 CALL zgemm(
'N',
'N', mb, n-je, nb,
584 $ dcmplx( one, zero ), f( is, js ), ldf,
585 $ e( js, je+1 ), lde,
586 $ dcmplx( one, zero ), f( is, je+1 ),
591 IF( dscale.NE.zero )
THEN
592 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
593 dif = sqrt( dble( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
595 dif = sqrt( dble( pq ) ) / ( dscale*sqrt( dsum ) )
598 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
603 CALL zlacpy(
'F', m, n, c, ldc, work, m )
604 CALL zlacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
605 CALL zlaset(
'F', m, n, czero, czero, c, ldc )
606 CALL zlaset(
'F', m, n, czero, czero, f, ldf )
607 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
608 CALL zlacpy(
'F', m, n, work, m, c, ldc )
609 CALL zlacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
623 ie = iwork( i+1 ) - 1
625 DO 200 j = q, p + 2, -1
627 je = iwork( j+1 ) - 1
629 CALL ztgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
630 $ b( js, js ), ldb, c( is, js ), ldc,
631 $ d( is, is ), ldd, e( js, js ), lde,
632 $ f( is, js ), ldf, scaloc, dsum, dscale,
636 IF( scaloc.NE.one )
THEN
638 CALL zscal( m, dcmplx( scaloc, zero ), c( 1,
641 CALL zscal( m, dcmplx( scaloc, zero ), f( 1,
646 CALL zscal( is-1, dcmplx( scaloc, zero ),
648 CALL zscal( is-1, dcmplx( scaloc, zero ),
652 CALL zscal( m-ie, dcmplx( scaloc, zero ),
654 CALL zscal( m-ie, dcmplx( scaloc, zero ),
658 CALL zscal( m, dcmplx( scaloc, zero ), c( 1,
661 CALL zscal( m, dcmplx( scaloc, zero ), f( 1,
671 CALL zgemm(
'N',
'C', mb, js-1, nb,
672 $ dcmplx( one, zero ), c( is, js ), ldc,
673 $ b( 1, js ), ldb, dcmplx( one, zero ),
675 CALL zgemm(
'N',
'C', mb, js-1, nb,
676 $ dcmplx( one, zero ), f( is, js ), ldf,
677 $ e( 1, js ), lde, dcmplx( one, zero ),
681 CALL zgemm(
'C',
'N', m-ie, nb, mb,
682 $ dcmplx( -one, zero ), a( is, ie+1 ), lda,
683 $ c( is, js ), ldc, dcmplx( one, zero ),
684 $ c( ie+1, js ), ldc )
685 CALL zgemm(
'C',
'N', m-ie, nb, mb,
686 $ dcmplx( -one, zero ), d( is, ie+1 ), ldd,
687 $ f( is, js ), ldf, dcmplx( one, zero ),
688 $ c( ie+1, js ), ldc )