LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ztgsy2.f
Go to the documentation of this file.
1*> \brief \b ZTGSY2 solves the generalized Sylvester equation (unblocked algorithm).
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download ZTGSY2 + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztgsy2.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztgsy2.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztgsy2.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE ZTGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
20* LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
21* INFO )
22*
23* .. Scalar Arguments ..
24* CHARACTER TRANS
25* INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N
26* DOUBLE PRECISION RDSCAL, RDSUM, SCALE
27* ..
28* .. Array Arguments ..
29* COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
30* $ D( LDD, * ), E( LDE, * ), F( LDF, * )
31* ..
32*
33*
34*> \par Purpose:
35* =============
36*>
37*> \verbatim
38*>
39*> ZTGSY2 solves the generalized Sylvester equation
40*>
41*> A * R - L * B = scale * C (1)
42*> D * R - L * E = scale * F
43*>
44*> using Level 1 and 2 BLAS, where R and L are unknown M-by-N matrices,
45*> (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M,
46*> N-by-N and M-by-N, respectively. A, B, D and E are upper triangular
47*> (i.e., (A,D) and (B,E) in generalized Schur form).
48*>
49*> The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output
50*> scaling factor chosen to avoid overflow.
51*>
52*> In matrix notation solving equation (1) corresponds to solve
53*> Zx = scale * b, where Z is defined as
54*>
55*> Z = [ kron(In, A) -kron(B**H, Im) ] (2)
56*> [ kron(In, D) -kron(E**H, Im) ],
57*>
58*> Ik is the identity matrix of size k and X**H is the conjugate transpose of X.
59*> kron(X, Y) is the Kronecker product between the matrices X and Y.
60*>
61*> If TRANS = 'C', y in the conjugate transposed system Z**H*y = scale*b
62*> is solved for, which is equivalent to solve for R and L in
63*>
64*> A**H * R + D**H * L = scale * C (3)
65*> R * B**H + L * E**H = scale * -F
66*>
67*> This case is used to compute an estimate of Dif[(A, D), (B, E)] =
68*> = sigma_min(Z) using reverse communication with ZLACON.
69*>
70*> ZTGSY2 also (IJOB >= 1) contributes to the computation in ZTGSYL
71*> of an upper bound on the separation between to matrix pairs. Then
72*> the input (A, D), (B, E) are sub-pencils of two matrix pairs in
73*> ZTGSYL.
74*> \endverbatim
75*
76* Arguments:
77* ==========
78*
79*> \param[in] TRANS
80*> \verbatim
81*> TRANS is CHARACTER*1
82*> = 'N': solve the generalized Sylvester equation (1).
83*> = 'T': solve the 'transposed' system (3).
84*> \endverbatim
85*>
86*> \param[in] IJOB
87*> \verbatim
88*> IJOB is INTEGER
89*> Specifies what kind of functionality to be performed.
90*> =0: solve (1) only.
91*> =1: A contribution from this subsystem to a Frobenius
92*> norm-based estimate of the separation between two matrix
93*> pairs is computed. (look ahead strategy is used).
94*> =2: A contribution from this subsystem to a Frobenius
95*> norm-based estimate of the separation between two matrix
96*> pairs is computed. (DGECON on sub-systems is used.)
97*> Not referenced if TRANS = 'T'.
98*> \endverbatim
99*>
100*> \param[in] M
101*> \verbatim
102*> M is INTEGER
103*> On entry, M specifies the order of A and D, and the row
104*> dimension of C, F, R and L.
105*> \endverbatim
106*>
107*> \param[in] N
108*> \verbatim
109*> N is INTEGER
110*> On entry, N specifies the order of B and E, and the column
111*> dimension of C, F, R and L.
112*> \endverbatim
113*>
114*> \param[in] A
115*> \verbatim
116*> A is COMPLEX*16 array, dimension (LDA, M)
117*> On entry, A contains an upper triangular matrix.
118*> \endverbatim
119*>
120*> \param[in] LDA
121*> \verbatim
122*> LDA is INTEGER
123*> The leading dimension of the matrix A. LDA >= max(1, M).
124*> \endverbatim
125*>
126*> \param[in] B
127*> \verbatim
128*> B is COMPLEX*16 array, dimension (LDB, N)
129*> On entry, B contains an upper triangular matrix.
130*> \endverbatim
131*>
132*> \param[in] LDB
133*> \verbatim
134*> LDB is INTEGER
135*> The leading dimension of the matrix B. LDB >= max(1, N).
136*> \endverbatim
137*>
138*> \param[in,out] C
139*> \verbatim
140*> C is COMPLEX*16 array, dimension (LDC, N)
141*> On entry, C contains the right-hand-side of the first matrix
142*> equation in (1).
143*> On exit, if IJOB = 0, C has been overwritten by the solution
144*> R.
145*> \endverbatim
146*>
147*> \param[in] LDC
148*> \verbatim
149*> LDC is INTEGER
150*> The leading dimension of the matrix C. LDC >= max(1, M).
151*> \endverbatim
152*>
153*> \param[in] D
154*> \verbatim
155*> D is COMPLEX*16 array, dimension (LDD, M)
156*> On entry, D contains an upper triangular matrix.
157*> \endverbatim
158*>
159*> \param[in] LDD
160*> \verbatim
161*> LDD is INTEGER
162*> The leading dimension of the matrix D. LDD >= max(1, M).
163*> \endverbatim
164*>
165*> \param[in] E
166*> \verbatim
167*> E is COMPLEX*16 array, dimension (LDE, N)
168*> On entry, E contains an upper triangular matrix.
169*> \endverbatim
170*>
171*> \param[in] LDE
172*> \verbatim
173*> LDE is INTEGER
174*> The leading dimension of the matrix E. LDE >= max(1, N).
175*> \endverbatim
176*>
177*> \param[in,out] F
178*> \verbatim
179*> F is COMPLEX*16 array, dimension (LDF, N)
180*> On entry, F contains the right-hand-side of the second matrix
181*> equation in (1).
182*> On exit, if IJOB = 0, F has been overwritten by the solution
183*> L.
184*> \endverbatim
185*>
186*> \param[in] LDF
187*> \verbatim
188*> LDF is INTEGER
189*> The leading dimension of the matrix F. LDF >= max(1, M).
190*> \endverbatim
191*>
192*> \param[out] SCALE
193*> \verbatim
194*> SCALE is DOUBLE PRECISION
195*> On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions
196*> R and L (C and F on entry) will hold the solutions to a
197*> slightly perturbed system but the input matrices A, B, D and
198*> E have not been changed. If SCALE = 0, R and L will hold the
199*> solutions to the homogeneous system with C = F = 0.
200*> Normally, SCALE = 1.
201*> \endverbatim
202*>
203*> \param[in,out] RDSUM
204*> \verbatim
205*> RDSUM is DOUBLE PRECISION
206*> On entry, the sum of squares of computed contributions to
207*> the Dif-estimate under computation by ZTGSYL, where the
208*> scaling factor RDSCAL (see below) has been factored out.
209*> On exit, the corresponding sum of squares updated with the
210*> contributions from the current sub-system.
211*> If TRANS = 'T' RDSUM is not touched.
212*> NOTE: RDSUM only makes sense when ZTGSY2 is called by
213*> ZTGSYL.
214*> \endverbatim
215*>
216*> \param[in,out] RDSCAL
217*> \verbatim
218*> RDSCAL is DOUBLE PRECISION
219*> On entry, scaling factor used to prevent overflow in RDSUM.
220*> On exit, RDSCAL is updated w.r.t. the current contributions
221*> in RDSUM.
222*> If TRANS = 'T', RDSCAL is not touched.
223*> NOTE: RDSCAL only makes sense when ZTGSY2 is called by
224*> ZTGSYL.
225*> \endverbatim
226*>
227*> \param[out] INFO
228*> \verbatim
229*> INFO is INTEGER
230*> On exit, if INFO is set to
231*> =0: Successful exit
232*> <0: If INFO = -i, input argument number i is illegal.
233*> >0: The matrix pairs (A, D) and (B, E) have common or very
234*> close eigenvalues.
235*> \endverbatim
236*
237* Authors:
238* ========
239*
240*> \author Univ. of Tennessee
241*> \author Univ. of California Berkeley
242*> \author Univ. of Colorado Denver
243*> \author NAG Ltd.
244*
245*> \ingroup tgsy2
246*
247*> \par Contributors:
248* ==================
249*>
250*> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
251*> Umea University, S-901 87 Umea, Sweden.
252*
253* =====================================================================
254 SUBROUTINE ztgsy2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC,
255 $ D,
256 $ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
257 $ INFO )
258*
259* -- LAPACK auxiliary routine --
260* -- LAPACK is a software package provided by Univ. of Tennessee, --
261* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
262*
263* .. Scalar Arguments ..
264 CHARACTER TRANS
265 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N
266 DOUBLE PRECISION RDSCAL, RDSUM, SCALE
267* ..
268* .. Array Arguments ..
269 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * ),
270 $ D( LDD, * ), E( LDE, * ), F( LDF, * )
271* ..
272*
273* =====================================================================
274*
275* .. Parameters ..
276 DOUBLE PRECISION ZERO, ONE
277 INTEGER LDZ
278 PARAMETER ( ZERO = 0.0d+0, one = 1.0d+0, ldz = 2 )
279* ..
280* .. Local Scalars ..
281 LOGICAL NOTRAN
282 INTEGER I, IERR, J, K
283 DOUBLE PRECISION SCALOC
284 COMPLEX*16 ALPHA
285* ..
286* .. Local Arrays ..
287 INTEGER IPIV( LDZ ), JPIV( LDZ )
288 COMPLEX*16 RHS( LDZ ), Z( LDZ, LDZ )
289* ..
290* .. External Functions ..
291 LOGICAL LSAME
292 EXTERNAL LSAME
293* ..
294* .. External Subroutines ..
295 EXTERNAL xerbla, zaxpy, zgesc2, zgetc2, zlatdf,
296 $ zscal
297* ..
298* .. Intrinsic Functions ..
299 INTRINSIC dcmplx, dconjg, max
300* ..
301* .. Executable Statements ..
302*
303* Decode and test input parameters
304*
305 info = 0
306 ierr = 0
307 notran = lsame( trans, 'N' )
308 IF( .NOT.notran .AND. .NOT.lsame( trans, 'C' ) ) THEN
309 info = -1
310 ELSE IF( notran ) THEN
311 IF( ( ijob.LT.0 ) .OR. ( ijob.GT.2 ) ) THEN
312 info = -2
313 END IF
314 END IF
315 IF( info.EQ.0 ) THEN
316 IF( m.LE.0 ) THEN
317 info = -3
318 ELSE IF( n.LE.0 ) THEN
319 info = -4
320 ELSE IF( lda.LT.max( 1, m ) ) THEN
321 info = -6
322 ELSE IF( ldb.LT.max( 1, n ) ) THEN
323 info = -8
324 ELSE IF( ldc.LT.max( 1, m ) ) THEN
325 info = -10
326 ELSE IF( ldd.LT.max( 1, m ) ) THEN
327 info = -12
328 ELSE IF( lde.LT.max( 1, n ) ) THEN
329 info = -14
330 ELSE IF( ldf.LT.max( 1, m ) ) THEN
331 info = -16
332 END IF
333 END IF
334 IF( info.NE.0 ) THEN
335 CALL xerbla( 'ZTGSY2', -info )
336 RETURN
337 END IF
338*
339 IF( notran ) THEN
340*
341* Solve (I, J) - system
342* A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)
343* D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)
344* for I = M, M - 1, ..., 1; J = 1, 2, ..., N
345*
346 scale = one
347 scaloc = one
348 DO 30 j = 1, n
349 DO 20 i = m, 1, -1
350*
351* Build 2 by 2 system
352*
353 z( 1, 1 ) = a( i, i )
354 z( 2, 1 ) = d( i, i )
355 z( 1, 2 ) = -b( j, j )
356 z( 2, 2 ) = -e( j, j )
357*
358* Set up right hand side(s)
359*
360 rhs( 1 ) = c( i, j )
361 rhs( 2 ) = f( i, j )
362*
363* Solve Z * x = RHS
364*
365 CALL zgetc2( ldz, z, ldz, ipiv, jpiv, ierr )
366 IF( ierr.GT.0 )
367 $ info = ierr
368 IF( ijob.EQ.0 ) THEN
369 CALL zgesc2( ldz, z, ldz, rhs, ipiv, jpiv, scaloc )
370 IF( scaloc.NE.one ) THEN
371 DO 10 k = 1, n
372 CALL zscal( m, dcmplx( scaloc, zero ),
373 $ c( 1, k ), 1 )
374 CALL zscal( m, dcmplx( scaloc, zero ),
375 $ f( 1, k ), 1 )
376 10 CONTINUE
377 scale = scale*scaloc
378 END IF
379 ELSE
380 CALL zlatdf( ijob, ldz, z, ldz, rhs, rdsum, rdscal,
381 $ ipiv, jpiv )
382 END IF
383*
384* Unpack solution vector(s)
385*
386 c( i, j ) = rhs( 1 )
387 f( i, j ) = rhs( 2 )
388*
389* Substitute R(I, J) and L(I, J) into remaining equation.
390*
391 IF( i.GT.1 ) THEN
392 alpha = -rhs( 1 )
393 CALL zaxpy( i-1, alpha, a( 1, i ), 1, c( 1, j ),
394 $ 1 )
395 CALL zaxpy( i-1, alpha, d( 1, i ), 1, f( 1, j ),
396 $ 1 )
397 END IF
398 IF( j.LT.n ) THEN
399 CALL zaxpy( n-j, rhs( 2 ), b( j, j+1 ), ldb,
400 $ c( i, j+1 ), ldc )
401 CALL zaxpy( n-j, rhs( 2 ), e( j, j+1 ), lde,
402 $ f( i, j+1 ), ldf )
403 END IF
404*
405 20 CONTINUE
406 30 CONTINUE
407 ELSE
408*
409* Solve transposed (I, J) - system:
410* A(I, I)**H * R(I, J) + D(I, I)**H * L(J, J) = C(I, J)
411* R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J)
412* for I = 1, 2, ..., M, J = N, N - 1, ..., 1
413*
414 scale = one
415 scaloc = one
416 DO 80 i = 1, m
417 DO 70 j = n, 1, -1
418*
419* Build 2 by 2 system Z**H
420*
421 z( 1, 1 ) = dconjg( a( i, i ) )
422 z( 2, 1 ) = -dconjg( b( j, j ) )
423 z( 1, 2 ) = dconjg( d( i, i ) )
424 z( 2, 2 ) = -dconjg( e( j, j ) )
425*
426*
427* Set up right hand side(s)
428*
429 rhs( 1 ) = c( i, j )
430 rhs( 2 ) = f( i, j )
431*
432* Solve Z**H * x = RHS
433*
434 CALL zgetc2( ldz, z, ldz, ipiv, jpiv, ierr )
435 IF( ierr.GT.0 )
436 $ info = ierr
437 CALL zgesc2( ldz, z, ldz, rhs, ipiv, jpiv, scaloc )
438 IF( scaloc.NE.one ) THEN
439 DO 40 k = 1, n
440 CALL zscal( m, dcmplx( scaloc, zero ), c( 1,
441 $ k ),
442 $ 1 )
443 CALL zscal( m, dcmplx( scaloc, zero ), f( 1,
444 $ k ),
445 $ 1 )
446 40 CONTINUE
447 scale = scale*scaloc
448 END IF
449*
450* Unpack solution vector(s)
451*
452 c( i, j ) = rhs( 1 )
453 f( i, j ) = rhs( 2 )
454*
455* Substitute R(I, J) and L(I, J) into remaining equation.
456*
457 DO 50 k = 1, j - 1
458 f( i, k ) = f( i, k ) + rhs( 1 )*dconjg( b( k, j ) ) +
459 $ rhs( 2 )*dconjg( e( k, j ) )
460 50 CONTINUE
461 DO 60 k = i + 1, m
462 c( k, j ) = c( k, j ) - dconjg( a( i, k ) )*rhs( 1 ) -
463 $ dconjg( d( i, k ) )*rhs( 2 )
464 60 CONTINUE
465*
466 70 CONTINUE
467 80 CONTINUE
468 END IF
469 RETURN
470*
471* End of ZTGSY2
472*
473 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
Definition zaxpy.f:88
subroutine zgesc2(n, a, lda, rhs, ipiv, jpiv, scale)
ZGESC2 solves a system of linear equations using the LU factorization with complete pivoting computed...
Definition zgesc2.f:113
subroutine zgetc2(n, a, lda, ipiv, jpiv, info)
ZGETC2 computes the LU factorization with complete pivoting of the general n-by-n matrix.
Definition zgetc2.f:109
subroutine zlatdf(ijob, n, z, ldz, rhs, rdsum, rdscal, ipiv, jpiv)
ZLATDF uses the LU factorization of the n-by-n matrix computed by sgetc2 and computes a contribution ...
Definition zlatdf.f:167
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
subroutine ztgsy2(trans, ijob, m, n, a, lda, b, ldb, c, ldc, d, ldd, e, lde, f, ldf, scale, rdsum, rdscal, info)
ZTGSY2 solves the generalized Sylvester equation (unblocked algorithm).
Definition ztgsy2.f:258