236 SUBROUTINE slatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
244 CHARACTER DIAG, NORMIN, TRANS, UPLO
249 REAL A( LDA, * ), CNORM( * ), X( * )
256 parameter( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0 )
259 LOGICAL NOTRAN, NOUNIT, UPPER
260 INTEGER I, IMAX, J, JFIRST, JINC, JLAST
261 REAL BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS,
262 $ tmax, tscal, uscal, xbnd, xj, xmax
270 REAL SASUM, SDOT, SLAMCH, SLANGE
271 EXTERNAL lsame, isamax, sasum, sdot, slamch, slange
277 INTRINSIC abs, max, min
282 upper = lsame( uplo,
'U' )
283 notran = lsame( trans,
'N' )
284 nounit = lsame( diag,
'N' )
288 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
290 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
291 $ lsame( trans,
'C' ) )
THEN
293 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
295 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
296 $ lsame( normin,
'N' ) )
THEN
298 ELSE IF( n.LT.0 )
THEN
300 ELSE IF( lda.LT.max( 1, n ) )
THEN
304 CALL xerbla(
'SLATRS', -info )
316 smlnum = slamch(
'Safe minimum' ) / slamch(
'Precision' )
317 bignum = one / smlnum
319 IF( lsame( normin,
'N' ) )
THEN
328 cnorm( j ) = sasum( j-1, a( 1, j ), 1 )
335 cnorm( j ) = sasum( n-j, a( j+1, j ), 1 )
344 imax = isamax( n, cnorm, 1 )
346 IF( tmax.LE.bignum )
THEN
353 IF ( tmax.LE.slamch(
'Overflow') )
THEN
355 tscal = one / ( smlnum*tmax )
356 CALL sscal( n, tscal, cnorm, 1 )
368 tmax = max( slange(
'M', j-1, 1, a( 1, j ), 1, work ),
376 tmax = max( slange(
'M', n-j, 1, a( j+1, j ), 1,
381 IF( tmax.LE.slamch(
'Overflow') )
THEN
382 tscal = one / ( smlnum*tmax )
384 IF( cnorm( j ).LE.slamch(
'Overflow') )
THEN
385 cnorm( j ) = cnorm( j )*tscal
392 cnorm( j ) = cnorm( j ) +
393 $ tscal * abs( a( i, j ) )
397 cnorm( j ) = cnorm( j ) +
398 $ tscal * abs( a( i, j ) )
406 CALL strsv( uplo, trans, diag, n, a, lda, x, 1 )
415 j = isamax( n, x, 1 )
432 IF( tscal.NE.one )
THEN
444 grow = one / max( xbnd, smlnum )
446 DO 30 j = jfirst, jlast, jinc
455 tjj = abs( a( j, j ) )
456 xbnd = min( xbnd, min( one, tjj )*grow )
457 IF( tjj+cnorm( j ).GE.smlnum )
THEN
461 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
476 grow = min( one, one / max( xbnd, smlnum ) )
477 DO 40 j = jfirst, jlast, jinc
486 grow = grow*( one / ( one+cnorm( j ) ) )
505 IF( tscal.NE.one )
THEN
517 grow = one / max( xbnd, smlnum )
519 DO 60 j = jfirst, jlast, jinc
528 xj = one + cnorm( j )
529 grow = min( grow, xbnd / xj )
533 tjj = abs( a( j, j ) )
535 $ xbnd = xbnd*( tjj / xj )
537 grow = min( grow, xbnd )
544 grow = min( one, one / max( xbnd, smlnum ) )
545 DO 70 j = jfirst, jlast, jinc
554 xj = one + cnorm( j )
561 IF( ( grow*tscal ).GT.smlnum )
THEN
566 CALL strsv( uplo, trans, diag, n, a, lda, x, 1 )
571 IF( xmax.GT.bignum )
THEN
576 scale = bignum / xmax
577 CALL sscal( n, scale, x, 1 )
585 DO 100 j = jfirst, jlast, jinc
591 tjjs = a( j, j )*tscal
598 IF( tjj.GT.smlnum )
THEN
602 IF( tjj.LT.one )
THEN
603 IF( xj.GT.tjj*bignum )
THEN
608 CALL sscal( n, rec, x, 1 )
613 x( j ) = x( j ) / tjjs
615 ELSE IF( tjj.GT.zero )
THEN
619 IF( xj.GT.tjj*bignum )
THEN
624 rec = ( tjj*bignum ) / xj
625 IF( cnorm( j ).GT.one )
THEN
630 rec = rec / cnorm( j )
632 CALL sscal( n, rec, x, 1 )
636 x( j ) = x( j ) / tjjs
658 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
663 CALL sscal( n, rec, x, 1 )
666 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
670 CALL sscal( n, half, x, 1 )
680 CALL saxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
682 i = isamax( j-1, x, 1 )
691 CALL saxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
693 i = j + isamax( n-j, x( j+1 ), 1 )
703 DO 140 j = jfirst, jlast, jinc
710 rec = one / max( xmax, one )
711 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
717 tjjs = a( j, j )*tscal
722 IF( tjj.GT.one )
THEN
726 rec = min( one, rec*tjj )
729 IF( rec.LT.one )
THEN
730 CALL sscal( n, rec, x, 1 )
737 IF( uscal.EQ.one )
THEN
743 sumj = sdot( j-1, a( 1, j ), 1, x, 1 )
744 ELSE IF( j.LT.n )
THEN
745 sumj = sdot( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
753 sumj = sumj + ( a( i, j )*uscal )*x( i )
755 ELSE IF( j.LT.n )
THEN
757 sumj = sumj + ( a( i, j )*uscal )*x( i )
762 IF( uscal.EQ.tscal )
THEN
767 x( j ) = x( j ) - sumj
770 tjjs = a( j, j )*tscal
780 IF( tjj.GT.smlnum )
THEN
784 IF( tjj.LT.one )
THEN
785 IF( xj.GT.tjj*bignum )
THEN
790 CALL sscal( n, rec, x, 1 )
795 x( j ) = x( j ) / tjjs
796 ELSE IF( tjj.GT.zero )
THEN
800 IF( xj.GT.tjj*bignum )
THEN
804 rec = ( tjj*bignum ) / xj
805 CALL sscal( n, rec, x, 1 )
809 x( j ) = x( j ) / tjjs
828 x( j ) = x( j ) / tjjs - sumj
830 xmax = max( xmax, abs( x( j ) ) )
833 scale = scale / tscal
838 IF( tscal.NE.one )
THEN
839 CALL sscal( n, one / tscal, cnorm, 1 )
subroutine xerbla(srname, info)
subroutine saxpy(n, sa, sx, incx, sy, incy)
SAXPY
subroutine slatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
SLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine strsv(uplo, trans, diag, n, a, lda, x, incx)
STRSV