236 SUBROUTINE dlatrs( UPLO, TRANS, DIAG, NORMIN, N, A, LDA, X, SCALE,
244 CHARACTER DIAG, NORMIN, TRANS, UPLO
246 DOUBLE PRECISION SCALE
249 DOUBLE PRECISION A( LDA, * ), CNORM( * ), X( * )
255 DOUBLE PRECISION ZERO, HALF, ONE
256 parameter( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0 )
259 LOGICAL NOTRAN, NOUNIT, UPPER
260 INTEGER I, IMAX, J, JFIRST, JINC, JLAST
261 DOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS,
262 $ tmax, tscal, uscal, xbnd, xj, xmax
265 DOUBLE PRECISION WORK(1)
270 DOUBLE PRECISION DASUM, DDOT, DLAMCH, DLANGE
271 EXTERNAL lsame, idamax, dasum, ddot, dlamch, dlange
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(
'DLATRS', -info )
316 smlnum = dlamch(
'Safe minimum' ) / dlamch(
'Precision' )
317 bignum = one / smlnum
319 IF( lsame( normin,
'N' ) )
THEN
328 cnorm( j ) = dasum( j-1, a( 1, j ), 1 )
335 cnorm( j ) = dasum( n-j, a( j+1, j ), 1 )
344 imax = idamax( n, cnorm, 1 )
346 IF( tmax.LE.bignum )
THEN
353 IF( tmax.LE.dlamch(
'Overflow') )
THEN
355 tscal = one / ( smlnum*tmax )
356 CALL dscal( n, tscal, cnorm, 1 )
368 tmax = max( dlange(
'M', j-1, 1, a( 1, j ), 1, work ),
376 tmax = max( dlange(
'M', n-j, 1, a( j+1, j ), 1,
381 IF( tmax.LE.dlamch(
'Overflow') )
THEN
382 tscal = one / ( smlnum*tmax )
384 IF( cnorm( j ).LE.dlamch(
'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 dtrsv( uplo, trans, diag, n, a, lda, x, 1 )
415 j = idamax( 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 dtrsv( uplo, trans, diag, n, a, lda, x, 1 )
571 IF( xmax.GT.bignum )
THEN
576 scale = bignum / xmax
577 CALL dscal( n, scale, x, 1 )
585 DO 110 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 dscal( 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 dscal( n, rec, x, 1 )
636 x( j ) = x( j ) / tjjs
658 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
663 CALL dscal( n, rec, x, 1 )
666 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
670 CALL dscal( n, half, x, 1 )
680 CALL daxpy( j-1, -x( j )*tscal, a( 1, j ), 1, x,
682 i = idamax( j-1, x, 1 )
691 CALL daxpy( n-j, -x( j )*tscal, a( j+1, j ), 1,
693 i = j + idamax( n-j, x( j+1 ), 1 )
703 DO 160 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 dscal( n, rec, x, 1 )
737 IF( uscal.EQ.one )
THEN
743 sumj = ddot( j-1, a( 1, j ), 1, x, 1 )
744 ELSE IF( j.LT.n )
THEN
745 sumj = ddot( 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 dscal( 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 dscal( 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 dscal( n, one / tscal, cnorm, 1 )
subroutine xerbla(srname, info)
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
subroutine dlatrs(uplo, trans, diag, normin, n, a, lda, x, scale, cnorm, info)
DLATRS solves a triangular system of equations with the scale factor set to prevent overflow.
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine dtrsv(uplo, trans, diag, n, a, lda, x, incx)
DTRSV