162 SUBROUTINE cgebal( JOB, N, A, LDA, ILO, IHI, SCALE, INFO )
170 INTEGER IHI, ILO, INFO, LDA, N
181 parameter( zero = 0.0e+0, one = 1.0e+0 )
183 parameter( sclfac = 2.0e+0 )
185 parameter( factor = 0.95e+0 )
188 LOGICAL NOCONV, CANSWAP
189 INTEGER I, ICA, IRA, J, K, L
190 REAL C, CA, F, G, R, RA, S, SFMAX1, SFMAX2, SFMIN1,
194 LOGICAL SISNAN, LSAME
197 EXTERNAL sisnan, lsame, icamax, slamch,
204 INTRINSIC abs, real, aimag, max, min
209 IF( .NOT.lsame( job,
'N' ) .AND.
210 $ .NOT.lsame( job,
'P' ) .AND.
211 $ .NOT.lsame( job,
'S' ) .AND.
212 $ .NOT.lsame( job,
'B' ) )
THEN
214 ELSE IF( n.LT.0 )
THEN
216 ELSE IF( lda.LT.max( 1, n ) )
THEN
220 CALL xerbla(
'CGEBAL', -info )
232 IF( lsame( job,
'N' ) )
THEN
246 IF( .NOT.lsame( job,
'S' ) )
THEN
259 IF( i.NE.j .AND. ( real( a( i, j ) ).NE.zero .OR.
260 $ aimag( a( i, j ) ).NE.zero ) )
THEN
267 scale( l ) = real( i )
269 CALL cswap( l, a( 1, i ), 1, a( 1, l ), 1 )
270 CALL cswap( n-k+1, a( i, k ), lda, a( l, k ),
296 IF( i.NE.j .AND. ( real( a( i, j ) ).NE.zero .OR.
297 $ aimag( a( i, j ) ).NE.zero ) )
THEN
304 scale( k ) = real( j )
306 CALL cswap( l, a( 1, j ), 1, a( 1, k ), 1 )
307 CALL cswap( n-k+1, a( j, k ), lda, a( k, k ),
328 IF( lsame( job,
'P' ) )
THEN
338 sfmin1 = slamch(
'S' ) / slamch(
'P' )
339 sfmax1 = one / sfmin1
340 sfmin2 = sfmin1*sclfac
341 sfmax2 = one / sfmin2
349 c = scnrm2( l-k+1, a( k, i ), 1 )
350 r = scnrm2( l-k+1, a( i, k ), lda )
351 ica = icamax( l, a( 1, i ), 1 )
352 ca = abs( a( ica, i ) )
353 ira = icamax( n-k+1, a( i, k ), lda )
354 ra = abs( a( i, ira+k-1 ) )
358 IF( c.EQ.zero .OR. r.EQ.zero ) cycle
362 IF( sisnan( c+ca+r+ra ) )
THEN
364 CALL xerbla(
'CGEBAL', -info )
372 DO WHILE( c.LT.g .AND. max( f, c, ca ).LT.sfmax2 .AND.
373 $ min( r, g, ra ).GT.sfmin2 )
384 DO WHILE( g.GE.r .AND. max( r, ra ).LT.sfmax2 .AND.
385 $ min( f, c, g, ca ).GT.sfmin2 )
396 IF( ( c+r ).GE.factor*s ) cycle
397 IF( f.LT.one .AND. scale( i ).LT.one )
THEN
398 IF( f*scale( i ).LE.sfmin1 ) cycle
400 IF( f.GT.one .AND. scale( i ).GT.one )
THEN
401 IF( scale( i ).GE.sfmax1 / f ) cycle
404 scale( i ) = scale( i )*f
407 CALL csscal( n-k+1, g, a( i, k ), lda )
408 CALL csscal( l, f, a( 1, i ), 1 )