186 SUBROUTINE ztgex2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,
195 INTEGER INFO, J1, LDA, LDB, LDQ, LDZ, N
198 COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
205 COMPLEX*16 CZERO, CONE
206 parameter( czero = ( 0.0d+0, 0.0d+0 ),
207 $ cone = ( 1.0d+0, 0.0d+0 ) )
208 DOUBLE PRECISION TWENTY
209 parameter( twenty = 2.0d+1 )
211 parameter( ldst = 2 )
213 parameter( wands = .true. )
218 DOUBLE PRECISION CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SUM,
220 COMPLEX*16 CDUM, F, G, SQ, SZ
223 COMPLEX*16 S( LDST, LDST ), T( LDST, LDST ), WORK( 8 )
226 DOUBLE PRECISION DLAMCH
233 INTRINSIC abs, dble, dconjg, max, sqrt
250 CALL zlacpy(
'Full', m, m, a( j1, j1 ), lda, s, ldst )
251 CALL zlacpy(
'Full', m, m, b( j1, j1 ), ldb, t, ldst )
256 smlnum = dlamch(
'S' ) / eps
257 scale = dble( czero )
259 CALL zlacpy(
'Full', m, m, s, ldst, work, m )
260 CALL zlacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
261 CALL zlassq( m*m, work, 1, scale, sum )
262 sa = scale*sqrt( sum )
263 scale = dble( czero )
265 CALL zlassq( m*m, work(m*m+1), 1, scale, sum )
266 sb = scale*sqrt( sum )
276 thresha = max( twenty*eps*sa, smlnum )
277 threshb = max( twenty*eps*sb, smlnum )
282 f = s( 2, 2 )*t( 1, 1 ) - t( 2, 2 )*s( 1, 1 )
283 g = s( 2, 2 )*t( 1, 2 ) - t( 2, 2 )*s( 1, 2 )
284 sa = abs( s( 2, 2 ) ) * abs( t( 1, 1 ) )
285 sb = abs( s( 1, 1 ) ) * abs( t( 2, 2 ) )
286 CALL zlartg( g, f, cz, sz, cdum )
288 CALL zrot( 2, s( 1, 1 ), 1, s( 1, 2 ), 1, cz, dconjg( sz ) )
289 CALL zrot( 2, t( 1, 1 ), 1, t( 1, 2 ), 1, cz, dconjg( sz ) )
291 CALL zlartg( s( 1, 1 ), s( 2, 1 ), cq, sq, cdum )
293 CALL zlartg( t( 1, 1 ), t( 2, 1 ), cq, sq, cdum )
295 CALL zrot( 2, s( 1, 1 ), ldst, s( 2, 1 ), ldst, cq, sq )
296 CALL zrot( 2, t( 1, 1 ), ldst, t( 2, 1 ), ldst, cq, sq )
301 weak = abs( s( 2, 1 ) ).LE.thresha .AND.
302 $ abs( t( 2, 1 ) ).LE.threshb
313 CALL zlacpy(
'Full', m, m, s, ldst, work, m )
314 CALL zlacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
315 CALL zrot( 2, work, 1, work( 3 ), 1, cz, -dconjg( sz ) )
316 CALL zrot( 2, work( 5 ), 1, work( 7 ), 1, cz,
318 CALL zrot( 2, work, 2, work( 2 ), 2, cq, -sq )
319 CALL zrot( 2, work( 5 ), 2, work( 6 ), 2, cq, -sq )
321 work( i ) = work( i ) - a( j1+i-1, j1 )
322 work( i+2 ) = work( i+2 ) - a( j1+i-1, j1+1 )
323 work( i+4 ) = work( i+4 ) - b( j1+i-1, j1 )
324 work( i+6 ) = work( i+6 ) - b( j1+i-1, j1+1 )
326 scale = dble( czero )
328 CALL zlassq( m*m, work, 1, scale, sum )
329 sa = scale*sqrt( sum )
330 scale = dble( czero )
332 CALL zlassq( m*m, work(m*m+1), 1, scale, sum )
333 sb = scale*sqrt( sum )
334 strong = sa.LE.thresha .AND. sb.LE.threshb
342 CALL zrot( j1+1, a( 1, j1 ), 1, a( 1, j1+1 ), 1, cz,
344 CALL zrot( j1+1, b( 1, j1 ), 1, b( 1, j1+1 ), 1, cz,
346 CALL zrot( n-j1+1, a( j1, j1 ), lda, a( j1+1, j1 ), lda, cq,
348 CALL zrot( n-j1+1, b( j1, j1 ), ldb, b( j1+1, j1 ), ldb, cq,
353 a( j1+1, j1 ) = czero
354 b( j1+1, j1 ) = czero
359 $
CALL zrot( n, z( 1, j1 ), 1, z( 1, j1+1 ), 1, cz,
362 $
CALL zrot( n, q( 1, j1 ), 1, q( 1, j1+1 ), 1, cq,