227 SUBROUTINE zlatps( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE,
235 CHARACTER DIAG, NORMIN, TRANS, UPLO
237 DOUBLE PRECISION SCALE
240 DOUBLE PRECISION CNORM( * )
241 COMPLEX*16 AP( * ), X( * )
247 DOUBLE PRECISION ZERO, HALF, ONE, TWO
248 parameter( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0,
252 LOGICAL NOTRAN, NOUNIT, UPPER
253 INTEGER I, IMAX, IP, J, JFIRST, JINC, JLAST, JLEN
254 DOUBLE PRECISION BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,
256 COMPLEX*16 CSUMJ, TJJS, USCAL, ZDUM
260 INTEGER IDAMAX, IZAMAX
261 DOUBLE PRECISION DLAMCH, DZASUM
262 COMPLEX*16 ZDOTC, ZDOTU, ZLADIV
263 EXTERNAL lsame, idamax, izamax, dlamch, dzasum,
271 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
274 DOUBLE PRECISION CABS1, CABS2
277 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
278 cabs2( zdum ) = abs( dble( zdum ) / 2.d0 ) +
279 $ abs( dimag( zdum ) / 2.d0 )
284 upper = lsame( uplo,
'U' )
285 notran = lsame( trans,
'N' )
286 nounit = lsame( diag,
'N' )
290 IF( .NOT.upper .AND. .NOT.lsame( uplo,
'L' ) )
THEN
292 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) .AND. .NOT.
293 $ lsame( trans,
'C' ) )
THEN
295 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag,
'U' ) )
THEN
297 ELSE IF( .NOT.lsame( normin,
'Y' ) .AND. .NOT.
298 $ lsame( normin,
'N' ) )
THEN
300 ELSE IF( n.LT.0 )
THEN
304 CALL xerbla(
'ZLATPS', -info )
315 smlnum = dlamch(
'Safe minimum' )
316 bignum = one / smlnum
317 smlnum = smlnum / dlamch(
'Precision' )
318 bignum = one / smlnum
321 IF( lsame( normin,
'N' ) )
THEN
331 cnorm( j ) = dzasum( j-1, ap( ip ), 1 )
340 cnorm( j ) = dzasum( n-j, ap( ip+1 ), 1 )
350 imax = idamax( n, cnorm, 1 )
352 IF( tmax.LE.bignum*half )
THEN
355 tscal = half / ( smlnum*tmax )
356 CALL dscal( n, tscal, cnorm, 1 )
364 xmax = max( xmax, cabs2( x( j ) ) )
381 IF( tscal.NE.one )
THEN
393 grow = half / max( xbnd, smlnum )
395 ip = jfirst*( jfirst+1 ) / 2
397 DO 40 j = jfirst, jlast, jinc
407 IF( tjj.GE.smlnum )
THEN
411 xbnd = min( xbnd, min( one, tjj )*grow )
419 IF( tjj+cnorm( j ).GE.smlnum )
THEN
423 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
440 grow = min( one, half / max( xbnd, smlnum ) )
441 DO 50 j = jfirst, jlast, jinc
450 grow = grow*( one / ( one+cnorm( j ) ) )
469 IF( tscal.NE.one )
THEN
481 grow = half / max( xbnd, smlnum )
483 ip = jfirst*( jfirst+1 ) / 2
485 DO 70 j = jfirst, jlast, jinc
494 xj = one + cnorm( j )
495 grow = min( grow, xbnd / xj )
500 IF( tjj.GE.smlnum )
THEN
505 $ xbnd = xbnd*( tjj / xj )
515 grow = min( grow, xbnd )
522 grow = min( one, half / max( xbnd, smlnum ) )
523 DO 80 j = jfirst, jlast, jinc
532 xj = one + cnorm( j )
539 IF( ( grow*tscal ).GT.smlnum )
THEN
544 CALL ztpsv( uplo, trans, diag, n, ap, x, 1 )
549 IF( xmax.GT.bignum*half )
THEN
554 scale = ( bignum*half ) / xmax
555 CALL zdscal( n, scale, x, 1 )
565 ip = jfirst*( jfirst+1 ) / 2
566 DO 120 j = jfirst, jlast, jinc
572 tjjs = ap( ip )*tscal
579 IF( tjj.GT.smlnum )
THEN
583 IF( tjj.LT.one )
THEN
584 IF( xj.GT.tjj*bignum )
THEN
589 CALL zdscal( n, rec, x, 1 )
594 x( j ) = zladiv( x( j ), tjjs )
596 ELSE IF( tjj.GT.zero )
THEN
600 IF( xj.GT.tjj*bignum )
THEN
605 rec = ( tjj*bignum ) / xj
606 IF( cnorm( j ).GT.one )
THEN
611 rec = rec / cnorm( j )
613 CALL zdscal( n, rec, x, 1 )
617 x( j ) = zladiv( x( j ), tjjs )
639 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
644 CALL zdscal( n, rec, x, 1 )
647 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
651 CALL zdscal( n, half, x, 1 )
661 CALL zaxpy( j-1, -x( j )*tscal, ap( ip-j+1 ), 1,
664 i = izamax( j-1, x, 1 )
665 xmax = cabs1( x( i ) )
674 CALL zaxpy( n-j, -x( j )*tscal, ap( ip+1 ), 1,
676 i = j + izamax( n-j, x( j+1 ), 1 )
677 xmax = cabs1( x( i ) )
683 ELSE IF( lsame( trans,
'T' ) )
THEN
687 ip = jfirst*( jfirst+1 ) / 2
689 DO 170 j = jfirst, jlast, jinc
696 rec = one / max( xmax, one )
697 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
703 tjjs = ap( ip )*tscal
708 IF( tjj.GT.one )
THEN
712 rec = min( one, rec*tjj )
713 uscal = zladiv( uscal, tjjs )
715 IF( rec.LT.one )
THEN
716 CALL zdscal( n, rec, x, 1 )
723 IF( uscal.EQ.dcmplx( one ) )
THEN
729 csumj = zdotu( j-1, ap( ip-j+1 ), 1, x, 1 )
730 ELSE IF( j.LT.n )
THEN
731 csumj = zdotu( n-j, ap( ip+1 ), 1, x( j+1 ), 1 )
739 csumj = csumj + ( ap( ip-j+i )*uscal )*x( i )
741 ELSE IF( j.LT.n )
THEN
743 csumj = csumj + ( ap( ip+i )*uscal )*x( j+i )
748 IF( uscal.EQ.dcmplx( tscal ) )
THEN
753 x( j ) = x( j ) - csumj
759 tjjs = ap( ip )*tscal
766 IF( tjj.GT.smlnum )
THEN
770 IF( tjj.LT.one )
THEN
771 IF( xj.GT.tjj*bignum )
THEN
776 CALL zdscal( n, rec, x, 1 )
781 x( j ) = zladiv( x( j ), tjjs )
782 ELSE IF( tjj.GT.zero )
THEN
786 IF( xj.GT.tjj*bignum )
THEN
790 rec = ( tjj*bignum ) / xj
791 CALL zdscal( n, rec, x, 1 )
795 x( j ) = zladiv( x( j ), tjjs )
814 x( j ) = zladiv( x( j ), tjjs ) - csumj
816 xmax = max( xmax, cabs1( x( j ) ) )
825 ip = jfirst*( jfirst+1 ) / 2
827 DO 220 j = jfirst, jlast, jinc
834 rec = one / max( xmax, one )
835 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
841 tjjs = dconjg( ap( ip ) )*tscal
846 IF( tjj.GT.one )
THEN
850 rec = min( one, rec*tjj )
851 uscal = zladiv( uscal, tjjs )
853 IF( rec.LT.one )
THEN
854 CALL zdscal( n, rec, x, 1 )
861 IF( uscal.EQ.dcmplx( one ) )
THEN
867 csumj = zdotc( j-1, ap( ip-j+1 ), 1, x, 1 )
868 ELSE IF( j.LT.n )
THEN
869 csumj = zdotc( n-j, ap( ip+1 ), 1, x( j+1 ), 1 )
877 csumj = csumj + ( dconjg( ap( ip-j+i ) )*uscal )
880 ELSE IF( j.LT.n )
THEN
882 csumj = csumj + ( dconjg( ap( ip+i ) )*uscal )*
888 IF( uscal.EQ.dcmplx( tscal ) )
THEN
893 x( j ) = x( j ) - csumj
899 tjjs = dconjg( ap( ip ) )*tscal
906 IF( tjj.GT.smlnum )
THEN
910 IF( tjj.LT.one )
THEN
911 IF( xj.GT.tjj*bignum )
THEN
916 CALL zdscal( n, rec, x, 1 )
921 x( j ) = zladiv( x( j ), tjjs )
922 ELSE IF( tjj.GT.zero )
THEN
926 IF( xj.GT.tjj*bignum )
THEN
930 rec = ( tjj*bignum ) / xj
931 CALL zdscal( n, rec, x, 1 )
935 x( j ) = zladiv( x( j ), tjjs )
954 x( j ) = zladiv( x( j ), tjjs ) - csumj
956 xmax = max( xmax, cabs1( x( j ) ) )
961 scale = scale / tscal
966 IF( tscal.NE.one )
THEN
967 CALL dscal( n, one / tscal, cnorm, 1 )