296 SUBROUTINE stgsyl( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
297 $ LDD, E, LDE, F, LDF, SCALE, DIF, WORK, LWORK,
306 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF,
312 REAL A( LDA, * ), B( LDB, * ), C( LDC, * ),
313 $ d( ldd, * ), e( lde, * ), f( ldf, * ),
323 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
326 LOGICAL LQUERY, NOTRAN
327 INTEGER I, IE, IFUNC, IROUND, IS, ISOLVE, J, JE, JS, K,
328 $ linfo, lwmin, mb, nb, p, ppqq, pq, q
329 REAL DSCALE, DSUM, SCALE2, SCALOC
335 EXTERNAL lsame, ilaenv, sroundup_lwork
341 INTRINSIC max, real, sqrt
348 notran = lsame( trans,
'N' )
349 lquery = ( lwork.EQ.-1 )
351 IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) )
THEN
353 ELSE IF( notran )
THEN
354 IF( ( ijob.LT.0 ) .OR. ( ijob.GT.4 ) )
THEN
361 ELSE IF( n.LE.0 )
THEN
363 ELSE IF( lda.LT.max( 1, m ) )
THEN
365 ELSE IF( ldb.LT.max( 1, n ) )
THEN
367 ELSE IF( ldc.LT.max( 1, m ) )
THEN
369 ELSE IF( ldd.LT.max( 1, m ) )
THEN
371 ELSE IF( lde.LT.max( 1, n ) )
THEN
373 ELSE IF( ldf.LT.max( 1, m ) )
THEN
380 IF( ijob.EQ.1 .OR. ijob.EQ.2 )
THEN
381 lwmin = max( 1, 2*m*n )
388 work( 1 ) = sroundup_lwork(lwmin)
390 IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
396 CALL xerbla(
'STGSYL', -info )
398 ELSE IF( lquery )
THEN
404 IF( m.EQ.0 .OR. n.EQ.0 )
THEN
416 mb = ilaenv( 2,
'STGSYL', trans, m, n, -1, -1 )
417 nb = ilaenv( 5,
'STGSYL', trans, m, n, -1, -1 )
424 CALL slaset(
'F', m, n, zero, zero, c, ldc )
425 CALL slaset(
'F', m, n, zero, zero, f, ldf )
426 ELSE IF( ijob.GE.1 .AND. notran )
THEN
431 IF( ( mb.LE.1 .AND. nb.LE.1 ) .OR. ( mb.GE.m .AND. nb.GE.n ) )
434 DO 30 iround = 1, isolve
441 CALL stgsy2( trans, ifunc, m, n, a, lda, b, ldb, c, ldc, d,
442 $ ldd, e, lde, f, ldf, scale, dsum, dscale,
444 IF( dscale.NE.zero )
THEN
445 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
446 dif = sqrt( real( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
448 dif = sqrt( real( pq ) ) / ( dscale*sqrt( dsum ) )
452 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
457 CALL slacpy(
'F', m, n, c, ldc, work, m )
458 CALL slacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
459 CALL slaset(
'F', m, n, zero, zero, c, ldc )
460 CALL slaset(
'F', m, n, zero, zero, f, ldf )
461 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
462 CALL slacpy(
'F', m, n, work, m, c, ldc )
463 CALL slacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
483 IF( a( i, i-1 ).NE.zero )
489 IF( iwork( p ).EQ.iwork( p+1 ) )
504 IF( b( j, j-1 ).NE.zero )
510 IF( iwork( q ).EQ.iwork( q+1 ) )
515 DO 150 iround = 1, isolve
528 je = iwork( j+1 ) - 1
532 ie = iwork( i+1 ) - 1
535 CALL stgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
536 $ b( js, js ), ldb, c( is, js ), ldc,
537 $ d( is, is ), ldd, e( js, js ), lde,
538 $ f( is, js ), ldf, scaloc, dsum, dscale,
539 $ iwork( q+2 ), ppqq, linfo )
544 IF( scaloc.NE.one )
THEN
546 CALL sscal( m, scaloc, c( 1, k ), 1 )
547 CALL sscal( m, scaloc, f( 1, k ), 1 )
550 CALL sscal( is-1, scaloc, c( 1, k ), 1 )
551 CALL sscal( is-1, scaloc, f( 1, k ), 1 )
554 CALL sscal( m-ie, scaloc, c( ie+1, k ), 1 )
555 CALL sscal( m-ie, scaloc, f( ie+1, k ), 1 )
558 CALL sscal( m, scaloc, c( 1, k ), 1 )
559 CALL sscal( m, scaloc, f( 1, k ), 1 )
568 CALL sgemm(
'N',
'N', is-1, nb, mb, -one,
569 $ a( 1, is ), lda, c( is, js ), ldc, one,
571 CALL sgemm(
'N',
'N', is-1, nb, mb, -one,
572 $ d( 1, is ), ldd, c( is, js ), ldc, one,
576 CALL sgemm(
'N',
'N', mb, n-je, nb, one,
577 $ f( is, js ), ldf, b( js, je+1 ), ldb,
578 $ one, c( is, je+1 ), ldc )
579 CALL sgemm(
'N',
'N', mb, n-je, nb, one,
580 $ f( is, js ), ldf, e( js, je+1 ), lde,
581 $ one, f( is, je+1 ), ldf )
585 IF( dscale.NE.zero )
THEN
586 IF( ijob.EQ.1 .OR. ijob.EQ.3 )
THEN
587 dif = sqrt( real( 2*m*n ) ) / ( dscale*sqrt( dsum ) )
589 dif = sqrt( real( pq ) ) / ( dscale*sqrt( dsum ) )
592 IF( isolve.EQ.2 .AND. iround.EQ.1 )
THEN
597 CALL slacpy(
'F', m, n, c, ldc, work, m )
598 CALL slacpy(
'F', m, n, f, ldf, work( m*n+1 ), m )
599 CALL slaset(
'F', m, n, zero, zero, c, ldc )
600 CALL slaset(
'F', m, n, zero, zero, f, ldf )
601 ELSE IF( isolve.EQ.2 .AND. iround.EQ.2 )
THEN
602 CALL slacpy(
'F', m, n, work, m, c, ldc )
603 CALL slacpy(
'F', m, n, work( m*n+1 ), m, f, ldf )
618 ie = iwork( i+1 ) - 1
620 DO 200 j = q, p + 2, -1
622 je = iwork( j+1 ) - 1
624 CALL stgsy2( trans, ifunc, mb, nb, a( is, is ), lda,
625 $ b( js, js ), ldb, c( is, js ), ldc,
626 $ d( is, is ), ldd, e( js, js ), lde,
627 $ f( is, js ), ldf, scaloc, dsum, dscale,
628 $ iwork( q+2 ), ppqq, linfo )
631 IF( scaloc.NE.one )
THEN
633 CALL sscal( m, scaloc, c( 1, k ), 1 )
634 CALL sscal( m, scaloc, f( 1, k ), 1 )
637 CALL sscal( is-1, scaloc, c( 1, k ), 1 )
638 CALL sscal( is-1, scaloc, f( 1, k ), 1 )
641 CALL sscal( m-ie, scaloc, c( ie+1, k ), 1 )
642 CALL sscal( m-ie, scaloc, f( ie+1, k ), 1 )
645 CALL sscal( m, scaloc, c( 1, k ), 1 )
646 CALL sscal( m, scaloc, f( 1, k ), 1 )
654 CALL sgemm(
'N',
'T', mb, js-1, nb, one, c( is, js ),
655 $ ldc, b( 1, js ), ldb, one, f( is, 1 ),
657 CALL sgemm(
'N',
'T', mb, js-1, nb, one, f( is, js ),
658 $ ldf, e( 1, js ), lde, one, f( is, 1 ),
662 CALL sgemm(
'T',
'N', m-ie, nb, mb, -one,
663 $ a( is, ie+1 ), lda, c( is, js ), ldc, one,
664 $ c( ie+1, js ), ldc )
665 CALL sgemm(
'T',
'N', m-ie, nb, mb, -one,
666 $ d( is, ie+1 ), ldd, f( is, js ), ldf, one,
667 $ c( ie+1, js ), ldc )
674 work( 1 ) = sroundup_lwork(lwmin)
subroutine xerbla(srname, info)
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
subroutine slaset(uplo, m, n, alpha, beta, a, lda)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine stgsy2(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, rdsum, rdscal, iwork, pq, info)
STGSY2 solves the generalized Sylvester equation (unblocked algorithm).
subroutine stgsyl(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, dif, work, lwork, iwork, info)
STGSYL