243 SUBROUTINE clatbs( UPLO, TRANS, DIAG, NORMIN, N, KD, AB, LDAB, X,
244 $ scale, cnorm, info )
252 CHARACTER diag, normin, trans, uplo
253 INTEGER info, kd, ldab, n
258 COMPLEX ab( ldab, * ), x( * )
264 REAL zero, half, one, two
265 parameter( zero = 0.0e+0, half = 0.5e+0, one = 1.0e+0,
269 LOGICAL notran, nounit, upper
270 INTEGER i, imax, j, jfirst, jinc, jlast, jlen, maind
271 REAL bignum, grow, rec, smlnum, tjj, tmax, tscal,
273 COMPLEX csumj, tjjs, uscal, zdum
287 INTRINSIC abs, aimag, cmplx, conjg, max, min, real
293 cabs1( zdum ) = abs(
REAL( ZDUM ) ) + abs( aimag( zdum ) )
294 cabs2( zdum ) = abs(
REAL( ZDUM ) / 2. ) +
295 $ abs( aimag( zdum ) / 2. )
300 upper =
lsame( uplo,
'U' )
301 notran =
lsame( trans,
'N' )
302 nounit =
lsame( diag,
'N' )
306 IF( .NOT.upper .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
308 ELSE IF( .NOT.notran .AND. .NOT.
lsame( trans,
'T' ) .AND. .NOT.
309 $
lsame( trans,
'C' ) )
THEN
311 ELSE IF( .NOT.nounit .AND. .NOT.
lsame( diag,
'U' ) )
THEN
313 ELSE IF( .NOT.
lsame( normin,
'Y' ) .AND. .NOT.
314 $
lsame( normin,
'N' ) )
THEN
316 ELSE IF( n.LT.0 )
THEN
318 ELSE IF( kd.LT.0 )
THEN
320 ELSE IF( ldab.LT.kd+1 )
THEN
324 CALL
xerbla(
'CLATBS', -info )
335 smlnum =
slamch(
'Safe minimum' )
336 bignum = one / smlnum
337 CALL
slabad( smlnum, bignum )
338 smlnum = smlnum /
slamch(
'Precision' )
339 bignum = one / smlnum
342 IF(
lsame( normin,
'N' ) )
THEN
351 jlen = min( kd, j-1 )
352 cnorm( j ) =
scasum( jlen, ab( kd+1-jlen, j ), 1 )
359 jlen = min( kd, n-j )
361 cnorm( j ) =
scasum( jlen, ab( 2, j ), 1 )
372 imax =
isamax( n, cnorm, 1 )
374 IF( tmax.LE.bignum*half )
THEN
377 tscal = half / ( smlnum*tmax )
378 CALL
sscal( n, tscal, cnorm, 1 )
386 xmax = max( xmax, cabs2( x( j ) ) )
405 IF( tscal.NE.one )
THEN
417 grow = half / max( xbnd, smlnum )
419 DO 40 j = jfirst, jlast, jinc
426 tjjs = ab( maind, j )
429 IF( tjj.GE.smlnum )
THEN
433 xbnd = min( xbnd, min( one, tjj )*grow )
441 IF( tjj+cnorm( j ).GE.smlnum )
THEN
445 grow = grow*( tjj / ( tjj+cnorm( j ) ) )
460 grow = min( one, half / max( xbnd, smlnum ) )
461 DO 50 j = jfirst, jlast, jinc
470 grow = grow*( one / ( one+cnorm( j ) ) )
491 IF( tscal.NE.one )
THEN
503 grow = half / max( xbnd, smlnum )
505 DO 70 j = jfirst, jlast, jinc
514 xj = one + cnorm( j )
515 grow = min( grow, xbnd / xj )
517 tjjs = ab( maind, j )
520 IF( tjj.GE.smlnum )
THEN
525 $ xbnd = xbnd*( tjj / xj )
533 grow = min( grow, xbnd )
540 grow = min( one, half / max( xbnd, smlnum ) )
541 DO 80 j = jfirst, jlast, jinc
550 xj = one + cnorm( j )
557 IF( ( grow*tscal ).GT.smlnum )
THEN
562 CALL
ctbsv( uplo, trans, diag, n, kd, ab, ldab, x, 1 )
567 IF( xmax.GT.bignum*half )
THEN
572 scale = ( bignum*half ) / xmax
573 CALL
csscal( n, scale, x, 1 )
583 DO 110 j = jfirst, jlast, jinc
589 tjjs = ab( maind, j )*tscal
596 IF( tjj.GT.smlnum )
THEN
600 IF( tjj.LT.one )
THEN
601 IF( xj.GT.tjj*bignum )
THEN
606 CALL
csscal( n, rec, x, 1 )
611 x( j ) =
cladiv( x( j ), tjjs )
613 ELSE IF( tjj.GT.zero )
THEN
617 IF( xj.GT.tjj*bignum )
THEN
622 rec = ( tjj*bignum ) / xj
623 IF( cnorm( j ).GT.one )
THEN
628 rec = rec / cnorm( j )
630 CALL
csscal( n, rec, x, 1 )
634 x( j ) =
cladiv( x( j ), tjjs )
656 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
661 CALL
csscal( n, rec, x, 1 )
664 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
668 CALL
csscal( n, half, x, 1 )
679 jlen = min( kd, j-1 )
680 CALL
caxpy( jlen, -x( j )*tscal,
681 $ ab( kd+1-jlen, j ), 1, x( j-jlen ), 1 )
683 xmax = cabs1( x( i ) )
685 ELSE IF( j.LT.n )
THEN
691 jlen = min( kd, n-j )
693 $ CALL
caxpy( jlen, -x( j )*tscal, ab( 2, j ), 1,
695 i = j +
icamax( n-j, x( j+1 ), 1 )
696 xmax = cabs1( x( i ) )
700 ELSE IF(
lsame( trans,
'T' ) )
THEN
704 DO 150 j = jfirst, jlast, jinc
711 rec = one / max( xmax, one )
712 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
718 tjjs = ab( maind, j )*tscal
723 IF( tjj.GT.one )
THEN
727 rec = min( one, rec*tjj )
728 uscal =
cladiv( uscal, tjjs )
730 IF( rec.LT.one )
THEN
731 CALL
csscal( n, rec, x, 1 )
738 IF( uscal.EQ.cmplx( one ) )
THEN
744 jlen = min( kd, j-1 )
745 csumj =
cdotu( jlen, ab( kd+1-jlen, j ), 1,
748 jlen = min( kd, n-j )
750 $ csumj =
cdotu( jlen, ab( 2, j ), 1, x( j+1 ),
758 jlen = min( kd, j-1 )
760 csumj = csumj + ( ab( kd+i-jlen, j )*uscal )*
764 jlen = min( kd, n-j )
766 csumj = csumj + ( ab( i+1, j )*uscal )*x( j+i )
771 IF( uscal.EQ.cmplx( tscal ) )
THEN
776 x( j ) = x( j ) - csumj
782 tjjs = ab( maind, j )*tscal
789 IF( tjj.GT.smlnum )
THEN
793 IF( tjj.LT.one )
THEN
794 IF( xj.GT.tjj*bignum )
THEN
799 CALL
csscal( n, rec, x, 1 )
804 x( j ) =
cladiv( x( j ), tjjs )
805 ELSE IF( tjj.GT.zero )
THEN
809 IF( xj.GT.tjj*bignum )
THEN
813 rec = ( tjj*bignum ) / xj
814 CALL
csscal( n, rec, x, 1 )
818 x( j ) =
cladiv( x( j ), tjjs )
837 x( j ) =
cladiv( x( j ), tjjs ) - csumj
839 xmax = max( xmax, cabs1( x( j ) ) )
846 DO 190 j = jfirst, jlast, jinc
853 rec = one / max( xmax, one )
854 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
860 tjjs = conjg( ab( maind, j ) )*tscal
865 IF( tjj.GT.one )
THEN
869 rec = min( one, rec*tjj )
870 uscal =
cladiv( uscal, tjjs )
872 IF( rec.LT.one )
THEN
873 CALL
csscal( n, rec, x, 1 )
880 IF( uscal.EQ.cmplx( one ) )
THEN
886 jlen = min( kd, j-1 )
887 csumj =
cdotc( jlen, ab( kd+1-jlen, j ), 1,
890 jlen = min( kd, n-j )
892 $ csumj =
cdotc( jlen, ab( 2, j ), 1, x( j+1 ),
900 jlen = min( kd, j-1 )
902 csumj = csumj + ( conjg( ab( kd+i-jlen, j ) )*
903 $ uscal )*x( j-jlen-1+i )
906 jlen = min( kd, n-j )
908 csumj = csumj + ( conjg( ab( i+1, j ) )*uscal )*
914 IF( uscal.EQ.cmplx( tscal ) )
THEN
919 x( j ) = x( j ) - csumj
925 tjjs = conjg( ab( maind, j ) )*tscal
932 IF( tjj.GT.smlnum )
THEN
936 IF( tjj.LT.one )
THEN
937 IF( xj.GT.tjj*bignum )
THEN
942 CALL
csscal( n, rec, x, 1 )
947 x( j ) =
cladiv( x( j ), tjjs )
948 ELSE IF( tjj.GT.zero )
THEN
952 IF( xj.GT.tjj*bignum )
THEN
956 rec = ( tjj*bignum ) / xj
957 CALL
csscal( n, rec, x, 1 )
961 x( j ) =
cladiv( x( j ), tjjs )
980 x( j ) =
cladiv( x( j ), tjjs ) - csumj
982 xmax = max( xmax, cabs1( x( j ) ) )
985 scale = scale / tscal
990 IF( tscal.NE.one )
THEN
991 CALL
sscal( n, one / tscal, cnorm, 1 )