188 SUBROUTINE ztgex2( WANTQ, WANTZ, N, A, LDA, B, LDB, Q, LDQ, Z,
197 INTEGER INFO, J1, LDA, LDB, LDQ, LDZ, N
200 COMPLEX*16 A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
207 COMPLEX*16 CZERO, CONE
208 parameter( czero = ( 0.0d+0, 0.0d+0 ),
209 $ cone = ( 1.0d+0, 0.0d+0 ) )
210 DOUBLE PRECISION TWENTY
211 parameter( twenty = 2.0d+1 )
213 parameter( ldst = 2 )
215 parameter( wands = .true. )
220 DOUBLE PRECISION CQ, CZ, EPS, SA, SB, SCALE, SMLNUM, SUM,
222 COMPLEX*16 CDUM, F, G, SQ, SZ
225 COMPLEX*16 S( LDST, LDST ), T( LDST, LDST ), WORK( 8 )
228 DOUBLE PRECISION DLAMCH
235 INTRINSIC abs, dble, dconjg, max, sqrt
252 CALL zlacpy(
'Full', m, m, a( j1, j1 ), lda, s, ldst )
253 CALL zlacpy(
'Full', m, m, b( j1, j1 ), ldb, t, ldst )
258 smlnum = dlamch(
'S' ) / eps
259 scale = dble( czero )
261 CALL zlacpy(
'Full', m, m, s, ldst, work, m )
262 CALL zlacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
263 CALL zlassq( m*m, work, 1, scale, sum )
264 sa = scale*sqrt( sum )
265 scale = dble( czero )
267 CALL zlassq( 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 zlartg( g, f, cz, sz, cdum )
290 CALL zrot( 2, s( 1, 1 ), 1, s( 1, 2 ), 1, cz, dconjg( sz ) )
291 CALL zrot( 2, t( 1, 1 ), 1, t( 1, 2 ), 1, cz, dconjg( sz ) )
293 CALL zlartg( s( 1, 1 ), s( 2, 1 ), cq, sq, cdum )
295 CALL zlartg( t( 1, 1 ), t( 2, 1 ), cq, sq, cdum )
297 CALL zrot( 2, s( 1, 1 ), ldst, s( 2, 1 ), ldst, cq, sq )
298 CALL zrot( 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
315 CALL zlacpy(
'Full', m, m, s, ldst, work, m )
316 CALL zlacpy(
'Full', m, m, t, ldst, work( m*m+1 ), m )
317 CALL zrot( 2, work, 1, work( 3 ), 1, cz, -dconjg( sz ) )
318 CALL zrot( 2, work( 5 ), 1, work( 7 ), 1, cz, -dconjg( sz ) )
319 CALL zrot( 2, work, 2, work( 2 ), 2, cq, -sq )
320 CALL zrot( 2, work( 5 ), 2, work( 6 ), 2, cq, -sq )
322 work( i ) = work( i ) - a( j1+i-1, j1 )
323 work( i+2 ) = work( i+2 ) - a( j1+i-1, j1+1 )
324 work( i+4 ) = work( i+4 ) - b( j1+i-1, j1 )
325 work( i+6 ) = work( i+6 ) - b( j1+i-1, j1+1 )
327 scale = dble( czero )
329 CALL zlassq( m*m, work, 1, scale, sum )
330 sa = scale*sqrt( sum )
331 scale = dble( czero )
333 CALL zlassq( m*m, work(m*m+1), 1, scale, sum )
334 sb = scale*sqrt( sum )
335 strong = sa.LE.thresha .AND. sb.LE.threshb
343 CALL zrot( j1+1, a( 1, j1 ), 1, a( 1, j1+1 ), 1, cz,
345 CALL zrot( j1+1, b( 1, j1 ), 1, b( 1, j1+1 ), 1, cz,
347 CALL zrot( n-j1+1, a( j1, j1 ), lda, a( j1+1, j1 ), lda, cq, sq )
348 CALL zrot( n-j1+1, b( j1, j1 ), ldb, b( j1+1, j1 ), ldb, cq, sq )
352 a( j1+1, j1 ) = czero
353 b( j1+1, j1 ) = czero
358 $
CALL zrot( n, z( 1, j1 ), 1, z( 1, j1+1 ), 1, cz,
361 $
CALL zrot( n, q( 1, j1 ), 1, q( 1, j1+1 ), 1, cq,
subroutine zlacpy(uplo, m, n, a, lda, b, ldb)
ZLACPY copies all or part of one two-dimensional array to another.
subroutine zlartg(f, g, c, s, r)
ZLARTG generates a plane rotation with real cosine and complex sine.
subroutine zlassq(n, x, incx, scale, sumsq)
ZLASSQ updates a sum of squares represented in scaled form.
subroutine zrot(n, cx, incx, cy, incy, c, s)
ZROT applies a plane rotation with real cosine and complex sine to a pair of complex vectors.
subroutine ztgex2(wantq, wantz, n, a, lda, b, ldb, q, ldq, z, ldz, j1, info)
ZTGEX2 swaps adjacent diagonal blocks in an upper (quasi) triangular matrix pair by an unitary equiva...