292 SUBROUTINE ctgsyl( 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,
308 COMPLEX A( LDA, * ), B( LDB, * ), C( LDC, * ),
309 $ d( ldd, * ), e( lde, * ), f( ldf, * ),
319 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
321 parameter( czero = (0.0e+0, 0.0e+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 REAL DSCALE, DSUM, SCALE2, SCALOC
333 EXTERNAL lsame, ilaenv, sroundup_lwork
339 INTRINSIC cmplx, max, real, sqrt
346 notran = lsame( trans,
'N' )
347 lquery = ( lwork.EQ.-1 )
349 IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
351 ELSE IF( notran )
THEN
352 IF( ( ijob.LT.0 ) .OR. ( ijob.GT.4 ) )
THEN
359 ELSE IF( n.LE.0 )
THEN
361 ELSE IF( lda.LT.max( 1, m ) )
THEN
363 ELSE IF( ldb.LT.max( 1, n ) )
THEN
365 ELSE IF( ldc.LT.max( 1, m ) )
THEN
367 ELSE IF( ldd.LT.max( 1, m ) )
THEN
369 ELSE IF( lde.LT.max( 1, n ) )
THEN
371 ELSE IF( ldf.LT.max( 1, m ) )
THEN
378 IF( ijob.EQ.1 .OR. ijob.EQ.2 )
THEN
379 lwmin = max( 1, 2*m*n )
386 work( 1 ) = sroundup_lwork(lwmin)
388 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
394 CALL xerbla(
'CTGSYL', -info )
396 ELSE IF( lquery )
THEN
402 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
414 mb = ilaenv( 2,
'CTGSYL', trans, m, n, -1, -1 )
415 nb = ilaenv( 5,
'CTGSYL', trans, m, n, -1, -1 )
422 CALL claset(
'F', m, n, czero, czero, c, ldc )
423 CALL claset(
'F', m, n, czero, czero, f, ldf )
424 ELSE IF( ijob.GE.1 .AND. notran )
THEN
429 IF( ( mb.LE.1 .AND. nb.LE.1 ) .OR. ( mb.GE.m .AND. nb.GE.n ) )
434 DO 30 iround = 1, isolve
440 CALL ctgsy2( trans, ifunc, m, n, a, lda, b, ldb, c, ldc, d,
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( real( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
447 dif = sqrt( real( pq ) ) / ( dscale*sqrt( dsum ) )
450 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
455 CALL clacpy(
'F', m, n, c, ldc, work, m )
456 CALL clacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
457 CALL claset(
'F', m, n, czero, czero, c, ldc )
458 CALL claset(
'F', m, n, czero, czero, f, ldf )
459 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
460 CALL clacpy(
'F', m, n, work, m, c, ldc )
461 CALL clacpy(
'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 ctgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
529 $ b( js, js ), ldb, c( is, js ), ldc,
530 $ d( is, is ), ldd, e( js, js ), lde,
531 $ f( is, js ), ldf, scaloc, dsum, dscale,
536 IF( scaloc.NE.one )
THEN
538 CALL cscal( m, cmplx( scaloc, zero ), c( 1, k ),
540 CALL cscal( m, cmplx( scaloc, zero ), f( 1, k ),
544 CALL cscal( is-1, cmplx( scaloc, zero ),
546 CALL cscal( is-1, cmplx( scaloc, zero ),
550 CALL cscal( m-ie, cmplx( scaloc, zero ),
552 CALL cscal( m-ie, cmplx( scaloc, zero ),
556 CALL cscal( m, cmplx( scaloc, zero ), c( 1, k ),
558 CALL cscal( m, cmplx( scaloc, zero ), f( 1, k ),
567 CALL cgemm(
'N',
'N', is-1, nb, mb,
568 $ cmplx( -one, zero ), a( 1, is ), lda,
569 $ c( is, js ), ldc, cmplx( one, zero ),
571 CALL cgemm(
'N',
'N', is-1, nb, mb,
572 $ cmplx( -one, zero ), d( 1, is ), ldd,
573 $ c( is, js ), ldc, cmplx( one, zero ),
577 CALL cgemm(
'N',
'N', mb, n-je, nb,
578 $ cmplx( one, zero ), f( is, js ), ldf,
579 $ b( js, je+1 ), ldb, cmplx( one, zero ),
580 $ c( is, je+1 ), ldc )
581 CALL cgemm(
'N',
'N', mb, n-je, nb,
582 $ cmplx( one, zero ), f( is, js ), ldf,
583 $ e( js, je+1 ), lde, cmplx( one, zero ),
584 $ f( is, je+1 ), ldf )
588 IF( dscale.NE.zero )
THEN
589 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
590 dif = sqrt( real( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
592 dif = sqrt( real( pq ) ) / ( dscale*sqrt( dsum ) )
595 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
600 CALL clacpy(
'F', m, n, c, ldc, work, m )
601 CALL clacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
602 CALL claset(
'F', m, n, czero, czero, c, ldc )
603 CALL claset(
'F', m, n, czero, czero, f, ldf )
604 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
605 CALL clacpy(
'F', m, n, work, m, c, ldc )
606 CALL clacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
620 ie = iwork( i+1 ) - 1
622 DO 200 j = q, p + 2, -1
624 je = iwork( j+1 ) - 1
626 CALL ctgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
627 $ b( js, js ), ldb, c( is, js ), ldc,
628 $ d( is, is ), ldd, e( js, js ), lde,
629 $ f( is, js ), ldf, scaloc, dsum, dscale,
633 IF( scaloc.NE.one )
THEN
635 CALL cscal( m, cmplx( scaloc, zero ), c( 1, k ),
637 CALL cscal( m, cmplx( scaloc, zero ), f( 1, k ),
641 CALL cscal( is-1, cmplx( scaloc, zero ), c( 1, k ),
643 CALL cscal( is-1, cmplx( scaloc, zero ), f( 1, k ),
647 CALL cscal( m-ie, cmplx( scaloc, zero ),
649 CALL cscal( m-ie, cmplx( scaloc, zero ),
653 CALL cscal( m, cmplx( scaloc, zero ), c( 1, k ),
655 CALL cscal( m, cmplx( scaloc, zero ), f( 1, k ),
664 CALL cgemm(
'N',
'C', mb, js-1, nb,
665 $ cmplx( one, zero ), c( is, js ), ldc,
666 $ b( 1, js ), ldb, cmplx( one, zero ),
668 CALL cgemm(
'N',
'C', mb, js-1, nb,
669 $ cmplx( one, zero ), f( is, js ), ldf,
670 $ e( 1, js ), lde, cmplx( one, zero ),
674 CALL cgemm(
'C',
'N', m-ie, nb, mb,
675 $ cmplx( -one, zero ), a( is, ie+1 ), lda,
676 $ c( is, js ), ldc, cmplx( one, zero ),
677 $ c( ie+1, js ), ldc )
678 CALL cgemm(
'C',
'N', m-ie, nb, mb,
679 $ cmplx( -one, zero ), d( is, ie+1 ), ldd,
680 $ f( is, js ), ldf, cmplx( one, zero ),
681 $ c( ie+1, js ), ldc )
687 work( 1 ) = sroundup_lwork(lwmin)
subroutine xerbla(srname, info)
subroutine cgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
CGEMM
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine claset(uplo, m, n, alpha, beta, a, lda)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine ctgsy2(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, rdsum, rdscal, info)
CTGSY2 solves the generalized Sylvester equation (unblocked algorithm).
subroutine ctgsyl(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, dif, work, lwork, iwork, info)
CTGSYL