175 SUBROUTINE zggbal( JOB, N, A, LDA, B, LDB, ILO, IHI, LSCALE,
176 $ RSCALE, WORK, INFO )
184 INTEGER IHI, ILO, INFO, LDA, LDB, N
187 DOUBLE PRECISION LSCALE( * ), RSCALE( * ), WORK( * )
188 COMPLEX*16 A( LDA, * ), B( LDB, * )
194 DOUBLE PRECISION ZERO, HALF, ONE
195 parameter( zero = 0.0d+0, half = 0.5d+0, one = 1.0d+0 )
196 DOUBLE PRECISION THREE, SCLFAC
197 parameter( three = 3.0d+0, sclfac = 1.0d+1 )
199 parameter( czero = ( 0.0d+0, 0.0d+0 ) )
202 INTEGER I, ICAB, IFLOW, IP1, IR, IRAB, IT, J, JC, JP1,
203 $ k, kount, l, lcab, lm1, lrab, lsfmax, lsfmin,
205 DOUBLE PRECISION ALPHA, BASL, BETA, CAB, CMAX, COEF, COEF2,
206 $ coef5, cor, ew, ewc, gamma, pgamma, rab, sfmax,
207 $ sfmin, sum, t, ta, tb, tc
213 DOUBLE PRECISION DDOT, DLAMCH
214 EXTERNAL lsame, izamax, ddot, dlamch
220 INTRINSIC abs, dble, dimag, int, log10, max, min, sign
223 DOUBLE PRECISION CABS1
226 cabs1( cdum ) = abs( dble( cdum ) ) + abs( dimag( cdum ) )
233 IF( .NOT.lsame( job,
'N' ) .AND. .NOT.lsame( job,
'P' ) .AND.
234 $ .NOT.lsame( job,
'S' ) .AND. .NOT.lsame( job,
'B' ) )
THEN
236 ELSE IF( n.LT.0 )
THEN
238 ELSE IF( lda.LT.max( 1, n ) )
THEN
240 ELSE IF( ldb.LT.max( 1, n ) )
THEN
244 CALL xerbla(
'ZGGBAL', -info )
264 IF( lsame( job,
'N' ) )
THEN
276 IF( lsame( job,
'S' ) )
299 IF( a( i, j ).NE.czero .OR. b( i, j ).NE.czero )
307 IF( a( i, j ).NE.czero .OR. b( i, j ).NE.czero )
328 IF( a( i, j ).NE.czero .OR. b( i, j ).NE.czero )
335 IF( a( i, j ).NE.czero .OR. b( i, j ).NE.czero )
352 CALL zswap( n-k+1, a( i, k ), lda, a( m, k ), lda )
353 CALL zswap( n-k+1, b( i, k ), ldb, b( m, k ), ldb )
361 CALL zswap( l, a( 1, j ), 1, a( 1, m ), 1 )
362 CALL zswap( l, b( 1, j ), 1, b( 1, m ), 1 )
365 GO TO ( 20, 90 )iflow
371 IF( lsame( job,
'P' ) )
THEN
399 basl = log10( sclfac )
402 IF( a( i, j ).EQ.czero )
THEN
406 ta = log10( cabs1( a( i, j ) ) ) / basl
409 IF( b( i, j ).EQ.czero )
THEN
413 tb = log10( cabs1( b( i, j ) ) ) / basl
416 work( i+4*n ) = work( i+4*n ) - ta - tb
417 work( j+5*n ) = work( j+5*n ) - ta - tb
421 coef = one / dble( 2*nr )
432 gamma = ddot( nr, work( ilo+4*n ), 1, work( ilo+4*n ), 1 ) +
433 $ ddot( nr, work( ilo+5*n ), 1, work( ilo+5*n ), 1 )
438 ew = ew + work( i+4*n )
439 ewc = ewc + work( i+5*n )
442 gamma = coef*gamma - coef2*( ew**2+ewc**2 ) - coef5*( ew-ewc )**2
446 $ beta = gamma / pgamma
447 t = coef5*( ewc-three*ew )
448 tc = coef5*( ew-three*ewc )
450 CALL dscal( nr, beta, work( ilo ), 1 )
451 CALL dscal( nr, beta, work( ilo+n ), 1 )
453 CALL daxpy( nr, coef, work( ilo+4*n ), 1, work( ilo+n ), 1 )
454 CALL daxpy( nr, coef, work( ilo+5*n ), 1, work( ilo ), 1 )
457 work( i ) = work( i ) + tc
458 work( i+n ) = work( i+n ) + t
467 IF( a( i, j ).EQ.czero )
470 sum = sum + work( j )
472 IF( b( i, j ).EQ.czero )
475 sum = sum + work( j )
477 work( i+2*n ) = dble( kount )*work( i+n ) + sum
484 IF( a( i, j ).EQ.czero )
487 sum = sum + work( i+n )
489 IF( b( i, j ).EQ.czero )
492 sum = sum + work( i+n )
494 work( j+3*n ) = dble( kount )*work( j ) + sum
497 sum = ddot( nr, work( ilo+n ), 1, work( ilo+2*n ), 1 ) +
498 $ ddot( nr, work( ilo ), 1, work( ilo+3*n ), 1 )
505 cor = alpha*work( i+n )
506 IF( abs( cor ).GT.cmax )
508 lscale( i ) = lscale( i ) + cor
509 cor = alpha*work( i )
510 IF( abs( cor ).GT.cmax )
512 rscale( i ) = rscale( i ) + cor
517 CALL daxpy( nr, -alpha, work( ilo+2*n ), 1, work( ilo+4*n ), 1 )
518 CALL daxpy( nr, -alpha, work( ilo+3*n ), 1, work( ilo+5*n ), 1 )
528 sfmin = dlamch(
'S' )
530 lsfmin = int( log10( sfmin ) / basl+one )
531 lsfmax = int( log10( sfmax ) / basl )
533 irab = izamax( n-ilo+1, a( i, ilo ), lda )
534 rab = abs( a( i, irab+ilo-1 ) )
535 irab = izamax( n-ilo+1, b( i, ilo ), ldb )
536 rab = max( rab, abs( b( i, irab+ilo-1 ) ) )
537 lrab = int( log10( rab+sfmin ) / basl+one )
538 ir = int(lscale( i ) + sign( half, lscale( i ) ))
539 ir = min( max( ir, lsfmin ), lsfmax, lsfmax-lrab )
540 lscale( i ) = sclfac**ir
541 icab = izamax( ihi, a( 1, i ), 1 )
542 cab = abs( a( icab, i ) )
543 icab = izamax( ihi, b( 1, i ), 1 )
544 cab = max( cab, abs( b( icab, i ) ) )
545 lcab = int( log10( cab+sfmin ) / basl+one )
546 jc = int(rscale( i ) + sign( half, rscale( i ) ))
547 jc = min( max( jc, lsfmin ), lsfmax, lsfmax-lcab )
548 rscale( i ) = sclfac**jc
554 CALL zdscal( n-ilo+1, lscale( i ), a( i, ilo ), lda )
555 CALL zdscal( n-ilo+1, lscale( i ), b( i, ilo ), ldb )
561 CALL zdscal( ihi, rscale( j ), a( 1, j ), 1 )
562 CALL zdscal( ihi, rscale( j ), b( 1, j ), 1 )
subroutine xerbla(srname, info)
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
subroutine zggbal(job, n, a, lda, b, ldb, ilo, ihi, lscale, rscale, work, info)
ZGGBAL
subroutine dscal(n, da, dx, incx)
DSCAL
subroutine zdscal(n, da, zx, incx)
ZDSCAL
subroutine zswap(n, zx, incx, zy, incy)
ZSWAP