292 SUBROUTINE ztgsyl( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
293 $ LDD, E, LDE, F, LDF, SCALE, DIF, WORK, LWORK,
302 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF,
304 DOUBLE PRECISION DIF, SCALE
308 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
309 $ d( ldd, * ), e( lde, * ), f( ldf, * ),
318 DOUBLE PRECISION ZERO, ONE
319 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0 )
321 parameter( czero = (0.0d+0, 0.0d+0) )
324 LOGICAL LQUERY, NOTRAN
325 INTEGER I, IE, IFUNC, IROUND, IS, ISOLVE, J, JE, JS, K,
326 $ linfo, lwmin, mb, nb, p, pq, q
327 DOUBLE PRECISION DSCALE, DSUM, SCALE2, SCALOC
332 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, d,
440 $ ldd, e, lde, f, ldf, scale, dsum, dscale,
442 IF( dscale.NE.zero )
THEN
443 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
444 dif = sqrt( dble( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
446 dif = sqrt( dble( pq ) ) / ( dscale*sqrt( dsum ) )
449 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
454 CALL zlacpy(
'F', m, n, c, ldc, work, m )
455 CALL zlacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
456 CALL zlaset(
'F', m, n, czero, czero, c, ldc )
457 CALL zlaset(
'F', m, n, czero, czero, f, ldf )
458 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
459 CALL zlacpy(
'F', m, n, work, m, c, ldc )
460 CALL zlacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
484 IF( iwork( p ).EQ.iwork( p+1 ) )
504 IF( iwork( q ).EQ.iwork( q+1 ) )
508 DO 150 iround = 1, isolve
521 je = iwork( j+1 ) - 1
525 ie = iwork( i+1 ) - 1
527 CALL ztgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
528 $ b( js, js ), ldb, c( is, js ), ldc,
529 $ d( is, is ), ldd, e( js, js ), lde,
530 $ f( is, js ), ldf, scaloc, dsum, dscale,
535 IF( scaloc.NE.one )
THEN
537 CALL zscal( m, dcmplx( scaloc, zero ),
539 CALL zscal( m, dcmplx( scaloc, zero ),
543 CALL zscal( is-1, dcmplx( scaloc, zero ),
545 CALL zscal( is-1, dcmplx( scaloc, zero ),
549 CALL zscal( m-ie, dcmplx( scaloc, zero ),
551 CALL zscal( m-ie, dcmplx( scaloc, zero ),
555 CALL zscal( m, dcmplx( scaloc, zero ),
557 CALL zscal( m, dcmplx( scaloc, zero ),
566 CALL zgemm(
'N',
'N', is-1, nb, mb,
567 $ dcmplx( -one, zero ), a( 1, is ), lda,
568 $ c( is, js ), ldc, dcmplx( one, zero ),
570 CALL zgemm(
'N',
'N', is-1, nb, mb,
571 $ dcmplx( -one, zero ), d( 1, is ), ldd,
572 $ c( is, js ), ldc, dcmplx( one, zero ),
576 CALL zgemm(
'N',
'N', mb, n-je, nb,
577 $ dcmplx( one, zero ), f( is, js ), ldf,
578 $ b( js, je+1 ), ldb,
579 $ dcmplx( one, zero ), c( is, je+1 ),
581 CALL zgemm(
'N',
'N', mb, n-je, nb,
582 $ dcmplx( one, zero ), f( is, js ), ldf,
583 $ e( js, je+1 ), lde,
584 $ dcmplx( one, zero ), f( is, je+1 ),
589 IF( dscale.NE.zero )
THEN
590 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
591 dif = sqrt( dble( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
593 dif = sqrt( dble( pq ) ) / ( dscale*sqrt( dsum ) )
596 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
601 CALL zlacpy(
'F', m, n, c, ldc, work, m )
602 CALL zlacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
603 CALL zlaset(
'F', m, n, czero, czero, c, ldc )
604 CALL zlaset(
'F', m, n, czero, czero, f, ldf )
605 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
606 CALL zlacpy(
'F', m, n, work, m, c, ldc )
607 CALL zlacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
621 ie = iwork( i+1 ) - 1
623 DO 200 j = q, p + 2, -1
625 je = iwork( j+1 ) - 1
627 CALL ztgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
628 $ b( js, js ), ldb, c( is, js ), ldc,
629 $ d( is, is ), ldd, e( js, js ), lde,
630 $ f( is, js ), ldf, scaloc, dsum, dscale,
634 IF( scaloc.NE.one )
THEN
636 CALL zscal( m, dcmplx( scaloc, zero ), c( 1, k ),
638 CALL zscal( m, dcmplx( scaloc, zero ), f( 1, k ),
642 CALL zscal( is-1, dcmplx( scaloc, zero ),
644 CALL zscal( is-1, dcmplx( scaloc, zero ),
648 CALL zscal( m-ie, dcmplx( scaloc, zero ),
650 CALL zscal( m-ie, dcmplx( scaloc, zero ),
654 CALL zscal( m, dcmplx( scaloc, zero ), c( 1, k ),
656 CALL zscal( m, dcmplx( scaloc, zero ), f( 1, k ),
665 CALL zgemm(
'N',
'C', mb, js-1, nb,
666 $ dcmplx( one, zero ), c( is, js ), ldc,
667 $ b( 1, js ), ldb, dcmplx( one, zero ),
669 CALL zgemm(
'N',
'C', mb, js-1, nb,
670 $ dcmplx( one, zero ), f( is, js ), ldf,
671 $ e( 1, js ), lde, dcmplx( one, zero ),
675 CALL zgemm(
'C',
'N', m-ie, nb, mb,
676 $ dcmplx( -one, zero ), a( is, ie+1 ), lda,
677 $ c( is, js ), ldc, dcmplx( one, zero ),
678 $ c( ie+1, js ), ldc )
679 CALL zgemm(
'C',
'N', m-ie, nb, mb,
680 $ dcmplx( -one, zero ), d( is, ie+1 ), ldd,
681 $ f( is, js ), ldf, dcmplx( one, zero ),
682 $ c( ie+1, js ), ldc )
subroutine xerbla(srname, info)
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlaset(uplo, m, n, alpha, beta, a, lda)
ZLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine zscal(n, za, zx, incx)
ZSCAL
subroutine ztgsy2(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, rdsum, rdscal, info)
ZTGSY2 solves the generalized Sylvester equation (unblocked algorithm).
subroutine ztgsyl(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, dif, work, lwork, iwork, info)
ZTGSYL