LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ztrsyl.f
Go to the documentation of this file.
1*> \brief \b ZTRSYL
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> \htmlonly
9*> Download ZTRSYL + dependencies
10*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrsyl.f">
11*> [TGZ]</a>
12*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrsyl.f">
13*> [ZIP]</a>
14*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrsyl.f">
15*> [TXT]</a>
16*> \endhtmlonly
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE ZTRSYL( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,
22* LDC, SCALE, INFO )
23*
24* .. Scalar Arguments ..
25* CHARACTER TRANA, TRANB
26* INTEGER INFO, ISGN, LDA, LDB, LDC, M, N
27* DOUBLE PRECISION SCALE
28* ..
29* .. Array Arguments ..
30* COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )
31* ..
32*
33*
34*> \par Purpose:
35* =============
36*>
37*> \verbatim
38*>
39*> ZTRSYL solves the complex Sylvester matrix equation:
40*>
41*> op(A)*X + X*op(B) = scale*C or
42*> op(A)*X - X*op(B) = scale*C,
43*>
44*> where op(A) = A or A**H, and A and B are both upper triangular. A is
45*> M-by-M and B is N-by-N; the right hand side C and the solution X are
46*> M-by-N; and scale is an output scale factor, set <= 1 to avoid
47*> overflow in X.
48*> \endverbatim
49*
50* Arguments:
51* ==========
52*
53*> \param[in] TRANA
54*> \verbatim
55*> TRANA is CHARACTER*1
56*> Specifies the option op(A):
57*> = 'N': op(A) = A (No transpose)
58*> = 'C': op(A) = A**H (Conjugate transpose)
59*> \endverbatim
60*>
61*> \param[in] TRANB
62*> \verbatim
63*> TRANB is CHARACTER*1
64*> Specifies the option op(B):
65*> = 'N': op(B) = B (No transpose)
66*> = 'C': op(B) = B**H (Conjugate transpose)
67*> \endverbatim
68*>
69*> \param[in] ISGN
70*> \verbatim
71*> ISGN is INTEGER
72*> Specifies the sign in the equation:
73*> = +1: solve op(A)*X + X*op(B) = scale*C
74*> = -1: solve op(A)*X - X*op(B) = scale*C
75*> \endverbatim
76*>
77*> \param[in] M
78*> \verbatim
79*> M is INTEGER
80*> The order of the matrix A, and the number of rows in the
81*> matrices X and C. M >= 0.
82*> \endverbatim
83*>
84*> \param[in] N
85*> \verbatim
86*> N is INTEGER
87*> The order of the matrix B, and the number of columns in the
88*> matrices X and C. N >= 0.
89*> \endverbatim
90*>
91*> \param[in] A
92*> \verbatim
93*> A is COMPLEX*16 array, dimension (LDA,M)
94*> The upper triangular matrix A.
95*> \endverbatim
96*>
97*> \param[in] LDA
98*> \verbatim
99*> LDA is INTEGER
100*> The leading dimension of the array A. LDA >= max(1,M).
101*> \endverbatim
102*>
103*> \param[in] B
104*> \verbatim
105*> B is COMPLEX*16 array, dimension (LDB,N)
106*> The upper triangular matrix B.
107*> \endverbatim
108*>
109*> \param[in] LDB
110*> \verbatim
111*> LDB is INTEGER
112*> The leading dimension of the array B. LDB >= max(1,N).
113*> \endverbatim
114*>
115*> \param[in,out] C
116*> \verbatim
117*> C is COMPLEX*16 array, dimension (LDC,N)
118*> On entry, the M-by-N right hand side matrix C.
119*> On exit, C is overwritten by the solution matrix X.
120*> \endverbatim
121*>
122*> \param[in] LDC
123*> \verbatim
124*> LDC is INTEGER
125*> The leading dimension of the array C. LDC >= max(1,M)
126*> \endverbatim
127*>
128*> \param[out] SCALE
129*> \verbatim
130*> SCALE is DOUBLE PRECISION
131*> The scale factor, scale, set <= 1 to avoid overflow in X.
132*> \endverbatim
133*>
134*> \param[out] INFO
135*> \verbatim
136*> INFO is INTEGER
137*> = 0: successful exit
138*> < 0: if INFO = -i, the i-th argument had an illegal value
139*> = 1: A and B have common or very close eigenvalues; perturbed
140*> values were used to solve the equation (but the matrices
141*> A and B are unchanged).
142*> \endverbatim
143*
144* Authors:
145* ========
146*
147*> \author Univ. of Tennessee
148*> \author Univ. of California Berkeley
149*> \author Univ. of Colorado Denver
150*> \author NAG Ltd.
151*
152*> \ingroup trsyl
153*
154* =====================================================================
155 SUBROUTINE ztrsyl( TRANA, TRANB, ISGN, M, N, A, LDA, B, LDB, C,
156 $ LDC, SCALE, INFO )
157*
158* -- LAPACK computational routine --
159* -- LAPACK is a software package provided by Univ. of Tennessee, --
160* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
161*
162* .. Scalar Arguments ..
163 CHARACTER TRANA, TRANB
164 INTEGER INFO, ISGN, LDA, LDB, LDC, M, N
165 DOUBLE PRECISION SCALE
166* ..
167* .. Array Arguments ..
168 COMPLEX*16 A( LDA, * ), B( LDB, * ), C( LDC, * )
169* ..
170*
171* =====================================================================
172*
173* .. Parameters ..
174 DOUBLE PRECISION ONE
175 parameter( one = 1.0d+0 )
176* ..
177* .. Local Scalars ..
178 LOGICAL NOTRNA, NOTRNB
179 INTEGER J, K, L
180 DOUBLE PRECISION BIGNUM, DA11, DB, EPS, SCALOC, SGN, SMIN,
181 $ smlnum
182 COMPLEX*16 A11, SUML, SUMR, VEC, X11
183* ..
184* .. Local Arrays ..
185 DOUBLE PRECISION DUM( 1 )
186* ..
187* .. External Functions ..
188 LOGICAL LSAME
189 DOUBLE PRECISION DLAMCH, ZLANGE
190 COMPLEX*16 ZDOTC, ZDOTU, ZLADIV
191 EXTERNAL lsame, dlamch, zlange, zdotc, zdotu, zladiv
192* ..
193* .. External Subroutines ..
194 EXTERNAL xerbla, zdscal
195* ..
196* .. Intrinsic Functions ..
197 INTRINSIC abs, dble, dcmplx, dconjg, dimag, max, min
198* ..
199* .. Executable Statements ..
200*
201* Decode and Test input parameters
202*
203 notrna = lsame( trana, 'N' )
204 notrnb = lsame( tranb, 'N' )
205*
206 info = 0
207 IF( .NOT.notrna .AND. .NOT.lsame( trana, 'C' ) ) THEN
208 info = -1
209 ELSE IF( .NOT.notrnb .AND. .NOT.lsame( tranb, 'C' ) ) THEN
210 info = -2
211 ELSE IF( isgn.NE.1 .AND. isgn.NE.-1 ) THEN
212 info = -3
213 ELSE IF( m.LT.0 ) THEN
214 info = -4
215 ELSE IF( n.LT.0 ) THEN
216 info = -5
217 ELSE IF( lda.LT.max( 1, m ) ) THEN
218 info = -7
219 ELSE IF( ldb.LT.max( 1, n ) ) THEN
220 info = -9
221 ELSE IF( ldc.LT.max( 1, m ) ) THEN
222 info = -11
223 END IF
224 IF( info.NE.0 ) THEN
225 CALL xerbla( 'ZTRSYL', -info )
226 RETURN
227 END IF
228*
229* Quick return if possible
230*
231 scale = one
232 IF( m.EQ.0 .OR. n.EQ.0 )
233 $ RETURN
234*
235* Set constants to control overflow
236*
237 eps = dlamch( 'P' )
238 smlnum = dlamch( 'S' )
239 bignum = one / smlnum
240 smlnum = smlnum*dble( m*n ) / eps
241 bignum = one / smlnum
242 smin = max( smlnum, eps*zlange( 'M', m, m, a, lda, dum ),
243 $ eps*zlange( 'M', n, n, b, ldb, dum ) )
244 sgn = isgn
245*
246 IF( notrna .AND. notrnb ) THEN
247*
248* Solve A*X + ISGN*X*B = scale*C.
249*
250* The (K,L)th block of X is determined starting from
251* bottom-left corner column by column by
252*
253* A(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L)
254*
255* Where
256* M L-1
257* R(K,L) = SUM [A(K,I)*X(I,L)] +ISGN*SUM [X(K,J)*B(J,L)].
258* I=K+1 J=1
259*
260 DO 30 l = 1, n
261 DO 20 k = m, 1, -1
262*
263 suml = zdotu( m-k, a( k, min( k+1, m ) ), lda,
264 $ c( min( k+1, m ), l ), 1 )
265 sumr = zdotu( l-1, c( k, 1 ), ldc, b( 1, l ), 1 )
266 vec = c( k, l ) - ( suml+sgn*sumr )
267*
268 scaloc = one
269 a11 = a( k, k ) + sgn*b( l, l )
270 da11 = abs( dble( a11 ) ) + abs( dimag( a11 ) )
271 IF( da11.LE.smin ) THEN
272 a11 = smin
273 da11 = smin
274 info = 1
275 END IF
276 db = abs( dble( vec ) ) + abs( dimag( vec ) )
277 IF( da11.LT.one .AND. db.GT.one ) THEN
278 IF( db.GT.bignum*da11 )
279 $ scaloc = one / db
280 END IF
281 x11 = zladiv( vec*dcmplx( scaloc ), a11 )
282*
283 IF( scaloc.NE.one ) THEN
284 DO 10 j = 1, n
285 CALL zdscal( m, scaloc, c( 1, j ), 1 )
286 10 CONTINUE
287 scale = scale*scaloc
288 END IF
289 c( k, l ) = x11
290*
291 20 CONTINUE
292 30 CONTINUE
293*
294 ELSE IF( .NOT.notrna .AND. notrnb ) THEN
295*
296* Solve A**H *X + ISGN*X*B = scale*C.
297*
298* The (K,L)th block of X is determined starting from
299* upper-left corner column by column by
300*
301* A**H(K,K)*X(K,L) + ISGN*X(K,L)*B(L,L) = C(K,L) - R(K,L)
302*
303* Where
304* K-1 L-1
305* R(K,L) = SUM [A**H(I,K)*X(I,L)] + ISGN*SUM [X(K,J)*B(J,L)]
306* I=1 J=1
307*
308 DO 60 l = 1, n
309 DO 50 k = 1, m
310*
311 suml = zdotc( k-1, a( 1, k ), 1, c( 1, l ), 1 )
312 sumr = zdotu( l-1, c( k, 1 ), ldc, b( 1, l ), 1 )
313 vec = c( k, l ) - ( suml+sgn*sumr )
314*
315 scaloc = one
316 a11 = dconjg( a( k, k ) ) + sgn*b( l, l )
317 da11 = abs( dble( a11 ) ) + abs( dimag( a11 ) )
318 IF( da11.LE.smin ) THEN
319 a11 = smin
320 da11 = smin
321 info = 1
322 END IF
323 db = abs( dble( vec ) ) + abs( dimag( vec ) )
324 IF( da11.LT.one .AND. db.GT.one ) THEN
325 IF( db.GT.bignum*da11 )
326 $ scaloc = one / db
327 END IF
328*
329 x11 = zladiv( vec*dcmplx( scaloc ), a11 )
330*
331 IF( scaloc.NE.one ) THEN
332 DO 40 j = 1, n
333 CALL zdscal( m, scaloc, c( 1, j ), 1 )
334 40 CONTINUE
335 scale = scale*scaloc
336 END IF
337 c( k, l ) = x11
338*
339 50 CONTINUE
340 60 CONTINUE
341*
342 ELSE IF( .NOT.notrna .AND. .NOT.notrnb ) THEN
343*
344* Solve A**H*X + ISGN*X*B**H = C.
345*
346* The (K,L)th block of X is determined starting from
347* upper-right corner column by column by
348*
349* A**H(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L)
350*
351* Where
352* K-1
353* R(K,L) = SUM [A**H(I,K)*X(I,L)] +
354* I=1
355* N
356* ISGN*SUM [X(K,J)*B**H(L,J)].
357* J=L+1
358*
359 DO 90 l = n, 1, -1
360 DO 80 k = 1, m
361*
362 suml = zdotc( k-1, a( 1, k ), 1, c( 1, l ), 1 )
363 sumr = zdotc( n-l, c( k, min( l+1, n ) ), ldc,
364 $ b( l, min( l+1, n ) ), ldb )
365 vec = c( k, l ) - ( suml+sgn*dconjg( sumr ) )
366*
367 scaloc = one
368 a11 = dconjg( a( k, k )+sgn*b( l, l ) )
369 da11 = abs( dble( a11 ) ) + abs( dimag( a11 ) )
370 IF( da11.LE.smin ) THEN
371 a11 = smin
372 da11 = smin
373 info = 1
374 END IF
375 db = abs( dble( vec ) ) + abs( dimag( vec ) )
376 IF( da11.LT.one .AND. db.GT.one ) THEN
377 IF( db.GT.bignum*da11 )
378 $ scaloc = one / db
379 END IF
380*
381 x11 = zladiv( vec*dcmplx( scaloc ), a11 )
382*
383 IF( scaloc.NE.one ) THEN
384 DO 70 j = 1, n
385 CALL zdscal( m, scaloc, c( 1, j ), 1 )
386 70 CONTINUE
387 scale = scale*scaloc
388 END IF
389 c( k, l ) = x11
390*
391 80 CONTINUE
392 90 CONTINUE
393*
394 ELSE IF( notrna .AND. .NOT.notrnb ) THEN
395*
396* Solve A*X + ISGN*X*B**H = C.
397*
398* The (K,L)th block of X is determined starting from
399* bottom-left corner column by column by
400*
401* A(K,K)*X(K,L) + ISGN*X(K,L)*B**H(L,L) = C(K,L) - R(K,L)
402*
403* Where
404* M N
405* R(K,L) = SUM [A(K,I)*X(I,L)] + ISGN*SUM [X(K,J)*B**H(L,J)]
406* I=K+1 J=L+1
407*
408 DO 120 l = n, 1, -1
409 DO 110 k = m, 1, -1
410*
411 suml = zdotu( m-k, a( k, min( k+1, m ) ), lda,
412 $ c( min( k+1, m ), l ), 1 )
413 sumr = zdotc( n-l, c( k, min( l+1, n ) ), ldc,
414 $ b( l, min( l+1, n ) ), ldb )
415 vec = c( k, l ) - ( suml+sgn*dconjg( sumr ) )
416*
417 scaloc = one
418 a11 = a( k, k ) + sgn*dconjg( b( l, l ) )
419 da11 = abs( dble( a11 ) ) + abs( dimag( a11 ) )
420 IF( da11.LE.smin ) THEN
421 a11 = smin
422 da11 = smin
423 info = 1
424 END IF
425 db = abs( dble( vec ) ) + abs( dimag( vec ) )
426 IF( da11.LT.one .AND. db.GT.one ) THEN
427 IF( db.GT.bignum*da11 )
428 $ scaloc = one / db
429 END IF
430*
431 x11 = zladiv( vec*dcmplx( scaloc ), a11 )
432*
433 IF( scaloc.NE.one ) THEN
434 DO 100 j = 1, n
435 CALL zdscal( m, scaloc, c( 1, j ), 1 )
436 100 CONTINUE
437 scale = scale*scaloc
438 END IF
439 c( k, l ) = x11
440*
441 110 CONTINUE
442 120 CONTINUE
443*
444 END IF
445*
446 RETURN
447*
448* End of ZTRSYL
449*
450 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine ztrsyl(trana, tranb, isgn, m, n, a, lda, b, ldb, c, ldc, scale, info)
ZTRSYL
Definition ztrsyl.f:157