239 SUBROUTINE clatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
248 CHARACTER DIAG, NORMIN, TRANS, UPLO
254 COMPLEX A( lda, * ), X( * )
260 REAL ZERO, HALF, ONE, TWO
261 parameter ( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0,
265 LOGICAL NOTRAN, NOUNIT, UPPER
266 INTEGER I, IMAX, J, JFIRST, JINC, JLAST
267 REAL BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,
269 COMPLEX CSUMJ, TJJS, USCAL, ZDUM
273 INTEGER ICAMAX, ISAMAX
275 COMPLEX CDOTC, CDOTU, CLADIV
276 EXTERNAL lsame, icamax, isamax, scasum, slamch, cdotc,
283 INTRINSIC abs, aimag, cmplx, conjg, max, min, real
289 cabs1( zdum ) = abs(
REAL( ZDUM ) ) + abs( AIMAG( zdum ) )
290 cabs2( zdum ) = abs(
REAL( ZDUM ) / 2. ) +
291 $ abs( aimag( zdum ) / 2. )
296 upper = lsame( uplo,
'U' )
297 notran = lsame( trans,
'N' )
298 nounit = lsame( diag,
'N' )
302 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
304 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
305 $ lsame( trans,
'C' ) )
THEN
307 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
309 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
310 $ lsame( normin,
'N' ) )
THEN
312 ELSE IF( n.LT.0 )
THEN
314 ELSE IF( lda.LT.max( 1, n ) )
THEN
318 CALL xerbla(
'CLATRS', -info )
329 smlnum = slamch(
'Safe minimum' )
330 bignum = one / smlnum
331 CALL slabad( smlnum, bignum )
332 smlnum = smlnum / slamch(
'Precision' )
333 bignum = one / smlnum
336 IF( lsame( normin,
'N' ) )
THEN
345 cnorm( j ) = scasum( j-1, a( 1, j ), 1 )
352 cnorm( j ) = scasum( n-j, a( j+1, j ), 1 )
361 imax = isamax( n, cnorm, 1 )
363 IF( tmax.LE.bignum*half )
THEN
366 tscal = half / ( smlnum*tmax )
367 CALL sscal( n, tscal, cnorm, 1 )
375 xmax = max( xmax, cabs2( x( j ) ) )
393 IF( tscal.NE.one )
THEN
405 grow = half / max( xbnd, smlnum )
407 DO 40 j = jfirst, jlast, jinc
417 IF( tjj.GE.smlnum )
THEN
421 xbnd = min( xbnd, min( one, tjj )*grow )
429 IF( tjj+cnorm( j ).GE.smlnum )
THEN
433 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
448 grow = min( one, half / max( xbnd, smlnum ) )
449 DO 50 j = jfirst, jlast, jinc
458 grow = grow*( one / ( one+cnorm( j ) ) )
477 IF( tscal.NE.one )
THEN
489 grow = half / max( xbnd, smlnum )
491 DO 70 j = jfirst, jlast, jinc
500 xj = one + cnorm( j )
501 grow = min( grow, xbnd / xj )
506 IF( tjj.GE.smlnum )
THEN
511 $ xbnd = xbnd*( tjj / xj )
519 grow = min( grow, xbnd )
526 grow = min( one, half / max( xbnd, smlnum ) )
527 DO 80 j = jfirst, jlast, jinc
536 xj = one + cnorm( j )
543 IF( ( grow*tscal ).GT.smlnum )
THEN
548 CALL ctrsv( uplo, trans, diag, n, a, lda, x, 1 )
553 IF( xmax.GT.bignum*half )
THEN
558 scale = ( bignum*half ) / xmax
559 CALL csscal( n, scale, x, 1 )
569 DO 110 j = jfirst, jlast, jinc
575 tjjs = a( j, j )*tscal
582 IF( tjj.GT.smlnum )
THEN
586 IF( tjj.LT.one )
THEN
587 IF( xj.GT.tjj*bignum )
THEN
592 CALL csscal( n, rec, x, 1 )
597 x( j ) = cladiv( x( j ), tjjs )
599 ELSE IF( tjj.GT.zero )
THEN
603 IF( xj.GT.tjj*bignum )
THEN
608 rec = ( tjj*bignum ) / xj
609 IF( cnorm( j ).GT.one )
THEN
614 rec = rec / cnorm( j )
616 CALL csscal( n, rec, x, 1 )
620 x( j ) = cladiv( x( j ), tjjs )
642 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
647 CALL csscal( n, rec, x, 1 )
650 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
654 CALL csscal( n, half, x, 1 )
664 CALL caxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
666 i = icamax( j-1, x, 1 )
667 xmax = cabs1( x( i ) )
675 CALL caxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
677 i = j + icamax( n-j, x( j+1 ), 1 )
678 xmax = cabs1( x( i ) )
683 ELSE IF( lsame( trans,
'T' ) )
THEN
687 DO 150 j = jfirst, jlast, jinc
694 rec = one / max( xmax, one )
695 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
701 tjjs = a( j, j )*tscal
706 IF( tjj.GT.one )
THEN
710 rec = min( one, rec*tjj )
711 uscal = cladiv( uscal, tjjs )
713 IF( rec.LT.one )
THEN
714 CALL csscal( n, rec, x, 1 )
721 IF( uscal.EQ.cmplx( one ) )
THEN
727 csumj = cdotu( j-1, a( 1, j ), 1, x, 1 )
728 ELSE IF( j.LT.n )
THEN
729 csumj = cdotu( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
737 csumj = csumj + ( a( i, j )*uscal )*x( i )
739 ELSE IF( j.LT.n )
THEN
741 csumj = csumj + ( a( i, j )*uscal )*x( i )
746 IF( uscal.EQ.cmplx( tscal ) )
THEN
751 x( j ) = x( j ) - csumj
754 tjjs = a( j, j )*tscal
764 IF( tjj.GT.smlnum )
THEN
768 IF( tjj.LT.one )
THEN
769 IF( xj.GT.tjj*bignum )
THEN
774 CALL csscal( n, rec, x, 1 )
779 x( j ) = cladiv( x( j ), tjjs )
780 ELSE IF( tjj.GT.zero )
THEN
784 IF( xj.GT.tjj*bignum )
THEN
788 rec = ( tjj*bignum ) / xj
789 CALL csscal( n, rec, x, 1 )
793 x( j ) = cladiv( x( j ), tjjs )
812 x( j ) = cladiv( x( j ), tjjs ) - csumj
814 xmax = max( xmax, cabs1( x( j ) ) )
821 DO 190 j = jfirst, jlast, jinc
828 rec = one / max( xmax, one )
829 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
835 tjjs = conjg( a( j, j ) )*tscal
840 IF( tjj.GT.one )
THEN
844 rec = min( one, rec*tjj )
845 uscal = cladiv( uscal, tjjs )
847 IF( rec.LT.one )
THEN
848 CALL csscal( n, rec, x, 1 )
855 IF( uscal.EQ.cmplx( one ) )
THEN
861 csumj = cdotc( j-1, a( 1, j ), 1, x, 1 )
862 ELSE IF( j.LT.n )
THEN
863 csumj = cdotc( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
871 csumj = csumj + ( conjg( a( i, j ) )*uscal )*
874 ELSE IF( j.LT.n )
THEN
876 csumj = csumj + ( conjg( a( i, j ) )*uscal )*
882 IF( uscal.EQ.cmplx( tscal ) )
THEN
887 x( j ) = x( j ) - csumj
890 tjjs = conjg( a( j, j ) )*tscal
900 IF( tjj.GT.smlnum )
THEN
904 IF( tjj.LT.one )
THEN
905 IF( xj.GT.tjj*bignum )
THEN
910 CALL csscal( n, rec, x, 1 )
915 x( j ) = cladiv( x( j ), tjjs )
916 ELSE IF( tjj.GT.zero )
THEN
920 IF( xj.GT.tjj*bignum )
THEN
924 rec = ( tjj*bignum ) / xj
925 CALL csscal( n, rec, x, 1 )
929 x( j ) = cladiv( x( j ), tjjs )
948 x( j ) = cladiv( x( j ), tjjs ) - csumj
950 xmax = max( xmax, cabs1( x( j ) ) )
953 scale = scale / tscal
958 IF( tscal.NE.one )
THEN
959 CALL sscal( n, one / tscal, cnorm, 1 )
subroutine slabad(SMALL, LARGE)
SLABAD
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 ctrsv(UPLO, TRANS, DIAG, N, A, LDA, X, INCX)
CTRSV
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine sscal(N, SA, SX, INCX)
SSCAL
subroutine caxpy(N, CA, CX, INCX, CY, INCY)
CAXPY
subroutine csscal(N, SA, CX, INCX)
CSSCAL