225 SUBROUTINE slatps( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE,
233 CHARACTER DIAG, NORMIN, TRANS, UPLO
238 REAL AP( * ), CNORM( * ), X( * )
245 parameter( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0 )
248 LOGICAL NOTRAN, NOUNIT, UPPER
249 INTEGER I, IMAX, IP, J, JFIRST, JINC, JLAST, JLEN
250 REAL BIGNUM, GROW, REC, SMLNUM, SUMJ, TJJ, TJJS,
251 $ tmax, tscal, uscal, xbnd, xj, xmax
256 REAL SASUM, SDOT, SLAMCH
257 EXTERNAL lsame, isamax, sasum, sdot, slamch
263 INTRINSIC abs, max, min
268 upper = lsame( uplo,
'U' )
269 notran = lsame( trans,
'N' )
270 nounit = lsame( diag,
'N' )
274 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
276 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
277 $ lsame( trans,
'C' ) )
THEN
279 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
281 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
282 $ lsame( normin,
'N' ) )
THEN
284 ELSE IF( n.LT.0 )
THEN
288 CALL xerbla(
'SLATPS', -info )
299 smlnum = slamch(
'Safe minimum' ) / slamch(
'Precision' )
300 bignum = one / smlnum
303 IF( lsame( normin,
'N' ) )
THEN
313 cnorm( j ) = sasum( j-1, ap( ip ), 1 )
322 cnorm( j ) = sasum( n-j, ap( ip+1 ), 1 )
332 imax = isamax( n, cnorm, 1 )
334 IF( tmax.LE.bignum )
THEN
337 tscal = one / ( smlnum*tmax )
338 CALL sscal( n, tscal, cnorm, 1 )
344 j = isamax( n, x, 1 )
361 IF( tscal.NE.one )
THEN
373 grow = one / max( xbnd, smlnum )
375 ip = jfirst*( jfirst+1 ) / 2
377 DO 30 j = jfirst, jlast, jinc
386 tjj = abs( ap( ip ) )
387 xbnd = min( xbnd, min( one, tjj )*grow )
388 IF( tjj+cnorm( j ).GE.smlnum )
THEN
392 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
409 grow = min( one, one / max( xbnd, smlnum ) )
410 DO 40 j = jfirst, jlast, jinc
419 grow = grow*( one / ( one+cnorm( j ) ) )
438 IF( tscal.NE.one )
THEN
450 grow = one / max( xbnd, smlnum )
452 ip = jfirst*( jfirst+1 ) / 2
454 DO 60 j = jfirst, jlast, jinc
463 xj = one + cnorm( j )
464 grow = min( grow, xbnd / xj )
468 tjj = abs( ap( ip ) )
470 $ xbnd = xbnd*( tjj / xj )
474 grow = min( grow, xbnd )
481 grow = min( one, one / max( xbnd, smlnum ) )
482 DO 70 j = jfirst, jlast, jinc
491 xj = one + cnorm( j )
498 IF( ( grow*tscal ).GT.smlnum )
THEN
503 CALL stpsv( uplo, trans, diag, n, ap, x, 1 )
508 IF( xmax.GT.bignum )
THEN
513 scale = bignum / xmax
514 CALL sscal( n, scale, x, 1 )
522 ip = jfirst*( jfirst+1 ) / 2
523 DO 100 j = jfirst, jlast, jinc
529 tjjs = ap( ip )*tscal
536 IF( tjj.GT.smlnum )
THEN
540 IF( tjj.LT.one )
THEN
541 IF( xj.GT.tjj*bignum )
THEN
546 CALL sscal( n, rec, x, 1 )
551 x( j ) = x( j ) / tjjs
553 ELSE IF( tjj.GT.zero )
THEN
557 IF( xj.GT.tjj*bignum )
THEN
562 rec = ( tjj*bignum ) / xj
563 IF( cnorm( j ).GT.one )
THEN
568 rec = rec / cnorm( j )
570 CALL sscal( n, rec, x, 1 )
574 x( j ) = x( j ) / tjjs
596 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
601 CALL sscal( n, rec, x, 1 )
604 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
608 CALL sscal( n, half, x, 1 )
618 CALL saxpy( j-1, -x( j )*tscal, ap( ip-j+1 ), 1,
621 i = isamax( j-1, x, 1 )
631 CALL saxpy( n-j, -x( j )*tscal, ap( ip+1 ), 1,
633 i = j + isamax( n-j, x( j+1 ), 1 )
644 ip = jfirst*( jfirst+1 ) / 2
646 DO 140 j = jfirst, jlast, jinc
653 rec = one / max( xmax, one )
654 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
660 tjjs = ap( ip )*tscal
665 IF( tjj.GT.one )
THEN
669 rec = min( one, rec*tjj )
672 IF( rec.LT.one )
THEN
673 CALL sscal( n, rec, x, 1 )
680 IF( uscal.EQ.one )
THEN
686 sumj = sdot( j-1, ap( ip-j+1 ), 1, x, 1 )
687 ELSE IF( j.LT.n )
THEN
688 sumj = sdot( n-j, ap( ip+1 ), 1, x( j+1 ), 1 )
696 sumj = sumj + ( ap( ip-j+i )*uscal )*x( i )
698 ELSE IF( j.LT.n )
THEN
700 sumj = sumj + ( ap( ip+i )*uscal )*x( j+i )
705 IF( uscal.EQ.tscal )
THEN
710 x( j ) = x( j ) - sumj
716 tjjs = ap( ip )*tscal
723 IF( tjj.GT.smlnum )
THEN
727 IF( tjj.LT.one )
THEN
728 IF( xj.GT.tjj*bignum )
THEN
733 CALL sscal( n, rec, x, 1 )
738 x( j ) = x( j ) / tjjs
739 ELSE IF( tjj.GT.zero )
THEN
743 IF( xj.GT.tjj*bignum )
THEN
747 rec = ( tjj*bignum ) / xj
748 CALL sscal( n, rec, x, 1 )
752 x( j ) = x( j ) / tjjs
771 x( j ) = x( j ) / tjjs - sumj
773 xmax = max( xmax, abs( x( j ) ) )
778 scale = scale / tscal
783 IF( tscal.NE.one )
THEN
784 CALL sscal( n, one / tscal, cnorm, 1 )