237 SUBROUTINE clatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
245 CHARACTER DIAG, NORMIN, TRANS, UPLO
251 COMPLEX A( LDA, * ), X( * )
257 REAL ZERO, HALF, ONE, TWO
258 parameter( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0,
262 LOGICAL NOTRAN, NOUNIT, UPPER
263 INTEGER I, IMAX, J, JFIRST, JINC, JLAST
264 REAL BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,
266 COMPLEX CSUMJ, TJJS, USCAL, ZDUM
270 INTEGER ICAMAX, ISAMAX
272 COMPLEX CDOTC, CDOTU, CLADIV
273 EXTERNAL lsame, icamax, isamax, scasum, slamch, cdotc,
280 INTRINSIC abs, aimag, cmplx, conjg, max, min, real
286 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
287 cabs2( zdum ) = abs( real( zdum ) / 2. ) +
288 $ abs( aimag( zdum ) / 2. )
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(
'CLATRS', -info )
327 smlnum = slamch(
'Safe minimum' ) / slamch(
'Precision' )
328 bignum = one / smlnum
330 IF( lsame( normin,
'N' ) )
THEN
339 cnorm( j ) = scasum( j-1, a( 1, j ), 1 )
346 cnorm( j ) = scasum( n-j, a( j+1, j ), 1 )
355 imax = isamax( n, cnorm, 1 )
357 IF( tmax.LE.bignum*half )
THEN
364 IF ( tmax.LE.slamch(
'Overflow') )
THEN
366 tscal = half / ( smlnum*tmax )
367 CALL sscal( n, tscal, cnorm, 1 )
381 tmax = max( tmax, abs( real( a( i, j ) ) ),
382 $ abs( aimag(a( i, j ) ) ) )
391 tmax = max( tmax, abs( real( a( i, j ) ) ),
392 $ abs( aimag(a( i, j ) ) ) )
397 IF( tmax.LE.slamch(
'Overflow') )
THEN
398 tscal = one / ( smlnum*tmax )
400 IF( cnorm( j ).LE.slamch(
'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 ctrsv( 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 ctrsv( uplo, trans, diag, n, a, lda, x, 1 )
613 IF( xmax.GT.bignum*half )
THEN
618 scale = ( bignum*half ) / xmax
619 CALL csscal( n, scale, x, 1 )
629 DO 110 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 csscal( n, rec, x, 1 )
657 x( j ) = cladiv( 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 csscal( n, rec, x, 1 )
680 x( j ) = cladiv( x( j ), tjjs )
702 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
707 CALL csscal( n, rec, x, 1 )
710 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
714 CALL csscal( n, half, x, 1 )
724 CALL caxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
726 i = icamax( j-1, x, 1 )
727 xmax = cabs1( x( i ) )
735 CALL caxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
737 i = j + icamax( n-j, x( j+1 ), 1 )
738 xmax = cabs1( x( i ) )
743 ELSE IF( lsame( trans,
'T' ) )
THEN
747 DO 150 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 = cladiv( uscal, tjjs )
773 IF( rec.LT.one )
THEN
774 CALL csscal( n, rec, x, 1 )
781 IF( uscal.EQ.cmplx( one ) )
THEN
787 csumj = cdotu( j-1, a( 1, j ), 1, x, 1 )
788 ELSE IF( j.LT.n )
THEN
789 csumj = cdotu( 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.cmplx( 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 csscal( n, rec, x, 1 )
839 x( j ) = cladiv( x( j ), tjjs )
840 ELSE IF( tjj.GT.zero )
THEN
844 IF( xj.GT.tjj*bignum )
THEN
848 rec = ( tjj*bignum ) / xj
849 CALL csscal( n, rec, x, 1 )
853 x( j ) = cladiv( x( j ), tjjs )
872 x( j ) = cladiv( x( j ), tjjs ) - csumj
874 xmax = max( xmax, cabs1( x( j ) ) )
881 DO 190 j = jfirst, jlast, jinc
888 rec = one / max( xmax, one )
889 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
895 tjjs = conjg( a( j, j ) )*tscal
900 IF( tjj.GT.one )
THEN
904 rec = min( one, rec*tjj )
905 uscal = cladiv( uscal, tjjs )
907 IF( rec.LT.one )
THEN
908 CALL csscal( n, rec, x, 1 )
915 IF( uscal.EQ.cmplx( one ) )
THEN
921 csumj = cdotc( j-1, a( 1, j ), 1, x, 1 )
922 ELSE IF( j.LT.n )
THEN
923 csumj = cdotc( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
931 csumj = csumj + ( conjg( a( i, j ) )*uscal )*
934 ELSE IF( j.LT.n )
THEN
936 csumj = csumj + ( conjg( a( i, j ) )*uscal )*
942 IF( uscal.EQ.cmplx( tscal ) )
THEN
947 x( j ) = x( j ) - csumj
950 tjjs = conjg( 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 csscal( n, rec, x, 1 )
975 x( j ) = cladiv( x( j ), tjjs )
976 ELSE IF( tjj.GT.zero )
THEN
980 IF( xj.GT.tjj*bignum )
THEN
984 rec = ( tjj*bignum ) / xj
985 CALL csscal( n, rec, x, 1 )
989 x( j ) = cladiv( x( j ), tjjs )
1008 x( j ) = cladiv( x( j ), tjjs ) - csumj
1010 xmax = max( xmax, cabs1( x( j ) ) )
1013 scale = scale / tscal
1018 IF( tscal.NE.one )
THEN
1019 CALL sscal( n, one / tscal, cnorm, 1 )
subroutine xerbla(srname, info)
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
subroutine clatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
CLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine csscal(n, sa, cx, incx)
CSSCAL
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine ctrsv(uplo, trans, diag, n, a, lda, x, incx)
CTRSV