238 SUBROUTINE slatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
247 CHARACTER DIAG, NORMIN, TRANS, UPLO
252 REAL A( lda, * ), CNORM( * ), X( * )
259 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, SUMJ, TJJ, TJJS,
265 $ tmax, tscal, uscal, xbnd, xj, xmax
270 REAL SASUM, SDOT, SLAMCH
271 EXTERNAL lsame, isamax, sasum, sdot, slamch
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 )
315 smlnum = slamch(
'Safe minimum' ) / slamch(
'Precision' )
316 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
349 tscal = one / ( smlnum*tmax )
350 CALL sscal( n, tscal, cnorm, 1 )
356 j = isamax( n, x, 1 )
373 IF( tscal.NE.one )
THEN
385 grow = one / max( xbnd, smlnum )
387 DO 30 j = jfirst, jlast, jinc
396 tjj = abs( a( j, j ) )
397 xbnd = min( xbnd, min( one, tjj )*grow )
398 IF( tjj+cnorm( j ).GE.smlnum )
THEN
402 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
417 grow = min( one, one / max( xbnd, smlnum ) )
418 DO 40 j = jfirst, jlast, jinc
427 grow = grow*( one / ( one+cnorm( j ) ) )
446 IF( tscal.NE.one )
THEN
458 grow = one / max( xbnd, smlnum )
460 DO 60 j = jfirst, jlast, jinc
469 xj = one + cnorm( j )
470 grow = min( grow, xbnd / xj )
474 tjj = abs( a( j, j ) )
476 $ xbnd = xbnd*( tjj / xj )
478 grow = min( grow, xbnd )
485 grow = min( one, one / max( xbnd, smlnum ) )
486 DO 70 j = jfirst, jlast, jinc
495 xj = one + cnorm( j )
502 IF( ( grow*tscal ).GT.smlnum )
THEN
507 CALL strsv( uplo, trans, diag, n, a, lda, x, 1 )
512 IF( xmax.GT.bignum )
THEN
517 scale = bignum / xmax
518 CALL sscal( n, scale, x, 1 )
526 DO 100 j = jfirst, jlast, jinc
532 tjjs = a( j, j )*tscal
539 IF( tjj.GT.smlnum )
THEN
543 IF( tjj.LT.one )
THEN
544 IF( xj.GT.tjj*bignum )
THEN
549 CALL sscal( n, rec, x, 1 )
554 x( j ) = x( j ) / tjjs
556 ELSE IF( tjj.GT.zero )
THEN
560 IF( xj.GT.tjj*bignum )
THEN
565 rec = ( tjj*bignum ) / xj
566 IF( cnorm( j ).GT.one )
THEN
571 rec = rec / cnorm( j )
573 CALL sscal( n, rec, x, 1 )
577 x( j ) = x( j ) / tjjs
599 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
604 CALL sscal( n, rec, x, 1 )
607 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
611 CALL sscal( n, half, x, 1 )
621 CALL saxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
623 i = isamax( j-1, x, 1 )
632 CALL saxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
634 i = j + isamax( n-j, x( j+1 ), 1 )
644 DO 140 j = jfirst, jlast, jinc
651 rec = one / max( xmax, one )
652 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
658 tjjs = a( j, j )*tscal
663 IF( tjj.GT.one )
THEN
667 rec = min( one, rec*tjj )
670 IF( rec.LT.one )
THEN
671 CALL sscal( n, rec, x, 1 )
678 IF( uscal.EQ.one )
THEN
684 sumj = sdot( j-1, a( 1, j ), 1, x, 1 )
685 ELSE IF( j.LT.n )
THEN
686 sumj = sdot( n-j, a( j+1, j ), 1, x( j+1 ), 1 )
694 sumj = sumj + ( a( i, j )*uscal )*x( i )
696 ELSE IF( j.LT.n )
THEN
698 sumj = sumj + ( a( i, j )*uscal )*x( i )
703 IF( uscal.EQ.tscal )
THEN
708 x( j ) = x( j ) - sumj
711 tjjs = a( j, j )*tscal
721 IF( tjj.GT.smlnum )
THEN
725 IF( tjj.LT.one )
THEN
726 IF( xj.GT.tjj*bignum )
THEN
731 CALL sscal( n, rec, x, 1 )
736 x( j ) = x( j ) / tjjs
737 ELSE IF( tjj.GT.zero )
THEN
741 IF( xj.GT.tjj*bignum )
THEN
745 rec = ( tjj*bignum ) / xj
746 CALL sscal( n, rec, x, 1 )
750 x( j ) = x( j ) / tjjs
769 x( j ) = x( j ) / tjjs - sumj
771 xmax = max( xmax, abs( x( j ) ) )
774 scale = scale / tscal
779 IF( tscal.NE.one )
THEN
780 CALL sscal( n, one / tscal, cnorm, 1 )
subroutine xerbla(SRNAME, INFO)
XERBLA
subroutine strsv(UPLO, TRANS, DIAG, N, A, LDA, X, INCX)
STRSV
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