188 SUBROUTINE ctgex2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,
197 INTEGER INFO, J1, LDA, LDB, LDQ, LDZ, N
200 COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
208 parameter( czero = ( 0.0e+0, 0.0e+0 ),
209 $ cone = ( 1.0e+0, 0.0e+0 ) )
211 parameter( twenty = 2.0e+1 )
213 parameter( ldst = 2 )
215 parameter( wands = .true. )
220 REAL CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SUM,
222 COMPLEX CDUM, F, G, SQ, SZ
225 COMPLEX S( LDST, LDST ), T( LDST, LDST ), WORK( 8 )
235 INTRINSIC abs, conjg, max, real, sqrt
252 CALL clacpy(
'Full', m, m, a( j1, j1 ), lda, s, ldst )
253 CALL clacpy(
'Full', m, m, b( j1, j1 ), ldb, t, ldst )
258 smlnum = slamch(
'S' ) / eps
259 scale = real( czero )
261 CALL clacpy(
'Full', m, m, s, ldst, work, m )
262 CALL clacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
263 CALL classq( m*m, work, 1, scale, sum )
264 sa = scale*sqrt( sum )
265 scale = dble( czero )
267 CALL classq( m*m, work(m*m+1), 1, scale, sum )
268 sb = scale*sqrt( sum )
278 thresha = max( twenty*eps*sa, smlnum )
279 threshb = max( twenty*eps*sb, smlnum )
284 f = s( 2, 2 )*t( 1, 1 ) - t( 2, 2 )*s( 1, 1 )
285 g = s( 2, 2 )*t( 1, 2 ) - t( 2, 2 )*s( 1, 2 )
286 sa = abs( s( 2, 2 ) ) * abs( t( 1, 1 ) )
287 sb = abs( s( 1, 1 ) ) * abs( t( 2, 2 ) )
288 CALL clartg( g, f, cz, sz, cdum )
290 CALL crot( 2, s( 1, 1 ), 1, s( 1, 2 ), 1, cz, conjg( sz ) )
291 CALL crot( 2, t( 1, 1 ), 1, t( 1, 2 ), 1, cz, conjg( sz ) )
293 CALL clartg( s( 1, 1 ), s( 2, 1 ), cq, sq, cdum )
295 CALL clartg( t( 1, 1 ), t( 2, 1 ), cq, sq, cdum )
297 CALL crot( 2, s( 1, 1 ), ldst, s( 2, 1 ), ldst, cq, sq )
298 CALL crot( 2, t( 1, 1 ), ldst, t( 2, 1 ), ldst, cq, sq )
303 weak = abs( s( 2, 1 ) ).LE.thresha .AND.
304 $ abs( t( 2, 1 ) ).LE.threshb
313 CALL clacpy(
'Full', m, m, s, ldst, work, m )
314 CALL clacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
315 CALL crot( 2, work, 1, work( 3 ), 1, cz, -conjg( sz ) )
316 CALL crot( 2, work( 5 ), 1, work( 7 ), 1, cz, -conjg( sz ) )
317 CALL crot( 2, work, 2, work( 2 ), 2, cq, -sq )
318 CALL crot( 2, work( 5 ), 2, work( 6 ), 2, cq, -sq )
320 work( i ) = work( i ) - a( j1+i-1, j1 )
321 work( i+2 ) = work( i+2 ) - a( j1+i-1, j1+1 )
322 work( i+4 ) = work( i+4 ) - b( j1+i-1, j1 )
323 work( i+6 ) = work( i+6 ) - b( j1+i-1, j1+1 )
325 scale = dble( czero )
327 CALL classq( m*m, work, 1, scale, sum )
328 sa = scale*sqrt( sum )
329 scale = dble( czero )
331 CALL classq( m*m, work(m*m+1), 1, scale, sum )
332 sb = scale*sqrt( sum )
333 strong = sa.LE.thresha .AND. sb.LE.threshb
341 CALL crot( j1+1, a( 1, j1 ), 1, a( 1, j1+1 ), 1, cz, conjg( sz ) )
342 CALL crot( j1+1, b( 1, j1 ), 1, b( 1, j1+1 ), 1, cz, conjg( sz ) )
343 CALL crot( n-j1+1, a( j1, j1 ), lda, a( j1+1, j1 ), lda, cq, sq )
344 CALL crot( n-j1+1, b( j1, j1 ), ldb, b( j1+1, j1 ), ldb, cq, sq )
348 a( j1+1, j1 ) = czero
349 b( j1+1, j1 ) = czero
354 $
CALL crot( n, z( 1, j1 ), 1, z( 1, j1+1 ), 1, cz, conjg( sz ) )
356 $
CALL crot( n, q( 1, j1 ), 1, q( 1, j1+1 ), 1, cq, conjg( sq ) )
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
subroutine clartg(f, g, c, s, r)
CLARTG generates a plane rotation with real cosine and complex sine.
subroutine classq(n, x, incx, scale, sumsq)
CLASSQ updates a sum of squares represented in scaled form.
subroutine crot(n, cx, incx, cy, incy, c, s)
CROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.
subroutine ctgex2(wantq, wantz, n, a, lda, b, ldb, q, ldq, z, ldz, j1, info)
CTGEX2 swaps adjacent diagonal blocks in an upper (quasi) triangular matrix pair by an unitary equiva...