1 *> \brief \b ZTGSY2 solves the generalized Sylvester equation (unblocked algorithm).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZTGSY2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsy2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsy2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsy2.f">
21 * SUBROUTINE ZTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
22 * LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
25 * .. Scalar Arguments ..
27 * INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N
28 * DOUBLE PRECISION RDSCAL, RDSUM, SCALE
30 * .. Array Arguments ..
31 * COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
32 * $ D( LDD, * ), E( LDE, * ), F( LDF, * )
41 *> ZTGSY2 solves the generalized Sylvester equation
43 *> A * R - L * B = scale * C (1)
44 *> D * R - L * E = scale * F
46 *> using Level 1 and 2 BLAS, where R and L are unknown M-by-N matrices,
47 *> (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M,
48 *> N-by-N and M-by-N, respectively. A, B, D and E are upper triangular
49 *> (i.e., (A,D) and (B,E) in generalized Schur form).
51 *> The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output
52 *> scaling factor chosen to avoid overflow.
54 *> In matrix notation solving equation (1) corresponds to solve
55 *> Zx = scale * b, where Z is defined as
57 *> Z = [ kron(In, A) -kron(B**H, Im) ] (2)
58 *> [ kron(In, D) -kron(E**H, Im) ],
60 *> Ik is the identity matrix of size k and X**H is the conjuguate transpose of X.
61 *> kron(X, Y) is the Kronecker product between the matrices X and Y.
63 *> If TRANS = 'C', y in the conjugate transposed system Z**H*y = scale*b
64 *> is solved for, which is equivalent to solve for R and L in
66 *> A**H * R + D**H * L = scale * C (3)
67 *> R * B**H + L * E**H = scale * -F
69 *> This case is used to compute an estimate of Dif[(A, D), (B, E)] =
70 *> = sigma_min(Z) using reverse communicaton with ZLACON.
72 *> ZTGSY2 also (IJOB >= 1) contributes to the computation in ZTGSYL
73 *> of an upper bound on the separation between to matrix pairs. Then
74 *> the input (A, D), (B, E) are sub-pencils of two matrix pairs in
83 *> TRANS is CHARACTER*1
84 *> = 'N', solve the generalized Sylvester equation (1).
85 *> = 'T': solve the 'transposed' system (3).
91 *> Specifies what kind of functionality to be performed.
92 *> =0: solve (1) only.
93 *> =1: A contribution from this subsystem to a Frobenius
94 *> norm-based estimate of the separation between two matrix
95 *> pairs is computed. (look ahead strategy is used).
96 *> =2: A contribution from this subsystem to a Frobenius
97 *> norm-based estimate of the separation between two matrix
98 *> pairs is computed. (DGECON on sub-systems is used.)
99 *> Not referenced if TRANS = 'T'.
105 *> On entry, M specifies the order of A and D, and the row
106 *> dimension of C, F, R and L.
112 *> On entry, N specifies the order of B and E, and the column
113 *> dimension of C, F, R and L.
118 *> A is COMPLEX*16 array, dimension (LDA, M)
119 *> On entry, A contains an upper triangular matrix.
125 *> The leading dimension of the matrix A. LDA >= max(1, M).
130 *> B is COMPLEX*16 array, dimension (LDB, N)
131 *> On entry, B contains an upper triangular matrix.
137 *> The leading dimension of the matrix B. LDB >= max(1, N).
142 *> C is COMPLEX*16 array, dimension (LDC, N)
143 *> On entry, C contains the right-hand-side of the first matrix
145 *> On exit, if IJOB = 0, C has been overwritten by the solution
152 *> The leading dimension of the matrix C. LDC >= max(1, M).
157 *> D is COMPLEX*16 array, dimension (LDD, M)
158 *> On entry, D contains an upper triangular matrix.
164 *> The leading dimension of the matrix D. LDD >= max(1, M).
169 *> E is COMPLEX*16 array, dimension (LDE, N)
170 *> On entry, E contains an upper triangular matrix.
176 *> The leading dimension of the matrix E. LDE >= max(1, N).
181 *> F is COMPLEX*16 array, dimension (LDF, N)
182 *> On entry, F contains the right-hand-side of the second matrix
184 *> On exit, if IJOB = 0, F has been overwritten by the solution
191 *> The leading dimension of the matrix F. LDF >= max(1, M).
196 *> SCALE is DOUBLE PRECISION
197 *> On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions
198 *> R and L (C and F on entry) will hold the solutions to a
199 *> slightly perturbed system but the input matrices A, B, D and
200 *> E have not been changed. If SCALE = 0, R and L will hold the
201 *> solutions to the homogeneous system with C = F = 0.
202 *> Normally, SCALE = 1.
205 *> \param[in,out] RDSUM
207 *> RDSUM is DOUBLE PRECISION
208 *> On entry, the sum of squares of computed contributions to
209 *> the Dif-estimate under computation by ZTGSYL, where the
210 *> scaling factor RDSCAL (see below) has been factored out.
211 *> On exit, the corresponding sum of squares updated with the
212 *> contributions from the current sub-system.
213 *> If TRANS = 'T' RDSUM is not touched.
214 *> NOTE: RDSUM only makes sense when ZTGSY2 is called by
218 *> \param[in,out] RDSCAL
220 *> RDSCAL is DOUBLE PRECISION
221 *> On entry, scaling factor used to prevent overflow in RDSUM.
222 *> On exit, RDSCAL is updated w.r.t. the current contributions
224 *> If TRANS = 'T', RDSCAL is not touched.
225 *> NOTE: RDSCAL only makes sense when ZTGSY2 is called by
232 *> On exit, if INFO is set to
233 *> =0: Successful exit
234 *> <0: If INFO = -i, input argument number i is illegal.
235 *> >0: The matrix pairs (A, D) and (B, E) have common or very
236 *> close eigenvalues.
242 *> \author Univ. of Tennessee
243 *> \author Univ. of California Berkeley
244 *> \author Univ. of Colorado Denver
247 *> \date November 2015
249 *> \ingroup complex16SYauxiliary
251 *> \par Contributors:
254 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
255 *> Umea University, S-901 87 Umea, Sweden.
257 * =====================================================================
258 SUBROUTINE ZTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
259 $ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
262 * -- LAPACK auxiliary routine (version 3.6.0) --
263 * -- LAPACK is a software package provided by Univ. of Tennessee, --
264 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
267 * .. Scalar Arguments ..
269 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N
270 DOUBLE PRECISION RDSCAL, RDSUM, SCALE
272 * .. Array Arguments ..
273 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
274 $ D( LDD, * ), E( LDE, * ), F( LDF, * )
277 * =====================================================================
280 DOUBLE PRECISION ZERO, ONE
282 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, LDZ = 2 )
284 * .. Local Scalars ..
286 INTEGER I, IERR, J, K
287 DOUBLE PRECISION SCALOC
291 INTEGER IPIV( LDZ ), JPIV( LDZ )
292 COMPLEX*16 RHS( LDZ ), Z( LDZ, LDZ )
294 * .. External Functions ..
298 * .. External Subroutines ..
299 EXTERNAL XERBLA, ZAXPY, ZGESC2, ZGETC2, ZLATDF, ZSCAL
301 * .. Intrinsic Functions ..
302 INTRINSIC DCMPLX, DCONJG, MAX
304 * .. Executable Statements ..
306 * Decode and test input parameters
310 NOTRAN = LSAME( TRANS, 'N' )
311 IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'C' ) ) THEN
313 ELSE IF( NOTRAN ) THEN
314 IF( ( IJOB.LT.0 ) .OR. ( IJOB.GT.2 ) ) THEN
321 ELSE IF( N.LE.0 ) THEN
323 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
325 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
327 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
329 ELSE IF( LDD.LT.MAX( 1, M ) ) THEN
331 ELSE IF( LDE.LT.MAX( 1, N ) ) THEN
333 ELSE IF( LDF.LT.MAX( 1, M ) ) THEN
338 CALL XERBLA( 'ZTGSY2', -INFO )
344 * Solve (I, J) - system
345 * A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)
346 * D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)
347 * for I = M, M - 1, ..., 1; J = 1, 2, ..., N
354 * Build 2 by 2 system
356 Z( 1, 1 ) = A( I, I )
357 Z( 2, 1 ) = D( I, I )
358 Z( 1, 2 ) = -B( J, J )
359 Z( 2, 2 ) = -E( J, J )
361 * Set up right hand side(s)
368 CALL ZGETC2( LDZ, Z, LDZ, IPIV, JPIV, IERR )
372 CALL ZGESC2( LDZ, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
373 IF( SCALOC.NE.ONE ) THEN
375 CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),
377 CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ),
383 CALL ZLATDF( IJOB, LDZ, Z, LDZ, RHS, RDSUM, RDSCAL,
387 * Unpack solution vector(s)
392 * Substitute R(I, J) and L(I, J) into remaining equation.
396 CALL ZAXPY( I-1, ALPHA, A( 1, I ), 1, C( 1, J ), 1 )
397 CALL ZAXPY( I-1, ALPHA, D( 1, I ), 1, F( 1, J ), 1 )
400 CALL ZAXPY( N-J, RHS( 2 ), B( J, J+1 ), LDB,
402 CALL ZAXPY( N-J, RHS( 2 ), E( J, J+1 ), LDE,
410 * Solve transposed (I, J) - system:
411 * A(I, I)**H * R(I, J) + D(I, I)**H * L(J, J) = C(I, J)
412 * R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J)
413 * for I = 1, 2, ..., M, J = N, N - 1, ..., 1
420 * Build 2 by 2 system Z**H
422 Z( 1, 1 ) = DCONJG( A( I, I ) )
423 Z( 2, 1 ) = -DCONJG( B( J, J ) )
424 Z( 1, 2 ) = DCONJG( D( I, I ) )
425 Z( 2, 2 ) = -DCONJG( E( J, J ) )
428 * Set up right hand side(s)
433 * Solve Z**H * x = RHS
435 CALL ZGETC2( LDZ, Z, LDZ, IPIV, JPIV, IERR )
438 CALL ZGESC2( LDZ, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
439 IF( SCALOC.NE.ONE ) THEN
441 CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), C( 1, K ),
443 CALL ZSCAL( M, DCMPLX( SCALOC, ZERO ), F( 1, K ),
449 * Unpack solution vector(s)
454 * Substitute R(I, J) and L(I, J) into remaining equation.
457 F( I, K ) = F( I, K ) + RHS( 1 )*DCONJG( B( K, J ) ) +
458 $ RHS( 2 )*DCONJG( E( K, J ) )
461 C( K, J ) = C( K, J ) - DCONJG( A( I, K ) )*RHS( 1 ) -
462 $ DCONJG( D( I, K ) )*RHS( 2 )