1 SUBROUTINE csteqr2( COMPZ, N, D, E, Z, LDZ, NR, WORK, INFO )
10 INTEGER INFO, LDZ, N, NR
13 REAL D( * ), E( * ), WORK( * )
85 REAL ZERO, ONE, TWO, THREE, HALF
86 parameter( zero = 0.0e0, one = 1.0e0, two = 2.0e0,
87 $ three = 3.0e0, half = 0.5e0 )
89 parameter( cone = ( 1.0e0, 1.0e0 ) )
90 INTEGER MAXIT, NMAXLOOK
91 parameter( maxit = 30, nmaxlook = 15 )
94 INTEGER I, ICOMPZ, II, ILAST, ISCALE, J, JTOT, K, L,
95 $ L1, LEND, LENDM1, LENDP1, LENDSV, LM1, LSV, M,
96 $ MM, MM1, NLOOK, NM1, NMAXIT
97 REAL ANORM, B, C, EPS, EPS2, F, G, GP, OLDEL, OLDGP,
98 $ OLDRP, P, R, RP, RT1, RT2, S, SAFMAX, SAFMIN,
99 $ SSFMAX, SSFMIN, TST, TST1
103 REAL SLAMCH, SLANST, SLAPY2
104 EXTERNAL lsame, slamch, slanst, slapy2
107 EXTERNAL clasr, cswap, slaev2, slartg, slascl, ssterf,
111 INTRINSIC abs,
max, sign, sqrt
120 IF( lsame( compz,
'N' ) )
THEN
122 ELSEIF( lsame( compz,
'I' ) )
THEN
127 IF( icompz.LT.0 )
THEN
129 ELSEIF( n.LT.0 )
THEN
131 ELSEIF( icompz.GT.0 .AND. ldz.LT.
max( 1, nr ) )
THEN
135 CALL xerbla(
'CSTEQR2', -info )
146 IF( icompz.EQ.0 )
THEN
147 CALL ssterf( n, d, e, info )
160 safmin = slamch(
'S' )
161 safmax = one / safmin
162 ssfmax = sqrt( safmax ) / three
163 ssfmin = sqrt( safmin ) / eps2
188 IF( tst.LE.( sqrt( abs( d( m ) ) )*sqrt( abs( d( m+
189 $ 1 ) ) ) )*eps )
THEN
208 anorm = slanst(
'I', lend-l+1, d( l ), e( l ) )
212 IF( anorm.GT.ssfmax )
THEN
214 CALL slascl(
'G', 0, 0, anorm, ssfmax, lend-l+1, 1, d( l ), n,
216 CALL slascl(
'G', 0, 0, anorm, ssfmax, lend-l, 1, e( l ), n,
218 ELSEIF( anorm.LT.ssfmin )
THEN
220 CALL slascl(
'G', 0, 0, anorm, ssfmin, lend-l+1, 1, d( l ), n,
222 CALL slascl(
'G', 0, 0, anorm, ssfmin, lend-l, 1, e( l ), n,
228 IF( abs( d( lend ) ).LT.abs( d( l ) ) )
THEN
243 tst = abs( e( m ) )**2
244 IF( tst.LE.( eps2*abs( d( m ) ) )*abs( d( m+1 ) )+
262 CALL slaev2( d( l ), e( l ), d( l+1 ), rt1, rt2, c, s )
265 CALL clasr(
'R',
'V',
'B', nr, 2, work( l ), work( n-1+l ),
282 g = ( d( l+1 )-p ) / ( two*e( l ) )
284 g = d( m ) - p + ( e( l ) / ( g+sign( r, g ) ) )
286 IF( icompz.EQ.0 )
THEN
291 oldel = abs( e( l ) )
294 tst = abs( e( l ) )**2
295 tst = tst / ( ( eps2*abs( d( l ) ) )*abs( d( l+1 ) )+safmin )
298 IF( ( tst.GT.one ) .AND. ( nlook.LE.nmaxlook ) )
THEN
311 CALL slartg( gp, f, c, s, rp )
313 rp = ( d( i )-gp )*s + two*c*b
321 IF( abs( c*oldrp-b ).GT.safmin )
THEN
322 gp = ( ( oldgp+p )-( d( l )-p ) ) / ( two*( c*oldrp-b ) )
331 rp = slapy2( gp, one )
332 gp = d( m ) - ( d( l )-p ) +
333 $ ( ( c*oldrp-b ) / ( gp+sign( rp, gp ) ) )
335 tst = abs( c*oldrp-b )**2
336 tst = tst / ( ( eps2*abs( d( l )-p ) )*abs( oldgp+p )+
339 IF( abs( c*oldrp-b ).GT.0.9e0*oldel )
THEN
340 IF( abs( c*oldrp-b ).GT.oldel )
THEN
346 oldel = abs( c*oldrp-b )
349 IF( ( tst.GT.one ) .AND. ( nlook.LE.nmaxlook ) )
353 IF( ( tst.LE.one ) .AND. ( tst.NE.half ) .AND.
354 $ ( abs( p ).LT.eps*abs( d( l ) ) ) .AND.
355 $ ( ilast.EQ.l ) .AND. ( abs( e( l ) )**2.LE.10000.0e0*
356 $ ( ( eps2*abs( d( l ) ) )*abs( d( l+1 ) )+safmin ) ) )
THEN
380 DO 100 i = mm1, l, -1
383 CALL slartg( g, f, c, s, r )
387 r = ( d( i )-g )*s + two*c*b
402 CALL clasr(
'R',
'V',
'B', nr, mm, work( l ), work( n-1+l ),
429 DO 130 m = l, lendp1, -1
430 tst = abs( e( m-1 ) )**2
431 IF( tst.LE.( eps2*abs( d( m ) ) )*abs( d( m-1 ) )+
449 CALL slaev2( d( l-1 ), e( l-1 ), d( l ), rt1, rt2, c, s )
452 CALL clasr(
'R',
'V',
'F', nr, 2, work( m ), work( n-1+m ),
469 g = ( d( l-1 )-p ) / ( two*e( l-1 ) )
471 g = d( m ) - p + ( e( l-1 ) / ( g+sign( r, g ) ) )
473 IF( icompz.EQ.0 )
THEN
478 oldel = abs( e( l-1 ) )
481 tst = abs( e( l-1 ) )**2
482 tst = tst / ( ( eps2*abs( d( l ) ) )*abs( d( l-1 ) )+safmin )
484 IF( ( tst.GT.one ) .AND. ( nlook.LE.nmaxlook ) )
THEN
500 CALL slartg( gp, f, c, s, rp )
502 rp = ( d( i+1 )-gp )*s + two*c*b
510 IF( abs( c*oldrp-b ).GT.safmin )
THEN
511 gp = ( ( oldgp+p )-( d( l )-p ) ) / ( two*( c*oldrp-b ) )
520 rp = slapy2( gp, one )
521 gp = d( m ) - ( d( l )-p ) +
522 $ ( ( c*oldrp-b ) / ( gp+sign( rp, gp ) ) )
524 tst = abs( ( c*oldrp-b ) )**2
525 tst = tst / ( ( eps2*abs( d( l )-p ) )*abs( oldgp+p )+
528 IF( abs( c*oldrp-b ).GT.0.9e0*oldel )
THEN
529 IF( abs( c*oldrp-b ).GT.oldel )
THEN
535 oldel = abs( c*oldrp-b )
538 IF( ( tst.GT.one ) .AND. ( nlook.LE.nmaxlook ) )
541 IF( ( tst.LE.one ) .AND. ( tst.NE.half ) .AND.
542 $ ( abs( p ).LT.eps*abs( d( l ) ) ) .AND.
543 $ ( ilast.EQ.l ) .AND. ( abs( e( l-1 ) )**2.LE.10000.0e0*
544 $ ( ( eps2*abs( d( l-1 ) ) )*abs( d( l ) )+safmin ) ) )
THEN
568 CALL slartg( g, f, c, s, r )
572 r = ( d( i+1 )-g )*s + two*c*b
587 CALL clasr(
'R',
'V',
'F', nr, mm, work( m ), work( n-1+m ),
610 IF( iscale.EQ.1 )
THEN
611 CALL slascl(
'G', 0, 0, ssfmax, anorm, lendsv-lsv+1, 1,
612 $ d( lsv ), n, info )
613 CALL slascl(
'G', 0, 0, ssfmax, anorm, lendsv-lsv, 1, e( lsv ),
615 ELSEIF( iscale.EQ.2 )
THEN
616 CALL slascl(
'G', 0, 0, ssfmin, anorm, lendsv-lsv+1, 1,
617 $ d( lsv ), n, info )
618 CALL slascl(
'G', 0, 0, ssfmin, anorm, lendsv-lsv, 1, e( lsv ),
644 IF( d( j ).LT.p )
THEN
652 CALL cswap( nr, z( 1, i ), 1, z( 1, k ), 1 )