155 SUBROUTINE ztrsyl3( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,
156 $ LDC, SCALE, SWORK, LDSWORK, INFO )
160 CHARACTER TRANA, TRANB
161 INTEGER INFO, ISGN, LDA, LDB, LDC, LDSWORK, M, N
162 DOUBLE PRECISION SCALE
165 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )
166 DOUBLE PRECISION SWORK( LDSWORK, * )
169 DOUBLE PRECISION ZERO, ONE
170 parameter( zero = 0.0d0, one = 1.0d0 )
172 parameter( cone = ( 1.0d0, 0.0d0 ) )
175 LOGICAL NOTRNA, NOTRNB, LQUERY
176 INTEGER AWRK, BWRK, I, I1, I2, IINFO, J, J1, J2, JJ,
177 $ k, k1, k2, l, l1, l2, ll, nba, nb, nbb
178 DOUBLE PRECISION ANRM, BIGNUM, BNRM, CNRM, SCAL, SCALOC,
179 $ scamin, sgn, xnrm, buf, smlnum
183 DOUBLE PRECISION WNRM( MAX( M, N ) )
188 DOUBLE PRECISION DLAMCH, DLARMM, ZLANGE
189 EXTERNAL dlamch, dlarmm, ilaenv, lsame, zlange
195 INTRINSIC abs, dble, dimag, exponent, max, min
201 notrna = lsame( trana,
'N' )
202 notrnb = lsame( tranb,
'N' )
206 nb = max( 8, ilaenv( 1,
'ZTRSYL',
'', m, n, -1, -1) )
210 nba = max( 1, (m + nb - 1) / nb )
211 nbb = max( 1, (n + nb - 1) / nb )
216 lquery = ( ldswork.EQ.-1 )
219 swork(1,1) = max( nba, nbb )
220 swork(2,1) = 2 * nbb + nba
225 IF( .NOT.notrna .AND. .NOT. lsame( trana,
'C' ) )
THEN
227 ELSE IF( .NOT.notrnb .AND. .NOT. lsame( tranb,
'C' ) )
THEN
229 ELSE IF( isgn.NE.1 .AND. isgn.NE.-1 )
THEN
231 ELSE IF( m.LT.0 )
THEN
233 ELSE IF( n.LT.0 )
THEN
235 ELSE IF( lda.LT.max( 1, m ) )
THEN
237 ELSE IF( ldb.LT.max( 1, n ) )
THEN
239 ELSE IF( ldc.LT.max( 1, m ) )
THEN
243 CALL xerbla(
'ZTRSYL3', -info )
245 ELSE IF( lquery )
THEN
252 IF( m.EQ.0 .OR. n.EQ.0 )
258 IF( min( nba, nbb ).EQ.1 .OR. ldswork.LT.max( nba, nbb ) )
THEN
259 CALL ztrsyl( trana, tranb, isgn, m, n, a, lda, b, ldb,
260 $ c, ldc, scale, info )
266 smlnum = dlamch(
'S' )
267 bignum = one / smlnum
286 k1 = (k - 1) * nb + 1
287 k2 = min( k * nb, m ) + 1
289 l1 = (l - 1) * nb + 1
290 l2 = min( l * nb, m ) + 1
292 swork( k, awrk + l ) = zlange(
'I', k2-k1, l2-l1,
293 $ a( k1, l1 ), lda, wnrm )
295 swork( l, awrk + k ) = zlange(
'1', k2-k1, l2-l1,
296 $ a( k1, l1 ), lda, wnrm )
302 k1 = (k - 1) * nb + 1
303 k2 = min( k * nb, n ) + 1
305 l1 = (l - 1) * nb + 1
306 l2 = min( l * nb, n ) + 1
308 swork( k, bwrk + l ) = zlange(
'I', k2-k1, l2-l1,
309 $ b( k1, l1 ), ldb, wnrm )
311 swork( l, bwrk + k ) = zlange(
'1', k2-k1, l2-l1,
312 $ b( k1, l1 ), ldb, wnrm )
318 csgn = dcmplx( sgn, zero )
320 IF( notrna .AND. notrnb )
THEN
342 k1 = (k - 1) * nb + 1
343 k2 = min( k * nb, m ) + 1
350 l1 = (l - 1) * nb + 1
351 l2 = min( l * nb, n ) + 1
353 CALL ztrsyl( trana, tranb, isgn, k2-k1, l2-l1,
356 $ c( k1, l1 ), ldc, scaloc, iinfo )
357 info = max( info, iinfo )
359 IF( scaloc * swork( k, l ) .EQ. zero )
THEN
360 IF( scaloc .EQ. zero )
THEN
367 buf = buf*2.d0**exponent( scaloc )
374 swork( ll, jj ) = min( bignum,
375 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
379 swork( k, l ) = scaloc * swork( k, l )
380 xnrm = zlange(
'I', k2-k1, l2-l1, c( k1, l1 ), ldc,
387 i1 = (i - 1) * nb + 1
388 i2 = min( i * nb, m ) + 1
393 cnrm = zlange(
'I', i2-i1, l2-l1, c( i1, l1 ),
395 scamin = min( swork( i, l ), swork( k, l ) )
396 cnrm = cnrm * ( scamin / swork( i, l ) )
397 xnrm = xnrm * ( scamin / swork( k, l ) )
398 anrm = swork( i, awrk + k )
399 scaloc = dlarmm( anrm, xnrm, cnrm )
400 IF( scaloc * scamin .EQ. zero )
THEN
402 buf = buf*2.d0**exponent( scaloc )
405 swork( ll, jj ) = min( bignum,
406 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
409 scamin = scamin / 2.d0**exponent( scaloc )
410 scaloc = scaloc / 2.d0**exponent( scaloc )
418 scal = ( scamin / swork( k, l ) ) * scaloc
419 IF( scal .NE. one )
THEN
421 CALL zdscal( k2-k1, scal, c( k1, jj ), 1)
425 scal = ( scamin / swork( i, l ) ) * scaloc
426 IF( scal .NE. one )
THEN
428 CALL zdscal( i2-i1, scal, c( i1, ll ), 1)
434 swork( k, l ) = scamin * scaloc
435 swork( i, l ) = scamin * scaloc
437 CALL zgemm(
'N',
'N', i2-i1, l2-l1, k2-k1, -cone,
438 $ a( i1, k1 ), lda, c( k1, l1 ), ldc,
439 $ cone, c( i1, l1 ), ldc )
447 j1 = (j - 1) * nb + 1
448 j2 = min( j * nb, n ) + 1
453 cnrm = zlange(
'I', k2-k1, j2-j1, c( k1, j1 ),
455 scamin = min( swork( k, j ), swork( k, l ) )
456 cnrm = cnrm * ( scamin / swork( k, j ) )
457 xnrm = xnrm * ( scamin / swork( k, l ) )
458 bnrm = swork(l, bwrk + j)
459 scaloc = dlarmm( bnrm, xnrm, cnrm )
460 IF( scaloc * scamin .EQ. zero )
THEN
462 buf = buf*2.d0**exponent( scaloc )
465 swork( ll, jj ) = min( bignum,
466 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
469 scamin = scamin / 2.d0**exponent( scaloc )
470 scaloc = scaloc / 2.d0**exponent( scaloc )
478 scal = ( scamin / swork( k, l ) ) * scaloc
479 IF( scal .NE. one )
THEN
481 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
485 scal = ( scamin / swork( k, j ) ) * scaloc
486 IF( scal .NE. one )
THEN
488 CALL zdscal( k2-k1, scal, c( k1, jj ), 1 )
494 swork( k, l ) = scamin * scaloc
495 swork( k, j ) = scamin * scaloc
497 CALL zgemm(
'N',
'N', k2-k1, j2-j1, l2-l1, -csgn,
498 $ c( k1, l1 ), ldc, b( l1, j1 ), ldb,
499 $ cone, c( k1, j1 ), ldc )
503 ELSE IF( .NOT.notrna .AND. notrnb )
THEN
525 k1 = (k - 1) * nb + 1
526 k2 = min( k * nb, m ) + 1
533 l1 = (l - 1) * nb + 1
534 l2 = min( l * nb, n ) + 1
536 CALL ztrsyl( trana, tranb, isgn, k2-k1, l2-l1,
539 $ c( k1, l1 ), ldc, scaloc, iinfo )
540 info = max( info, iinfo )
542 IF( scaloc * swork( k, l ) .EQ. zero )
THEN
543 IF( scaloc .EQ. zero )
THEN
551 buf = buf*2.d0**exponent( scaloc )
558 swork( ll, jj ) = min( bignum,
559 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
563 swork( k, l ) = scaloc * swork( k, l )
564 xnrm = zlange(
'I', k2-k1, l2-l1, c( k1, l1 ), ldc,
571 i1 = (i - 1) * nb + 1
572 i2 = min( i * nb, m ) + 1
577 cnrm = zlange(
'I', i2-i1, l2-l1, c( i1, l1 ),
579 scamin = min( swork( i, l ), swork( k, l ) )
580 cnrm = cnrm * ( scamin / swork( i, l ) )
581 xnrm = xnrm * ( scamin / swork( k, l ) )
582 anrm = swork( i, awrk + k )
583 scaloc = dlarmm( anrm, xnrm, cnrm )
584 IF( scaloc * scamin .EQ. zero )
THEN
586 buf = buf*2.d0**exponent( scaloc )
589 swork( ll, jj ) = min( bignum,
590 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
593 scamin = scamin / 2.d0**exponent( scaloc )
594 scaloc = scaloc / 2.d0**exponent( scaloc )
602 scal = ( scamin / swork( k, l ) ) * scaloc
603 IF( scal .NE. one )
THEN
605 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
609 scal = ( scamin / swork( i, l ) ) * scaloc
610 IF( scal .NE. one )
THEN
612 CALL zdscal( i2-i1, scal, c( i1, ll ), 1 )
618 swork( k, l ) = scamin * scaloc
619 swork( i, l ) = scamin * scaloc
621 CALL zgemm(
'C',
'N', i2-i1, l2-l1, k2-k1, -cone,
622 $ a( k1, i1 ), lda, c( k1, l1 ), ldc,
623 $ cone, c( i1, l1 ), ldc )
630 j1 = (j - 1) * nb + 1
631 j2 = min( j * nb, n ) + 1
636 cnrm = zlange(
'I', k2-k1, j2-j1, c( k1, j1 ),
638 scamin = min( swork( k, j ), swork( k, l ) )
639 cnrm = cnrm * ( scamin / swork( k, j ) )
640 xnrm = xnrm * ( scamin / swork( k, l ) )
641 bnrm = swork( l, bwrk + j )
642 scaloc = dlarmm( bnrm, xnrm, cnrm )
643 IF( scaloc * scamin .EQ. zero )
THEN
645 buf = buf*2.d0**exponent( scaloc )
648 swork( ll, jj ) = min( bignum,
649 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
652 scamin = scamin / 2.d0**exponent( scaloc )
653 scaloc = scaloc / 2.d0**exponent( scaloc )
661 scal = ( scamin / swork( k, l ) ) * scaloc
662 IF( scal .NE. one )
THEN
664 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
668 scal = ( scamin / swork( k, j ) ) * scaloc
669 IF( scal .NE. one )
THEN
671 CALL zdscal( k2-k1, scal, c( k1, jj ), 1 )
677 swork( k, l ) = scamin * scaloc
678 swork( k, j ) = scamin * scaloc
680 CALL zgemm(
'N',
'N', k2-k1, j2-j1, l2-l1, -csgn,
681 $ c( k1, l1 ), ldc, b( l1, j1 ), ldb,
682 $ cone, c( k1, j1 ), ldc )
686 ELSE IF( .NOT.notrna .AND. .NOT.notrnb )
THEN
708 k1 = (k - 1) * nb + 1
709 k2 = min( k * nb, m ) + 1
716 l1 = (l - 1) * nb + 1
717 l2 = min( l * nb, n ) + 1
719 CALL ztrsyl( trana, tranb, isgn, k2-k1, l2-l1,
722 $ c( k1, l1 ), ldc, scaloc, iinfo )
723 info = max( info, iinfo )
725 IF( scaloc * swork( k, l ) .EQ. zero )
THEN
726 IF( scaloc .EQ. zero )
THEN
734 buf = buf*2.d0**exponent( scaloc )
741 swork( ll, jj ) = min( bignum,
742 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
746 swork( k, l ) = scaloc * swork( k, l )
747 xnrm = zlange(
'I', k2-k1, l2-l1, c( k1, l1 ), ldc,
754 i1 = (i - 1) * nb + 1
755 i2 = min( i * nb, m ) + 1
760 cnrm = zlange(
'I', i2-i1, l2-l1, c( i1, l1 ),
762 scamin = min( swork( i, l ), swork( k, l ) )
763 cnrm = cnrm * ( scamin / swork( i, l ) )
764 xnrm = xnrm * ( scamin / swork( k, l ) )
765 anrm = swork( i, awrk + k )
766 scaloc = dlarmm( anrm, xnrm, cnrm )
767 IF( scaloc * scamin .EQ. zero )
THEN
769 buf = buf*2.d0**exponent( scaloc )
772 swork( ll, jj ) = min( bignum,
773 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
776 scamin = scamin / 2.d0**exponent( scaloc )
777 scaloc = scaloc / 2.d0**exponent( scaloc )
785 scal = ( scamin / swork( k, l ) ) * scaloc
786 IF( scal .NE. one )
THEN
788 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
792 scal = ( scamin / swork( i, l ) ) * scaloc
793 IF( scal .NE. one )
THEN
795 CALL zdscal( i2-i1, scal, c( i1, ll ), 1 )
801 swork( k, l ) = scamin * scaloc
802 swork( i, l ) = scamin * scaloc
804 CALL zgemm(
'C',
'N', i2-i1, l2-l1, k2-k1, -cone,
805 $ a( k1, i1 ), lda, c( k1, l1 ), ldc,
806 $ cone, c( i1, l1 ), ldc )
813 j1 = (j - 1) * nb + 1
814 j2 = min( j * nb, n ) + 1
819 cnrm = zlange(
'I', k2-k1, j2-j1, c( k1, j1 ),
821 scamin = min( swork( k, j ), swork( k, l ) )
822 cnrm = cnrm * ( scamin / swork( k, j ) )
823 xnrm = xnrm * ( scamin / swork( k, l ) )
824 bnrm = swork( l, bwrk + j )
825 scaloc = dlarmm( bnrm, xnrm, cnrm )
826 IF( scaloc * scamin .EQ. zero )
THEN
828 buf = buf*2.d0**exponent( scaloc )
831 swork( ll, jj ) = min( bignum,
832 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
835 scamin = scamin / 2.d0**exponent( scaloc )
836 scaloc = scaloc / 2.d0**exponent( scaloc )
844 scal = ( scamin / swork( k, l ) ) * scaloc
845 IF( scal .NE. one )
THEN
847 CALL zdscal( k2-k1, scal, c( k1, ll ), 1)
851 scal = ( scamin / swork( k, j ) ) * scaloc
852 IF( scal .NE. one )
THEN
854 CALL zdscal( k2-k1, scal, c( k1, jj ), 1 )
860 swork( k, l ) = scamin * scaloc
861 swork( k, j ) = scamin * scaloc
863 CALL zgemm(
'N',
'C', k2-k1, j2-j1, l2-l1, -csgn,
864 $ c( k1, l1 ), ldc, b( j1, l1 ), ldb,
865 $ cone, c( k1, j1 ), ldc )
869 ELSE IF( notrna .AND. .NOT.notrnb )
THEN
891 k1 = (k - 1) * nb + 1
892 k2 = min( k * nb, m ) + 1
899 l1 = (l - 1) * nb + 1
900 l2 = min( l * nb, n ) + 1
902 CALL ztrsyl( trana, tranb, isgn, k2-k1, l2-l1,
905 $ c( k1, l1 ), ldc, scaloc, iinfo )
906 info = max( info, iinfo )
908 IF( scaloc * swork( k, l ) .EQ. zero )
THEN
909 IF( scaloc .EQ. zero )
THEN
917 buf = buf*2.d0**exponent( scaloc )
924 swork( ll, jj ) = min( bignum,
925 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
929 swork( k, l ) = scaloc * swork( k, l )
930 xnrm = zlange(
'I', k2-k1, l2-l1, c( k1, l1 ), ldc,
937 i1 = (i - 1) * nb + 1
938 i2 = min( i * nb, m ) + 1
943 cnrm = zlange(
'I', i2-i1, l2-l1, c( i1, l1 ),
945 scamin = min( swork( i, l ), swork( k, l ) )
946 cnrm = cnrm * ( scamin / swork( i, l ) )
947 xnrm = xnrm * ( scamin / swork( k, l ) )
948 anrm = swork( i, awrk + k )
949 scaloc = dlarmm( anrm, xnrm, cnrm )
950 IF( scaloc * scamin .EQ. zero )
THEN
952 buf = buf*2.d0**exponent( scaloc )
955 swork( ll, jj ) = min( bignum,
956 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
959 scamin = scamin / 2.d0**exponent( scaloc )
960 scaloc = scaloc / 2.d0**exponent( scaloc )
968 scal = ( scamin / swork( k, l ) ) * scaloc
969 IF( scal .NE. one )
THEN
971 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
975 scal = ( scamin / swork( i, l ) ) * scaloc
976 IF( scal .NE. one )
THEN
978 CALL zdscal( i2-i1, scal, c( i1, ll ), 1 )
984 swork( k, l ) = scamin * scaloc
985 swork( i, l ) = scamin * scaloc
987 CALL zgemm(
'N',
'N', i2-i1, l2-l1, k2-k1, -cone,
988 $ a( i1, k1 ), lda, c( k1, l1 ), ldc,
989 $ cone, c( i1, l1 ), ldc )
997 j1 = (j - 1) * nb + 1
998 j2 = min( j * nb, n ) + 1
1003 cnrm = zlange(
'I', k2-k1, j2-j1, c( k1, j1 ),
1005 scamin = min( swork( k, j ), swork( k, l ) )
1006 cnrm = cnrm * ( scamin / swork( k, j ) )
1007 xnrm = xnrm * ( scamin / swork( k, l ) )
1008 bnrm = swork( l, bwrk + j )
1009 scaloc = dlarmm( bnrm, xnrm, cnrm )
1010 IF( scaloc * scamin .EQ. zero )
THEN
1012 buf = buf*2.d0**exponent( scaloc )
1015 swork( ll, jj ) = min( bignum,
1016 $ swork( ll, jj ) / 2.d0**exponent( scaloc ) )
1019 scamin = scamin / 2.d0**exponent( scaloc )
1020 scaloc = scaloc / 2.d0**exponent( scaloc )
1022 cnrm = cnrm * scaloc
1023 xnrm = xnrm * scaloc
1028 scal = ( scamin / swork( k, l ) ) * scaloc
1029 IF( scal .NE. one )
THEN
1031 CALL zdscal( k2-k1, scal, c( k1, jj ), 1 )
1035 scal = ( scamin / swork( k, j ) ) * scaloc
1036 IF( scal .NE. one )
THEN
1038 CALL zdscal( k2-k1, scal, c( k1, jj ), 1 )
1044 swork( k, l ) = scamin * scaloc
1045 swork( k, j ) = scamin * scaloc
1047 CALL zgemm(
'N',
'C', k2-k1, j2-j1, l2-l1, -csgn,
1048 $ c( k1, l1 ), ldc, b( j1, l1 ), ldb,
1049 $ cone, c( k1, j1 ), ldc )
1058 scale = swork( 1, 1 )
1061 scale = min( scale, swork( k, l ) )
1064 IF( scale .EQ. zero )
THEN
1071 swork(1,1) = max( nba, nbb )
1072 swork(2,1) = 2 * nbb + nba
1079 k1 = (k - 1) * nb + 1
1080 k2 = min( k * nb, m ) + 1
1082 l1 = (l - 1) * nb + 1
1083 l2 = min( l * nb, n ) + 1
1084 scal = scale / swork( k, l )
1085 IF( scal .NE. one )
THEN
1087 CALL zdscal( k2-k1, scal, c( k1, ll ), 1 )
1093 IF( buf .NE. one .AND. buf.GT.zero )
THEN
1097 scaloc = min( scale / smlnum, one / buf )
1099 scale = scale / scaloc
1102 IF( buf.NE.one .AND. buf.GT.zero )
THEN
1112 scal = max( abs( dble( c( 1, 1 ) ) ),
1113 $ abs( dimag( c( 1, 1 ) ) ) )
1116 scal = max( scal, abs( dble( c( k, l ) ) ),
1117 $ abs( dimag( c( k, l ) ) ) )
1123 scaloc = min( bignum / scal, one / buf )
1125 CALL zlascl(
'G', -1, -1, one, scaloc, m, n, c, ldc, iinfo )
1135 swork(1,1) = max( nba, nbb )
1136 swork(2,1) = 2 * nbb + nba
subroutine xerbla(srname, info)
subroutine zgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
ZGEMM
subroutine zlascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
ZLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine ztrsyl3(trana, tranb, isgn, m, n, a, lda, b, ldb, c, ldc, scale, swork, ldswork, info)
ZTRSYL3
subroutine ztrsyl(trana, tranb, isgn, m, n, a, lda, b, ldb, c, ldc, scale, info)
ZTRSYL