227 SUBROUTINE clatps( UPLO, TRANS, DIAG, NORMIN, N, AP, X, SCALE,
235 CHARACTER DIAG, NORMIN, TRANS, UPLO
241 COMPLEX AP( * ), X( * )
247 REAL ZERO, HALF, ONE, TWO
248 parameter( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0,
252 LOGICAL NOTRAN, NOUNIT, UPPER
253 INTEGER I, IMAX, IP, J, JFIRST, JINC, JLAST, JLEN
254 REAL BIGNUM, GROW, REC, SMLNUM, TJJ, TMAX, TSCAL,
256 COMPLEX CSUMJ, TJJS, USCAL, ZDUM
260 INTEGER ICAMAX, ISAMAX
262 COMPLEX CDOTC, CDOTU, CLADIV
263 EXTERNAL lsame, icamax, isamax, scasum, slamch,
271 INTRINSIC abs, aimag, cmplx, conjg, max, min, real
277 cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
278 cabs2( zdum ) = abs( real( zdum ) / 2. ) +
279 $ abs( aimag( zdum ) / 2. )
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(
'CLATPS', -info )
315 smlnum = slamch(
'Safe minimum' )
316 bignum = one / smlnum
317 smlnum = smlnum / slamch(
'Precision' )
318 bignum = one / smlnum
321 IF( lsame( normin,
'N' ) )
THEN
331 cnorm( j ) = scasum( j-1, ap( ip ), 1 )
340 cnorm( j ) = scasum( n-j, ap( ip+1 ), 1 )
350 imax = isamax( n, cnorm, 1 )
352 IF( tmax.LE.bignum*half )
THEN
355 tscal = half / ( smlnum*tmax )
356 CALL sscal( 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 ctpsv( uplo, trans, diag, n, ap, x, 1 )
549 IF( xmax.GT.bignum*half )
THEN
554 scale = ( bignum*half ) / xmax
555 CALL csscal( n, scale, x, 1 )
565 ip = jfirst*( jfirst+1 ) / 2
566 DO 110 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 csscal( n, rec, x, 1 )
594 x( j ) = cladiv( 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 csscal( n, rec, x, 1 )
617 x( j ) = cladiv( x( j ), tjjs )
639 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
644 CALL csscal( n, rec, x, 1 )
647 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
651 CALL csscal( n, half, x, 1 )
661 CALL caxpy( j-1, -x( j )*tscal, ap( ip-j+1 ), 1,
664 i = icamax( j-1, x, 1 )
665 xmax = cabs1( x( i ) )
674 CALL caxpy( n-j, -x( j )*tscal, ap( ip+1 ), 1,
676 i = j + icamax( 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 150 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 = cladiv( uscal, tjjs )
715 IF( rec.LT.one )
THEN
716 CALL csscal( n, rec, x, 1 )
723 IF( uscal.EQ.cmplx( one ) )
THEN
729 csumj = cdotu( j-1, ap( ip-j+1 ), 1, x, 1 )
730 ELSE IF( j.LT.n )
THEN
731 csumj = cdotu( 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.cmplx( 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 csscal( n, rec, x, 1 )
781 x( j ) = cladiv( x( j ), tjjs )
782 ELSE IF( tjj.GT.zero )
THEN
786 IF( xj.GT.tjj*bignum )
THEN
790 rec = ( tjj*bignum ) / xj
791 CALL csscal( n, rec, x, 1 )
795 x( j ) = cladiv( x( j ), tjjs )
814 x( j ) = cladiv( x( j ), tjjs ) - csumj
816 xmax = max( xmax, cabs1( x( j ) ) )
825 ip = jfirst*( jfirst+1 ) / 2
827 DO 190 j = jfirst, jlast, jinc
834 rec = one / max( xmax, one )
835 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
841 tjjs = conjg( ap( ip ) )*tscal
846 IF( tjj.GT.one )
THEN
850 rec = min( one, rec*tjj )
851 uscal = cladiv( uscal, tjjs )
853 IF( rec.LT.one )
THEN
854 CALL csscal( n, rec, x, 1 )
861 IF( uscal.EQ.cmplx( one ) )
THEN
867 csumj = cdotc( j-1, ap( ip-j+1 ), 1, x, 1 )
868 ELSE IF( j.LT.n )
THEN
869 csumj = cdotc( n-j, ap( ip+1 ), 1, x( j+1 ), 1 )
877 csumj = csumj + ( conjg( ap( ip-j+i ) )*uscal )*
880 ELSE IF( j.LT.n )
THEN
882 csumj = csumj + ( conjg( ap( ip+i ) )*uscal )*
888 IF( uscal.EQ.cmplx( tscal ) )
THEN
893 x( j ) = x( j ) - csumj
899 tjjs = conjg( ap( ip ) )*tscal
906 IF( tjj.GT.smlnum )
THEN
910 IF( tjj.LT.one )
THEN
911 IF( xj.GT.tjj*bignum )
THEN
916 CALL csscal( n, rec, x, 1 )
921 x( j ) = cladiv( x( j ), tjjs )
922 ELSE IF( tjj.GT.zero )
THEN
926 IF( xj.GT.tjj*bignum )
THEN
930 rec = ( tjj*bignum ) / xj
931 CALL csscal( n, rec, x, 1 )
935 x( j ) = cladiv( x( j ), tjjs )
954 x( j ) = cladiv( x( j ), tjjs ) - csumj
956 xmax = max( xmax, cabs1( x( j ) ) )
961 scale = scale / tscal
966 IF( tscal.NE.one )
THEN
967 CALL sscal( n, one / tscal, cnorm, 1 )