271 SUBROUTINE dtgsy2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
272 $ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
281 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N,
283 DOUBLE PRECISION RDSCAL, RDSUM, SCALE
287 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ),
288 $ d( ldd, * ), e( lde, * ), f( ldf, * )
297 PARAMETER ( LDZ = 8 )
298 DOUBLE PRECISION ZERO, ONE
299 parameter( zero = 0.0d+0, one = 1.0d+0 )
303 INTEGER I, IE, IERR, II, IS, ISP1, J, JE, JJ, JS, JSP1,
304 $ k, mb, nb, p, q, zdim
305 DOUBLE PRECISION ALPHA, SCALOC
308 INTEGER IPIV( LDZ ), JPIV( LDZ )
309 DOUBLE PRECISION RHS( LDZ ), Z( LDZ, LDZ )
328 notran = lsame( trans,
'N' )
329 IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) )
THEN
331 ELSE IF( notran )
THEN
332 IF( ( ijob.LT.0 ) .OR. ( ijob.GT.2 ) )
THEN
339 ELSE IF( n.LE.0 )
THEN
341 ELSE IF( lda.LT.max( 1, m ) )
THEN
343 ELSE IF( ldb.LT.max( 1, n ) )
THEN
345 ELSE IF( ldc.LT.max( 1, m ) )
THEN
347 ELSE IF( ldd.LT.max( 1, m ) )
THEN
349 ELSE IF( lde.LT.max( 1, n ) )
THEN
351 ELSE IF( ldf.LT.max( 1, m ) )
THEN
356 CALL xerbla(
'DTGSY2', -info )
372 IF( a( i+1, i ).NE.zero )
THEN
392 IF( b( j+1, j ).NE.zero )
THEN
414 je = iwork( j+1 ) - 1
420 ie = iwork( i+1 ) - 1
424 IF( ( mb.EQ.1 ) .AND. ( nb.EQ.1 ) )
THEN
428 z( 1, 1 ) = a( is, is )
429 z( 2, 1 ) = d( is, is )
430 z( 1, 2 ) = -b( js, js )
431 z( 2, 2 ) = -e( js, js )
435 rhs( 1 ) = c( is, js )
436 rhs( 2 ) = f( is, js )
440 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
445 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
447 IF( scaloc.NE.one )
THEN
449 CALL dscal( m, scaloc, c( 1, k ), 1 )
450 CALL dscal( m, scaloc, f( 1, k ), 1 )
455 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
456 $ rdscal, ipiv, jpiv )
461 c( is, js ) = rhs( 1 )
462 f( is, js ) = rhs( 2 )
469 CALL daxpy( is-1, alpha, a( 1, is ), 1, c( 1, js ),
471 CALL daxpy( is-1, alpha, d( 1, is ), 1, f( 1, js ),
475 CALL daxpy( n-je, rhs( 2 ), b( js, je+1 ), ldb,
476 $ c( is, je+1 ), ldc )
477 CALL daxpy( n-je, rhs( 2 ), e( js, je+1 ), lde,
478 $ f( is, je+1 ), ldf )
481 ELSE IF( ( mb.EQ.1 ) .AND. ( nb.EQ.2 ) )
THEN
485 z( 1, 1 ) = a( is, is )
487 z( 3, 1 ) = d( is, is )
491 z( 2, 2 ) = a( is, is )
493 z( 4, 2 ) = d( is, is )
495 z( 1, 3 ) = -b( js, js )
496 z( 2, 3 ) = -b( js, jsp1 )
497 z( 3, 3 ) = -e( js, js )
498 z( 4, 3 ) = -e( js, jsp1 )
500 z( 1, 4 ) = -b( jsp1, js )
501 z( 2, 4 ) = -b( jsp1, jsp1 )
503 z( 4, 4 ) = -e( jsp1, jsp1 )
507 rhs( 1 ) = c( is, js )
508 rhs( 2 ) = c( is, jsp1 )
509 rhs( 3 ) = f( is, js )
510 rhs( 4 ) = f( is, jsp1 )
514 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
519 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
521 IF( scaloc.NE.one )
THEN
523 CALL dscal( m, scaloc, c( 1, k ), 1 )
524 CALL dscal( m, scaloc, f( 1, k ), 1 )
529 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
530 $ rdscal, ipiv, jpiv )
535 c( is, js ) = rhs( 1 )
536 c( is, jsp1 ) = rhs( 2 )
537 f( is, js ) = rhs( 3 )
538 f( is, jsp1 ) = rhs( 4 )
544 CALL dger( is-1, nb, -one, a( 1, is ), 1, rhs( 1 ),
545 $ 1, c( 1, js ), ldc )
546 CALL dger( is-1, nb, -one, d( 1, is ), 1, rhs( 1 ),
547 $ 1, f( 1, js ), ldf )
550 CALL daxpy( n-je, rhs( 3 ), b( js, je+1 ), ldb,
551 $ c( is, je+1 ), ldc )
552 CALL daxpy( n-je, rhs( 3 ), e( js, je+1 ), lde,
553 $ f( is, je+1 ), ldf )
554 CALL daxpy( n-je, rhs( 4 ), b( jsp1, je+1 ), ldb,
555 $ c( is, je+1 ), ldc )
556 CALL daxpy( n-je, rhs( 4 ), e( jsp1, je+1 ), lde,
557 $ f( is, je+1 ), ldf )
560 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.1 ) )
THEN
564 z( 1, 1 ) = a( is, is )
565 z( 2, 1 ) = a( isp1, is )
566 z( 3, 1 ) = d( is, is )
569 z( 1, 2 ) = a( is, isp1 )
570 z( 2, 2 ) = a( isp1, isp1 )
571 z( 3, 2 ) = d( is, isp1 )
572 z( 4, 2 ) = d( isp1, isp1 )
574 z( 1, 3 ) = -b( js, js )
576 z( 3, 3 ) = -e( js, js )
580 z( 2, 4 ) = -b( js, js )
582 z( 4, 4 ) = -e( js, js )
586 rhs( 1 ) = c( is, js )
587 rhs( 2 ) = c( isp1, js )
588 rhs( 3 ) = f( is, js )
589 rhs( 4 ) = f( isp1, js )
593 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
597 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
599 IF( scaloc.NE.one )
THEN
601 CALL dscal( m, scaloc, c( 1, k ), 1 )
602 CALL dscal( m, scaloc, f( 1, k ), 1 )
607 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
608 $ rdscal, ipiv, jpiv )
613 c( is, js ) = rhs( 1 )
614 c( isp1, js ) = rhs( 2 )
615 f( is, js ) = rhs( 3 )
616 f( isp1, js ) = rhs( 4 )
622 CALL dgemv(
'N', is-1, mb, -one, a( 1, is ), lda,
623 $ rhs( 1 ), 1, one, c( 1, js ), 1 )
624 CALL dgemv(
'N', is-1, mb, -one, d( 1, is ), ldd,
625 $ rhs( 1 ), 1, one, f( 1, js ), 1 )
628 CALL dger( mb, n-je, one, rhs( 3 ), 1,
629 $ b( js, je+1 ), ldb, c( is, je+1 ), ldc )
630 CALL dger( mb, n-je, one, rhs( 3 ), 1,
631 $ e( js, je+1 ), lde, f( is, je+1 ), ldf )
634 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.2 ) )
THEN
638 CALL dlaset(
'F', ldz, ldz, zero, zero, z, ldz )
640 z( 1, 1 ) = a( is, is )
641 z( 2, 1 ) = a( isp1, is )
642 z( 5, 1 ) = d( is, is )
644 z( 1, 2 ) = a( is, isp1 )
645 z( 2, 2 ) = a( isp1, isp1 )
646 z( 5, 2 ) = d( is, isp1 )
647 z( 6, 2 ) = d( isp1, isp1 )
649 z( 3, 3 ) = a( is, is )
650 z( 4, 3 ) = a( isp1, is )
651 z( 7, 3 ) = d( is, is )
653 z( 3, 4 ) = a( is, isp1 )
654 z( 4, 4 ) = a( isp1, isp1 )
655 z( 7, 4 ) = d( is, isp1 )
656 z( 8, 4 ) = d( isp1, isp1 )
658 z( 1, 5 ) = -b( js, js )
659 z( 3, 5 ) = -b( js, jsp1 )
660 z( 5, 5 ) = -e( js, js )
661 z( 7, 5 ) = -e( js, jsp1 )
663 z( 2, 6 ) = -b( js, js )
664 z( 4, 6 ) = -b( js, jsp1 )
665 z( 6, 6 ) = -e( js, js )
666 z( 8, 6 ) = -e( js, jsp1 )
668 z( 1, 7 ) = -b( jsp1, js )
669 z( 3, 7 ) = -b( jsp1, jsp1 )
670 z( 7, 7 ) = -e( jsp1, jsp1 )
672 z( 2, 8 ) = -b( jsp1, js )
673 z( 4, 8 ) = -b( jsp1, jsp1 )
674 z( 8, 8 ) = -e( jsp1, jsp1 )
681 CALL dcopy( mb, c( is, js+jj ), 1, rhs( k ), 1 )
682 CALL dcopy( mb, f( is, js+jj ), 1, rhs( ii ), 1 )
689 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
693 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
695 IF( scaloc.NE.one )
THEN
697 CALL dscal( m, scaloc, c( 1, k ), 1 )
698 CALL dscal( m, scaloc, f( 1, k ), 1 )
703 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
704 $ rdscal, ipiv, jpiv )
711 DO 100 jj = 0, nb - 1
712 CALL dcopy( mb, rhs( k ), 1, c( is, js+jj ), 1 )
713 CALL dcopy( mb, rhs( ii ), 1, f( is, js+jj ), 1 )
722 CALL dgemm(
'N',
'N', is-1, nb, mb, -one,
723 $ a( 1, is ), lda, rhs( 1 ), mb, one,
725 CALL dgemm(
'N',
'N', is-1, nb, mb, -one,
726 $ d( 1, is ), ldd, rhs( 1 ), mb, one,
731 CALL dgemm(
'N',
'N', mb, n-je, nb, one, rhs( k ),
732 $ mb, b( js, je+1 ), ldb, one,
733 $ c( is, je+1 ), ldc )
734 CALL dgemm(
'N',
'N', mb, n-je, nb, one, rhs( k ),
735 $ mb, e( js, je+1 ), lde, one,
736 $ f( is, je+1 ), ldf )
756 ie = iwork( i+1 ) - 1
758 DO 190 j = q, p + 2, -1
762 je = iwork( j+1 ) - 1
765 IF( ( mb.EQ.1 ) .AND. ( nb.EQ.1 ) )
THEN
769 z( 1, 1 ) = a( is, is )
770 z( 2, 1 ) = -b( js, js )
771 z( 1, 2 ) = d( is, is )
772 z( 2, 2 ) = -e( js, js )
776 rhs( 1 ) = c( is, js )
777 rhs( 2 ) = f( is, js )
781 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
785 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv, scaloc )
786 IF( scaloc.NE.one )
THEN
788 CALL dscal( m, scaloc, c( 1, k ), 1 )
789 CALL dscal( m, scaloc, f( 1, k ), 1 )
796 c( is, js ) = rhs( 1 )
797 f( is, js ) = rhs( 2 )
804 CALL daxpy( js-1, alpha, b( 1, js ), 1, f( is, 1 ),
807 CALL daxpy( js-1, alpha, e( 1, js ), 1, f( is, 1 ),
812 CALL daxpy( m-ie, alpha, a( is, ie+1 ), lda,
815 CALL daxpy( m-ie, alpha, d( is, ie+1 ), ldd,
819 ELSE IF( ( mb.EQ.1 ) .AND. ( nb.EQ.2 ) )
THEN
823 z( 1, 1 ) = a( is, is )
825 z( 3, 1 ) = -b( js, js )
826 z( 4, 1 ) = -b( jsp1, js )
829 z( 2, 2 ) = a( is, is )
830 z( 3, 2 ) = -b( js, jsp1 )
831 z( 4, 2 ) = -b( jsp1, jsp1 )
833 z( 1, 3 ) = d( is, is )
835 z( 3, 3 ) = -e( js, js )
839 z( 2, 4 ) = d( is, is )
840 z( 3, 4 ) = -e( js, jsp1 )
841 z( 4, 4 ) = -e( jsp1, jsp1 )
845 rhs( 1 ) = c( is, js )
846 rhs( 2 ) = c( is, jsp1 )
847 rhs( 3 ) = f( is, js )
848 rhs( 4 ) = f( is, jsp1 )
852 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
855 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv, scaloc )
856 IF( scaloc.NE.one )
THEN
858 CALL dscal( m, scaloc, c( 1, k ), 1 )
859 CALL dscal( m, scaloc, f( 1, k ), 1 )
866 c( is, js ) = rhs( 1 )
867 c( is, jsp1 ) = rhs( 2 )
868 f( is, js ) = rhs( 3 )
869 f( is, jsp1 ) = rhs( 4 )
875 CALL daxpy( js-1, rhs( 1 ), b( 1, js ), 1,
877 CALL daxpy( js-1, rhs( 2 ), b( 1, jsp1 ), 1,
879 CALL daxpy( js-1, rhs( 3 ), e( 1, js ), 1,
881 CALL daxpy( js-1, rhs( 4 ), e( 1, jsp1 ), 1,
885 CALL dger( m-ie, nb, -one, a( is, ie+1 ), lda,
886 $ rhs( 1 ), 1, c( ie+1, js ), ldc )
887 CALL dger( m-ie, nb, -one, d( is, ie+1 ), ldd,
888 $ rhs( 3 ), 1, c( ie+1, js ), ldc )
891 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.1 ) )
THEN
895 z( 1, 1 ) = a( is, is )
896 z( 2, 1 ) = a( is, isp1 )
897 z( 3, 1 ) = -b( js, js )
900 z( 1, 2 ) = a( isp1, is )
901 z( 2, 2 ) = a( isp1, isp1 )
903 z( 4, 2 ) = -b( js, js )
905 z( 1, 3 ) = d( is, is )
906 z( 2, 3 ) = d( is, isp1 )
907 z( 3, 3 ) = -e( js, js )
911 z( 2, 4 ) = d( isp1, isp1 )
913 z( 4, 4 ) = -e( js, js )
917 rhs( 1 ) = c( is, js )
918 rhs( 2 ) = c( isp1, js )
919 rhs( 3 ) = f( is, js )
920 rhs( 4 ) = f( isp1, js )
924 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
928 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv, scaloc )
929 IF( scaloc.NE.one )
THEN
931 CALL dscal( m, scaloc, c( 1, k ), 1 )
932 CALL dscal( m, scaloc, f( 1, k ), 1 )
939 c( is, js ) = rhs( 1 )
940 c( isp1, js ) = rhs( 2 )
941 f( is, js ) = rhs( 3 )
942 f( isp1, js ) = rhs( 4 )
948 CALL dger( mb, js-1, one, rhs( 1 ), 1, b( 1, js ),
949 $ 1, f( is, 1 ), ldf )
950 CALL dger( mb, js-1, one, rhs( 3 ), 1, e( 1, js ),
951 $ 1, f( is, 1 ), ldf )
954 CALL dgemv(
'T', mb, m-ie, -one, a( is, ie+1 ),
955 $ lda, rhs( 1 ), 1, one, c( ie+1, js ),
957 CALL dgemv(
'T', mb, m-ie, -one, d( is, ie+1 ),
958 $ ldd, rhs( 3 ), 1, one, c( ie+1, js ),
962 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.2 ) )
THEN
966 CALL dlaset(
'F', ldz, ldz, zero, zero, z, ldz )
968 z( 1, 1 ) = a( is, is )
969 z( 2, 1 ) = a( is, isp1 )
970 z( 5, 1 ) = -b( js, js )
971 z( 7, 1 ) = -b( jsp1, js )
973 z( 1, 2 ) = a( isp1, is )
974 z( 2, 2 ) = a( isp1, isp1 )
975 z( 6, 2 ) = -b( js, js )
976 z( 8, 2 ) = -b( jsp1, js )
978 z( 3, 3 ) = a( is, is )
979 z( 4, 3 ) = a( is, isp1 )
980 z( 5, 3 ) = -b( js, jsp1 )
981 z( 7, 3 ) = -b( jsp1, jsp1 )
983 z( 3, 4 ) = a( isp1, is )
984 z( 4, 4 ) = a( isp1, isp1 )
985 z( 6, 4 ) = -b( js, jsp1 )
986 z( 8, 4 ) = -b( jsp1, jsp1 )
988 z( 1, 5 ) = d( is, is )
989 z( 2, 5 ) = d( is, isp1 )
990 z( 5, 5 ) = -e( js, js )
992 z( 2, 6 ) = d( isp1, isp1 )
993 z( 6, 6 ) = -e( js, js )
995 z( 3, 7 ) = d( is, is )
996 z( 4, 7 ) = d( is, isp1 )
997 z( 5, 7 ) = -e( js, jsp1 )
998 z( 7, 7 ) = -e( jsp1, jsp1 )
1000 z( 4, 8 ) = d( isp1, isp1 )
1001 z( 6, 8 ) = -e( js, jsp1 )
1002 z( 8, 8 ) = -e( jsp1, jsp1 )
1008 DO 160 jj = 0, nb - 1
1009 CALL dcopy( mb, c( is, js+jj ), 1, rhs( k ), 1 )
1010 CALL dcopy( mb, f( is, js+jj ), 1, rhs( ii ), 1 )
1018 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
1022 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv, scaloc )
1023 IF( scaloc.NE.one )
THEN
1025 CALL dscal( m, scaloc, c( 1, k ), 1 )
1026 CALL dscal( m, scaloc, f( 1, k ), 1 )
1028 scale = scale*scaloc
1035 DO 180 jj = 0, nb - 1
1036 CALL dcopy( mb, rhs( k ), 1, c( is, js+jj ), 1 )
1037 CALL dcopy( mb, rhs( ii ), 1, f( is, js+jj ), 1 )
1046 CALL dgemm(
'N',
'T', mb, js-1, nb, one,
1047 $ c( is, js ), ldc, b( 1, js ), ldb, one,
1049 CALL dgemm(
'N',
'T', mb, js-1, nb, one,
1050 $ f( is, js ), ldf, e( 1, js ), lde, one,
1054 CALL dgemm(
'T',
'N', m-ie, nb, mb, -one,
1055 $ a( is, ie+1 ), lda, c( is, js ), ldc,
1056 $ one, c( ie+1, js ), ldc )
1057 CALL dgemm(
'T',
'N', m-ie, nb, mb, -one,
1058 $ d( is, ie+1 ), ldd, f( is, js ), ldf,
1059 $ one, c( ie+1, js ), ldc )
subroutine xerbla(srname, info)
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
subroutine dgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
DGEMM
subroutine dgemv(trans, m, n, alpha, a, lda, x, incx, beta, y, incy)
DGEMV
subroutine dger(m, n, alpha, x, incx, y, incy, a, lda)
DGER
subroutine dgesc2(n, a, lda, rhs, ipiv, jpiv, scale)
DGESC2 solves a system of linear equations using the LU factorization with complete pivoting computed...
subroutine dgetc2(n, a, lda, ipiv, jpiv, info)
DGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
subroutine dlatdf(ijob, n, z, ldz, rhs, rdsum, rdscal, ipiv, jpiv)
DLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contribution ...
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dtgsy2(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, rdsum, rdscal, iwork, pq, info)
DTGSY2 solves the generalized Sylvester equation (unblocked algorithm).