269 SUBROUTINE dtgsy2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC,
271 $ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
280 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N,
282 DOUBLE PRECISION RDSCAL, RDSUM, SCALE
286 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), C( LDC, * ),
287 $ D( LDD, * ), E( LDE, * ), F( LDF, * )
296 PARAMETER ( LDZ = 8 )
297 double precision zero, one
298 parameter( zero = 0.0d+0, one = 1.0d+0 )
302 INTEGER I, IE, IERR, II, IS, ISP1, J, JE, JJ, JS, JSP1,
303 $ K, MB, NB, P, Q, ZDIM
304 DOUBLE PRECISION ALPHA, SCALOC
307 INTEGER IPIV( LDZ ), JPIV( LDZ )
308 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,
472 CALL daxpy( is-1, alpha, d( 1, is ), 1, f( 1,
477 CALL daxpy( n-je, rhs( 2 ), b( js, je+1 ), ldb,
478 $ c( is, je+1 ), ldc )
479 CALL daxpy( n-je, rhs( 2 ), e( js, je+1 ), lde,
480 $ f( is, je+1 ), ldf )
483 ELSE IF( ( mb.EQ.1 ) .AND. ( nb.EQ.2 ) )
THEN
487 z( 1, 1 ) = a( is, is )
489 z( 3, 1 ) = d( is, is )
493 z( 2, 2 ) = a( is, is )
495 z( 4, 2 ) = d( is, is )
497 z( 1, 3 ) = -b( js, js )
498 z( 2, 3 ) = -b( js, jsp1 )
499 z( 3, 3 ) = -e( js, js )
500 z( 4, 3 ) = -e( js, jsp1 )
502 z( 1, 4 ) = -b( jsp1, js )
503 z( 2, 4 ) = -b( jsp1, jsp1 )
505 z( 4, 4 ) = -e( jsp1, jsp1 )
509 rhs( 1 ) = c( is, js )
510 rhs( 2 ) = c( is, jsp1 )
511 rhs( 3 ) = f( is, js )
512 rhs( 4 ) = f( is, jsp1 )
516 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
521 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
523 IF( scaloc.NE.one )
THEN
525 CALL dscal( m, scaloc, c( 1, k ), 1 )
526 CALL dscal( m, scaloc, f( 1, k ), 1 )
531 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
532 $ rdscal, ipiv, jpiv )
537 c( is, js ) = rhs( 1 )
538 c( is, jsp1 ) = rhs( 2 )
539 f( is, js ) = rhs( 3 )
540 f( is, jsp1 ) = rhs( 4 )
546 CALL dger( is-1, nb, -one, a( 1, is ), 1,
548 $ 1, c( 1, js ), ldc )
549 CALL dger( is-1, nb, -one, d( 1, is ), 1,
551 $ 1, f( 1, js ), ldf )
554 CALL daxpy( n-je, rhs( 3 ), b( js, je+1 ), ldb,
555 $ c( is, je+1 ), ldc )
556 CALL daxpy( n-je, rhs( 3 ), e( js, je+1 ), lde,
557 $ f( is, je+1 ), ldf )
558 CALL daxpy( n-je, rhs( 4 ), b( jsp1, je+1 ),
560 $ c( is, je+1 ), ldc )
561 CALL daxpy( n-je, rhs( 4 ), e( jsp1, je+1 ),
563 $ f( is, je+1 ), ldf )
566 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.1 ) )
THEN
570 z( 1, 1 ) = a( is, is )
571 z( 2, 1 ) = a( isp1, is )
572 z( 3, 1 ) = d( is, is )
575 z( 1, 2 ) = a( is, isp1 )
576 z( 2, 2 ) = a( isp1, isp1 )
577 z( 3, 2 ) = d( is, isp1 )
578 z( 4, 2 ) = d( isp1, isp1 )
580 z( 1, 3 ) = -b( js, js )
582 z( 3, 3 ) = -e( js, js )
586 z( 2, 4 ) = -b( js, js )
588 z( 4, 4 ) = -e( js, js )
592 rhs( 1 ) = c( is, js )
593 rhs( 2 ) = c( isp1, js )
594 rhs( 3 ) = f( is, js )
595 rhs( 4 ) = f( isp1, js )
599 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
603 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
605 IF( scaloc.NE.one )
THEN
607 CALL dscal( m, scaloc, c( 1, k ), 1 )
608 CALL dscal( m, scaloc, f( 1, k ), 1 )
613 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
614 $ rdscal, ipiv, jpiv )
619 c( is, js ) = rhs( 1 )
620 c( isp1, js ) = rhs( 2 )
621 f( is, js ) = rhs( 3 )
622 f( isp1, js ) = rhs( 4 )
628 CALL dgemv(
'N', is-1, mb, -one, a( 1, is ),
630 $ rhs( 1 ), 1, one, c( 1, js ), 1 )
631 CALL dgemv(
'N', is-1, mb, -one, d( 1, is ),
633 $ rhs( 1 ), 1, one, f( 1, js ), 1 )
636 CALL dger( mb, n-je, one, rhs( 3 ), 1,
637 $ b( js, je+1 ), ldb, c( is, je+1 ), ldc )
638 CALL dger( mb, n-je, one, rhs( 3 ), 1,
639 $ e( js, je+1 ), lde, f( is, je+1 ), ldf )
642 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.2 ) )
THEN
646 CALL dlaset(
'F', ldz, ldz, zero, zero, z, ldz )
648 z( 1, 1 ) = a( is, is )
649 z( 2, 1 ) = a( isp1, is )
650 z( 5, 1 ) = d( is, is )
652 z( 1, 2 ) = a( is, isp1 )
653 z( 2, 2 ) = a( isp1, isp1 )
654 z( 5, 2 ) = d( is, isp1 )
655 z( 6, 2 ) = d( isp1, isp1 )
657 z( 3, 3 ) = a( is, is )
658 z( 4, 3 ) = a( isp1, is )
659 z( 7, 3 ) = d( is, is )
661 z( 3, 4 ) = a( is, isp1 )
662 z( 4, 4 ) = a( isp1, isp1 )
663 z( 7, 4 ) = d( is, isp1 )
664 z( 8, 4 ) = d( isp1, isp1 )
666 z( 1, 5 ) = -b( js, js )
667 z( 3, 5 ) = -b( js, jsp1 )
668 z( 5, 5 ) = -e( js, js )
669 z( 7, 5 ) = -e( js, jsp1 )
671 z( 2, 6 ) = -b( js, js )
672 z( 4, 6 ) = -b( js, jsp1 )
673 z( 6, 6 ) = -e( js, js )
674 z( 8, 6 ) = -e( js, jsp1 )
676 z( 1, 7 ) = -b( jsp1, js )
677 z( 3, 7 ) = -b( jsp1, jsp1 )
678 z( 7, 7 ) = -e( jsp1, jsp1 )
680 z( 2, 8 ) = -b( jsp1, js )
681 z( 4, 8 ) = -b( jsp1, jsp1 )
682 z( 8, 8 ) = -e( jsp1, jsp1 )
689 CALL dcopy( mb, c( is, js+jj ), 1, rhs( k ), 1 )
690 CALL dcopy( mb, f( is, js+jj ), 1, rhs( ii ),
698 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
702 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
704 IF( scaloc.NE.one )
THEN
706 CALL dscal( m, scaloc, c( 1, k ), 1 )
707 CALL dscal( m, scaloc, f( 1, k ), 1 )
712 CALL dlatdf( ijob, zdim, z, ldz, rhs, rdsum,
713 $ rdscal, ipiv, jpiv )
720 DO 100 jj = 0, nb - 1
721 CALL dcopy( mb, rhs( k ), 1, c( is, js+jj ), 1 )
722 CALL dcopy( mb, rhs( ii ), 1, f( is, js+jj ),
732 CALL dgemm(
'N',
'N', is-1, nb, mb, -one,
733 $ a( 1, is ), lda, rhs( 1 ), mb, one,
735 CALL dgemm(
'N',
'N', is-1, nb, mb, -one,
736 $ d( 1, is ), ldd, rhs( 1 ), mb, one,
741 CALL dgemm(
'N',
'N', mb, n-je, nb, one,
743 $ mb, b( js, je+1 ), ldb, one,
744 $ c( is, je+1 ), ldc )
745 CALL dgemm(
'N',
'N', mb, n-je, nb, one,
747 $ mb, e( js, je+1 ), lde, one,
748 $ f( is, je+1 ), ldf )
768 ie = iwork( i+1 ) - 1
770 DO 190 j = q, p + 2, -1
774 je = iwork( j+1 ) - 1
777 IF( ( mb.EQ.1 ) .AND. ( nb.EQ.1 ) )
THEN
781 z( 1, 1 ) = a( is, is )
782 z( 2, 1 ) = -b( js, js )
783 z( 1, 2 ) = d( is, is )
784 z( 2, 2 ) = -e( js, js )
788 rhs( 1 ) = c( is, js )
789 rhs( 2 ) = f( is, js )
793 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
797 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
799 IF( scaloc.NE.one )
THEN
801 CALL dscal( m, scaloc, c( 1, k ), 1 )
802 CALL dscal( m, scaloc, f( 1, k ), 1 )
809 c( is, js ) = rhs( 1 )
810 f( is, js ) = rhs( 2 )
817 CALL daxpy( js-1, alpha, b( 1, js ), 1, f( is,
821 CALL daxpy( js-1, alpha, e( 1, js ), 1, f( is,
827 CALL daxpy( m-ie, alpha, a( is, ie+1 ), lda,
830 CALL daxpy( m-ie, alpha, d( is, ie+1 ), ldd,
834 ELSE IF( ( mb.EQ.1 ) .AND. ( nb.EQ.2 ) )
THEN
838 z( 1, 1 ) = a( is, is )
840 z( 3, 1 ) = -b( js, js )
841 z( 4, 1 ) = -b( jsp1, js )
844 z( 2, 2 ) = a( is, is )
845 z( 3, 2 ) = -b( js, jsp1 )
846 z( 4, 2 ) = -b( jsp1, jsp1 )
848 z( 1, 3 ) = d( is, is )
850 z( 3, 3 ) = -e( js, js )
854 z( 2, 4 ) = d( is, is )
855 z( 3, 4 ) = -e( js, jsp1 )
856 z( 4, 4 ) = -e( jsp1, jsp1 )
860 rhs( 1 ) = c( is, js )
861 rhs( 2 ) = c( is, jsp1 )
862 rhs( 3 ) = f( is, js )
863 rhs( 4 ) = f( is, jsp1 )
867 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
870 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
872 IF( scaloc.NE.one )
THEN
874 CALL dscal( m, scaloc, c( 1, k ), 1 )
875 CALL dscal( m, scaloc, f( 1, k ), 1 )
882 c( is, js ) = rhs( 1 )
883 c( is, jsp1 ) = rhs( 2 )
884 f( is, js ) = rhs( 3 )
885 f( is, jsp1 ) = rhs( 4 )
891 CALL daxpy( js-1, rhs( 1 ), b( 1, js ), 1,
893 CALL daxpy( js-1, rhs( 2 ), b( 1, jsp1 ), 1,
895 CALL daxpy( js-1, rhs( 3 ), e( 1, js ), 1,
897 CALL daxpy( js-1, rhs( 4 ), e( 1, jsp1 ), 1,
901 CALL dger( m-ie, nb, -one, a( is, ie+1 ), lda,
902 $ rhs( 1 ), 1, c( ie+1, js ), ldc )
903 CALL dger( m-ie, nb, -one, d( is, ie+1 ), ldd,
904 $ rhs( 3 ), 1, c( ie+1, js ), ldc )
907 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.1 ) )
THEN
911 z( 1, 1 ) = a( is, is )
912 z( 2, 1 ) = a( is, isp1 )
913 z( 3, 1 ) = -b( js, js )
916 z( 1, 2 ) = a( isp1, is )
917 z( 2, 2 ) = a( isp1, isp1 )
919 z( 4, 2 ) = -b( js, js )
921 z( 1, 3 ) = d( is, is )
922 z( 2, 3 ) = d( is, isp1 )
923 z( 3, 3 ) = -e( js, js )
927 z( 2, 4 ) = d( isp1, isp1 )
929 z( 4, 4 ) = -e( js, js )
933 rhs( 1 ) = c( is, js )
934 rhs( 2 ) = c( isp1, js )
935 rhs( 3 ) = f( is, js )
936 rhs( 4 ) = f( isp1, js )
940 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
944 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
946 IF( scaloc.NE.one )
THEN
948 CALL dscal( m, scaloc, c( 1, k ), 1 )
949 CALL dscal( m, scaloc, f( 1, k ), 1 )
956 c( is, js ) = rhs( 1 )
957 c( isp1, js ) = rhs( 2 )
958 f( is, js ) = rhs( 3 )
959 f( isp1, js ) = rhs( 4 )
965 CALL dger( mb, js-1, one, rhs( 1 ), 1, b( 1,
967 $ 1, f( is, 1 ), ldf )
968 CALL dger( mb, js-1, one, rhs( 3 ), 1, e( 1,
970 $ 1, f( is, 1 ), ldf )
973 CALL dgemv(
'T', mb, m-ie, -one, a( is, ie+1 ),
974 $ lda, rhs( 1 ), 1, one, c( ie+1, js ),
976 CALL dgemv(
'T', mb, m-ie, -one, d( is, ie+1 ),
977 $ ldd, rhs( 3 ), 1, one, c( ie+1, js ),
981 ELSE IF( ( mb.EQ.2 ) .AND. ( nb.EQ.2 ) )
THEN
985 CALL dlaset(
'F', ldz, ldz, zero, zero, z, ldz )
987 z( 1, 1 ) = a( is, is )
988 z( 2, 1 ) = a( is, isp1 )
989 z( 5, 1 ) = -b( js, js )
990 z( 7, 1 ) = -b( jsp1, js )
992 z( 1, 2 ) = a( isp1, is )
993 z( 2, 2 ) = a( isp1, isp1 )
994 z( 6, 2 ) = -b( js, js )
995 z( 8, 2 ) = -b( jsp1, js )
997 z( 3, 3 ) = a( is, is )
998 z( 4, 3 ) = a( is, isp1 )
999 z( 5, 3 ) = -b( js, jsp1 )
1000 z( 7, 3 ) = -b( jsp1, jsp1 )
1002 z( 3, 4 ) = a( isp1, is )
1003 z( 4, 4 ) = a( isp1, isp1 )
1004 z( 6, 4 ) = -b( js, jsp1 )
1005 z( 8, 4 ) = -b( jsp1, jsp1 )
1007 z( 1, 5 ) = d( is, is )
1008 z( 2, 5 ) = d( is, isp1 )
1009 z( 5, 5 ) = -e( js, js )
1011 z( 2, 6 ) = d( isp1, isp1 )
1012 z( 6, 6 ) = -e( js, js )
1014 z( 3, 7 ) = d( is, is )
1015 z( 4, 7 ) = d( is, isp1 )
1016 z( 5, 7 ) = -e( js, jsp1 )
1017 z( 7, 7 ) = -e( jsp1, jsp1 )
1019 z( 4, 8 ) = d( isp1, isp1 )
1020 z( 6, 8 ) = -e( js, jsp1 )
1021 z( 8, 8 ) = -e( jsp1, jsp1 )
1027 DO 160 jj = 0, nb - 1
1028 CALL dcopy( mb, c( is, js+jj ), 1, rhs( k ), 1 )
1029 CALL dcopy( mb, f( is, js+jj ), 1, rhs( ii ),
1038 CALL dgetc2( zdim, z, ldz, ipiv, jpiv, ierr )
1042 CALL dgesc2( zdim, z, ldz, rhs, ipiv, jpiv,
1044 IF( scaloc.NE.one )
THEN
1046 CALL dscal( m, scaloc, c( 1, k ), 1 )
1047 CALL dscal( m, scaloc, f( 1, k ), 1 )
1049 scale = scale*scaloc
1056 DO 180 jj = 0, nb - 1
1057 CALL dcopy( mb, rhs( k ), 1, c( is, js+jj ), 1 )
1058 CALL dcopy( mb, rhs( ii ), 1, f( is, js+jj ),
1068 CALL dgemm(
'N',
'T', mb, js-1, nb, one,
1069 $ c( is, js ), ldc, b( 1, js ), ldb, one,
1071 CALL dgemm(
'N',
'T', mb, js-1, nb, one,
1072 $ f( is, js ), ldf, e( 1, js ), lde, one,
1076 CALL dgemm(
'T',
'N', m-ie, nb, mb, -one,
1077 $ a( is, ie+1 ), lda, c( is, js ), ldc,
1078 $ one, c( ie+1, js ), ldc )
1079 CALL dgemm(
'T',
'N', m-ie, nb, mb, -one,
1080 $ d( is, ie+1 ), ldd, f( is, js ), ldf,
1081 $ one, c( ie+1, js ), ldc )