237 SUBROUTINE zlatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
245 CHARACTER DIAG, NORMIN, TRANS, UPLO
247 DOUBLE PRECISION SCALE
250 DOUBLE PRECISION CNORM( * )
251 COMPLEX*16 A( LDA, * ), X( * )
257 DOUBLE PRECISION ZERO, HALF, ONE, TWO
258 parameter( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0,
262 LOGICAL NOTRAN, NOUNIT, UPPER
263 INTEGER I, IMAX, J, JFIRST, JINC, JLAST
264 DOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,
266 COMPLEX*16 CSUMJ, TJJS, USCAL, ZDUM
270 INTEGER IDAMAX, IZAMAX
271 DOUBLE PRECISION DLAMCH, DZASUM
272 COMPLEX*16 ZDOTC, ZDOTU, ZLADIV
273 EXTERNAL lsame, idamax, izamax, dlamch, dzasum, zdotc,
280 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
283 DOUBLE PRECISION CABS1, CABS2
286 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
287 cabs2( zdum ) = abs( dble( zdum ) / 2.d0 ) +
288 $ abs( dimag( zdum ) / 2.d0 )
293 upper = lsame( uplo,
'U' )
294 notran = lsame( trans,
'N' )
295 nounit = lsame( diag,
'N' )
299 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
301 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
302 $ lsame( trans,
'C' ) )
THEN
304 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
306 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
307 $ lsame( normin,
'N' ) )
THEN
309 ELSE IF( n.LT.0 )
THEN
311 ELSE IF( lda.LT.max( 1, n ) )
THEN
315 CALL xerbla(
'ZLATRS', -info )
327 smlnum = dlamch(
'Safe minimum' ) / dlamch(
'Precision' )
328 bignum = one / smlnum
330 IF( lsame( normin,
'N' ) )
THEN
339 cnorm( j ) = dzasum( j-1, a( 1, j ), 1 )
346 cnorm( j ) = dzasum( n-j, a( j+1, j ), 1 )
355 imax = idamax( n, cnorm, 1 )
357 IF( tmax.LE.bignum*half )
THEN
364 IF ( tmax.LE.dlamch(
'Overflow') )
THEN
366 tscal = half / ( smlnum*tmax )
367 CALL dscal( n, tscal, cnorm, 1 )
381 tmax = max( tmax, abs( dble( a( i, j ) ) ),
382 $ abs( dimag(a( i, j ) ) ) )
391 tmax = max( tmax, abs( dble( a( i, j ) ) ),
392 $ abs( dimag(a( i, j ) ) ) )
397 IF( tmax.LE.dlamch(
'Overflow') )
THEN
398 tscal = one / ( smlnum*tmax )
400 IF( cnorm( j ).LE.dlamch(
'Overflow') )
THEN
401 cnorm( j ) = cnorm( j )*tscal
409 cnorm( j ) = cnorm( j ) +
410 $ tscal * cabs2( a( i, j ) )
414 cnorm( j ) = cnorm( j ) +
415 $ tscal * cabs2( a( i, j ) )
424 CALL ztrsv( uplo, trans, diag, n, a, lda, x, 1 )
435 xmax = max( xmax, cabs2( x( j ) ) )
453 IF( tscal.NE.one )
THEN
465 grow = half / max( xbnd, smlnum )
467 DO 40 j = jfirst, jlast, jinc
477 IF( tjj.GE.smlnum )
THEN
481 xbnd = min( xbnd, min( one, tjj )*grow )
489 IF( tjj+cnorm( j ).GE.smlnum )
THEN
493 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
508 grow = min( one, half / max( xbnd, smlnum ) )
509 DO 50 j = jfirst, jlast, jinc
518 grow = grow*( one / ( one+cnorm( j ) ) )
537 IF( tscal.NE.one )
THEN
549 grow = half / max( xbnd, smlnum )
551 DO 70 j = jfirst, jlast, jinc
560 xj = one + cnorm( j )
561 grow = min( grow, xbnd / xj )
566 IF( tjj.GE.smlnum )
THEN
571 $ xbnd = xbnd*( tjj / xj )
579 grow = min( grow, xbnd )
586 grow = min( one, half / max( xbnd, smlnum ) )
587 DO 80 j = jfirst, jlast, jinc
596 xj = one + cnorm( j )
603 IF( ( grow*tscal ).GT.smlnum )
THEN
608 CALL ztrsv( uplo, trans, diag, n, a, lda, x, 1 )
613 IF( xmax.GT.bignum*half )
THEN
618 scale = ( bignum*half ) / xmax
619 CALL zdscal( n, scale, x, 1 )
629 DO 120 j = jfirst, jlast, jinc
635 tjjs = a( j, j )*tscal
642 IF( tjj.GT.smlnum )
THEN
646 IF( tjj.LT.one )
THEN
647 IF( xj.GT.tjj*bignum )
THEN
652 CALL zdscal( n, rec, x, 1 )
657 x( j ) = zladiv( x( j ), tjjs )
659 ELSE IF( tjj.GT.zero )
THEN
663 IF( xj.GT.tjj*bignum )
THEN
668 rec = ( tjj*bignum ) / xj
669 IF( cnorm( j ).GT.one )
THEN
674 rec = rec / cnorm( j )
676 CALL zdscal( n, rec, x, 1 )
680 x( j ) = zladiv( x( j ), tjjs )
702 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
707 CALL zdscal( n, rec, x, 1 )
710 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
714 CALL zdscal( n, half, x, 1 )
724 CALL zaxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
726 i = izamax( j-1, x, 1 )
727 xmax = cabs1( x( i ) )
735 CALL zaxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
737 i = j + izamax( n-j, x( j+1 ), 1 )
738 xmax = cabs1( x( i ) )
743 ELSE IF( lsame( trans,
'T' ) )
THEN
747 DO 170 j = jfirst, jlast, jinc
754 rec = one / max( xmax, one )
755 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
761 tjjs = a( j, j )*tscal
766 IF( tjj.GT.one )
THEN
770 rec = min( one, rec*tjj )
771 uscal = zladiv( uscal, tjjs )
773 IF( rec.LT.one )
THEN
774 CALL zdscal( n, rec, x, 1 )
781 IF( uscal.EQ.dcmplx( one ) )
THEN
787 csumj = zdotu( j-1, a( 1, j ), 1, x, 1 )
788 ELSE IF( j.LT.n )
THEN
789 csumj = zdotu( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
797 csumj = csumj + ( a( i, j )*uscal )*x( i )
799 ELSE IF( j.LT.n )
THEN
801 csumj = csumj + ( a( i, j )*uscal )*x( i )
806 IF( uscal.EQ.dcmplx( tscal ) )
THEN
811 x( j ) = x( j ) - csumj
814 tjjs = a( j, j )*tscal
824 IF( tjj.GT.smlnum )
THEN
828 IF( tjj.LT.one )
THEN
829 IF( xj.GT.tjj*bignum )
THEN
834 CALL zdscal( n, rec, x, 1 )
839 x( j ) = zladiv( x( j ), tjjs )
840 ELSE IF( tjj.GT.zero )
THEN
844 IF( xj.GT.tjj*bignum )
THEN
848 rec = ( tjj*bignum ) / xj
849 CALL zdscal( n, rec, x, 1 )
853 x( j ) = zladiv( x( j ), tjjs )
872 x( j ) = zladiv( x( j ), tjjs ) - csumj
874 xmax = max( xmax, cabs1( x( j ) ) )
881 DO 220 j = jfirst, jlast, jinc
888 rec = one / max( xmax, one )
889 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
895 tjjs = dconjg( a( j, j ) )*tscal
900 IF( tjj.GT.one )
THEN
904 rec = min( one, rec*tjj )
905 uscal = zladiv( uscal, tjjs )
907 IF( rec.LT.one )
THEN
908 CALL zdscal( n, rec, x, 1 )
915 IF( uscal.EQ.dcmplx( one ) )
THEN
921 csumj = zdotc( j-1, a( 1, j ), 1, x, 1 )
922 ELSE IF( j.LT.n )
THEN
923 csumj = zdotc( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
931 csumj = csumj + ( dconjg( a( i, j ) )*uscal )*
934 ELSE IF( j.LT.n )
THEN
936 csumj = csumj + ( dconjg( a( i, j ) )*uscal )*
942 IF( uscal.EQ.dcmplx( tscal ) )
THEN
947 x( j ) = x( j ) - csumj
950 tjjs = dconjg( a( j, j ) )*tscal
960 IF( tjj.GT.smlnum )
THEN
964 IF( tjj.LT.one )
THEN
965 IF( xj.GT.tjj*bignum )
THEN
970 CALL zdscal( n, rec, x, 1 )
975 x( j ) = zladiv( x( j ), tjjs )
976 ELSE IF( tjj.GT.zero )
THEN
980 IF( xj.GT.tjj*bignum )
THEN
984 rec = ( tjj*bignum ) / xj
985 CALL zdscal( n, rec, x, 1 )
989 x( j ) = zladiv( x( j ), tjjs )
1008 x( j ) = zladiv( x( j ), tjjs ) - csumj
1010 xmax = max( xmax, cabs1( x( j ) ) )
1013 scale = scale / tscal
1018 IF( tscal.NE.one )
THEN
1019 CALL dscal( n, one / tscal, cnorm, 1 )
subroutine xerbla(srname, info)
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
subroutine zlatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
ZLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine ztrsv(uplo, trans, diag, n, a, lda, x, incx)
ZTRSV