243 SUBROUTINE zlatbs( 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
254 DOUBLE PRECISION scale
257 DOUBLE PRECISION cnorm( * )
258 COMPLEX*16 ab( ldab, * ), x( * )
264 DOUBLE PRECISION zero, half, one, two
265 parameter( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0,
269 LOGICAL notran, nounit, upper
270 INTEGER i, imax, j, jfirst, jinc, jlast, jlen, maind
271 DOUBLE PRECISION bignum, grow, rec, smlnum, tjj, tmax, tscal,
273 COMPLEX*16 csumj, tjjs, uscal, zdum
287 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
290 DOUBLE PRECISION cabs1, cabs2
293 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
294 cabs2( zdum ) = abs( dble( zdum ) / 2.d0 ) +
295 $ abs( dimag( zdum ) / 2.d0 )
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(
'ZLATBS', -info )
335 smlnum =
dlamch(
'Safe minimum' )
336 bignum = one / smlnum
337 CALL
dlabad( smlnum, bignum )
338 smlnum = smlnum /
dlamch(
'Precision' )
339 bignum = one / smlnum
342 IF(
lsame( normin,
'N' ) )
THEN
351 jlen = min( kd, j-1 )
352 cnorm( j ) =
dzasum( jlen, ab( kd+1-jlen, j ), 1 )
359 jlen = min( kd, n-j )
361 cnorm( j ) =
dzasum( jlen, ab( 2, j ), 1 )
372 imax =
idamax( n, cnorm, 1 )
374 IF( tmax.LE.bignum*half )
THEN
377 tscal = half / ( smlnum*tmax )
378 CALL
dscal( 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
ztbsv( uplo, trans, diag, n, kd, ab, ldab, x, 1 )
567 IF( xmax.GT.bignum*half )
THEN
572 scale = ( bignum*half ) / xmax
573 CALL
zdscal( n, scale, x, 1 )
583 DO 120 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
zdscal( n, rec, x, 1 )
611 x( j ) =
zladiv( 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
zdscal( n, rec, x, 1 )
634 x( j ) =
zladiv( x( j ), tjjs )
656 IF( cnorm( j ).GT.( bignum-xmax )*rec )
THEN
661 CALL
zdscal( n, rec, x, 1 )
664 ELSE IF( xj*cnorm( j ).GT.( bignum-xmax ) )
THEN
668 CALL
zdscal( n, half, x, 1 )
679 jlen = min( kd, j-1 )
680 CALL
zaxpy( 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
zaxpy( jlen, -x( j )*tscal, ab( 2, j ), 1,
695 i = j +
izamax( n-j, x( j+1 ), 1 )
696 xmax = cabs1( x( i ) )
700 ELSE IF(
lsame( trans,
'T' ) )
THEN
704 DO 170 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 =
zladiv( uscal, tjjs )
730 IF( rec.LT.one )
THEN
731 CALL
zdscal( n, rec, x, 1 )
738 IF( uscal.EQ.dcmplx( one ) )
THEN
744 jlen = min( kd, j-1 )
745 csumj =
zdotu( jlen, ab( kd+1-jlen, j ), 1,
748 jlen = min( kd, n-j )
750 $ csumj =
zdotu( 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.dcmplx( 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
zdscal( n, rec, x, 1 )
804 x( j ) =
zladiv( x( j ), tjjs )
805 ELSE IF( tjj.GT.zero )
THEN
809 IF( xj.GT.tjj*bignum )
THEN
813 rec = ( tjj*bignum ) / xj
814 CALL
zdscal( n, rec, x, 1 )
818 x( j ) =
zladiv( x( j ), tjjs )
837 x( j ) =
zladiv( x( j ), tjjs ) - csumj
839 xmax = max( xmax, cabs1( x( j ) ) )
846 DO 220 j = jfirst, jlast, jinc
853 rec = one / max( xmax, one )
854 IF( cnorm( j ).GT.( bignum-xj )*rec )
THEN
860 tjjs = dconjg( ab( maind, j ) )*tscal
865 IF( tjj.GT.one )
THEN
869 rec = min( one, rec*tjj )
870 uscal =
zladiv( uscal, tjjs )
872 IF( rec.LT.one )
THEN
873 CALL
zdscal( n, rec, x, 1 )
880 IF( uscal.EQ.dcmplx( one ) )
THEN
886 jlen = min( kd, j-1 )
887 csumj =
zdotc( jlen, ab( kd+1-jlen, j ), 1,
890 jlen = min( kd, n-j )
892 $ csumj =
zdotc( jlen, ab( 2, j ), 1, x( j+1 ),
900 jlen = min( kd, j-1 )
902 csumj = csumj + ( dconjg( ab( kd+i-jlen, j ) )*
903 $ uscal )*x( j-jlen-1+i )
906 jlen = min( kd, n-j )
908 csumj = csumj + ( dconjg( ab( i+1, j ) )*uscal )
914 IF( uscal.EQ.dcmplx( tscal ) )
THEN
919 x( j ) = x( j ) - csumj
925 tjjs = dconjg( 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
zdscal( n, rec, x, 1 )
947 x( j ) =
zladiv( x( j ), tjjs )
948 ELSE IF( tjj.GT.zero )
THEN
952 IF( xj.GT.tjj*bignum )
THEN
956 rec = ( tjj*bignum ) / xj
957 CALL
zdscal( n, rec, x, 1 )
961 x( j ) =
zladiv( x( j ), tjjs )
980 x( j ) =
zladiv( x( j ), tjjs ) - csumj
982 xmax = max( xmax, cabs1( x( j ) ) )
985 scale = scale / tscal
990 IF( tscal.NE.one )
THEN
991 CALL
dscal( n, one / tscal, cnorm, 1 )