LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
ctrsen.f
Go to the documentation of this file.
1*> \brief \b CTRSEN
2*
3* =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6* http://www.netlib.org/lapack/explore-html/
7*
8*> Download CTRSEN + dependencies
9*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ctrsen.f">
10*> [TGZ]</a>
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ctrsen.f">
12*> [ZIP]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ctrsen.f">
14*> [TXT]</a>
15*
16* Definition:
17* ===========
18*
19* SUBROUTINE CTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,
20* SEP, WORK, LWORK, INFO )
21*
22* .. Scalar Arguments ..
23* CHARACTER COMPQ, JOB
24* INTEGER INFO, LDQ, LDT, LWORK, M, N
25* REAL S, SEP
26* ..
27* .. Array Arguments ..
28* LOGICAL SELECT( * )
29* COMPLEX Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )
30* ..
31*
32*
33*> \par Purpose:
34* =============
35*>
36*> \verbatim
37*>
38*> CTRSEN reorders the Schur factorization of a complex matrix
39*> A = Q*T*Q**H, so that a selected cluster of eigenvalues appears in
40*> the leading positions on the diagonal of the upper triangular matrix
41*> T, and the leading columns of Q form an orthonormal basis of the
42*> corresponding right invariant subspace.
43*>
44*> Optionally the routine computes the reciprocal condition numbers of
45*> the cluster of eigenvalues and/or the invariant subspace.
46*> \endverbatim
47*
48* Arguments:
49* ==========
50*
51*> \param[in] JOB
52*> \verbatim
53*> JOB is CHARACTER*1
54*> Specifies whether condition numbers are required for the
55*> cluster of eigenvalues (S) or the invariant subspace (SEP):
56*> = 'N': none;
57*> = 'E': for eigenvalues only (S);
58*> = 'V': for invariant subspace only (SEP);
59*> = 'B': for both eigenvalues and invariant subspace (S and
60*> SEP).
61*> \endverbatim
62*>
63*> \param[in] COMPQ
64*> \verbatim
65*> COMPQ is CHARACTER*1
66*> = 'V': update the matrix Q of Schur vectors;
67*> = 'N': do not update Q.
68*> \endverbatim
69*>
70*> \param[in] SELECT
71*> \verbatim
72*> SELECT is LOGICAL array, dimension (N)
73*> SELECT specifies the eigenvalues in the selected cluster. To
74*> select the j-th eigenvalue, SELECT(j) must be set to .TRUE..
75*> \endverbatim
76*>
77*> \param[in] N
78*> \verbatim
79*> N is INTEGER
80*> The order of the matrix T. N >= 0.
81*> \endverbatim
82*>
83*> \param[in,out] T
84*> \verbatim
85*> T is COMPLEX array, dimension (LDT,N)
86*> On entry, the upper triangular matrix T.
87*> On exit, T is overwritten by the reordered matrix T, with the
88*> selected eigenvalues as the leading diagonal elements.
89*> \endverbatim
90*>
91*> \param[in] LDT
92*> \verbatim
93*> LDT is INTEGER
94*> The leading dimension of the array T. LDT >= max(1,N).
95*> \endverbatim
96*>
97*> \param[in,out] Q
98*> \verbatim
99*> Q is COMPLEX array, dimension (LDQ,N)
100*> On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
101*> On exit, if COMPQ = 'V', Q has been postmultiplied by the
102*> unitary transformation matrix which reorders T; the leading M
103*> columns of Q form an orthonormal basis for the specified
104*> invariant subspace.
105*> If COMPQ = 'N', Q is not referenced.
106*> \endverbatim
107*>
108*> \param[in] LDQ
109*> \verbatim
110*> LDQ is INTEGER
111*> The leading dimension of the array Q.
112*> LDQ >= 1; and if COMPQ = 'V', LDQ >= N.
113*> \endverbatim
114*>
115*> \param[out] W
116*> \verbatim
117*> W is COMPLEX array, dimension (N)
118*> The reordered eigenvalues of T, in the same order as they
119*> appear on the diagonal of T.
120*> \endverbatim
121*>
122*> \param[out] M
123*> \verbatim
124*> M is INTEGER
125*> The dimension of the specified invariant subspace.
126*> 0 <= M <= N.
127*> \endverbatim
128*>
129*> \param[out] S
130*> \verbatim
131*> S is REAL
132*> If JOB = 'E' or 'B', S is a lower bound on the reciprocal
133*> condition number for the selected cluster of eigenvalues.
134*> S cannot underestimate the true reciprocal condition number
135*> by more than a factor of sqrt(N). If M = 0 or N, S = 1.
136*> If JOB = 'N' or 'V', S is not referenced.
137*> \endverbatim
138*>
139*> \param[out] SEP
140*> \verbatim
141*> SEP is REAL
142*> If JOB = 'V' or 'B', SEP is the estimated reciprocal
143*> condition number of the specified invariant subspace. If
144*> M = 0 or N, SEP = norm(T).
145*> If JOB = 'N' or 'E', SEP is not referenced.
146*> \endverbatim
147*>
148*> \param[out] WORK
149*> \verbatim
150*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
151*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
152*> \endverbatim
153*>
154*> \param[in] LWORK
155*> \verbatim
156*> LWORK is INTEGER
157*> The dimension of the array WORK.
158*> If JOB = 'N', LWORK >= 1;
159*> if JOB = 'E', LWORK = max(1,M*(N-M));
160*> if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).
161*>
162*> If LWORK = -1, then a workspace query is assumed; the routine
163*> only calculates the optimal size of the WORK array, returns
164*> this value as the first entry of the WORK array, and no error
165*> message related to LWORK is issued by XERBLA.
166*> \endverbatim
167*>
168*> \param[out] INFO
169*> \verbatim
170*> INFO is INTEGER
171*> = 0: successful exit
172*> < 0: if INFO = -i, the i-th argument had an illegal value
173*> \endverbatim
174*
175* Authors:
176* ========
177*
178*> \author Univ. of Tennessee
179*> \author Univ. of California Berkeley
180*> \author Univ. of Colorado Denver
181*> \author NAG Ltd.
182*
183*> \ingroup trsen
184*
185*> \par Further Details:
186* =====================
187*>
188*> \verbatim
189*>
190*> CTRSEN first collects the selected eigenvalues by computing a unitary
191*> transformation Z to move them to the top left corner of T. In other
192*> words, the selected eigenvalues are the eigenvalues of T11 in:
193*>
194*> Z**H * T * Z = ( T11 T12 ) n1
195*> ( 0 T22 ) n2
196*> n1 n2
197*>
198*> where N = n1+n2. The first
199*> n1 columns of Z span the specified invariant subspace of T.
200*>
201*> If T has been obtained from the Schur factorization of a matrix
202*> A = Q*T*Q**H, then the reordered Schur factorization of A is given by
203*> A = (Q*Z)*(Z**H*T*Z)*(Q*Z)**H, and the first n1 columns of Q*Z span the
204*> corresponding invariant subspace of A.
205*>
206*> The reciprocal condition number of the average of the eigenvalues of
207*> T11 may be returned in S. S lies between 0 (very badly conditioned)
208*> and 1 (very well conditioned). It is computed as follows. First we
209*> compute R so that
210*>
211*> P = ( I R ) n1
212*> ( 0 0 ) n2
213*> n1 n2
214*>
215*> is the projector on the invariant subspace associated with T11.
216*> R is the solution of the Sylvester equation:
217*>
218*> T11*R - R*T22 = T12.
219*>
220*> Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote
221*> the two-norm of M. Then S is computed as the lower bound
222*>
223*> (1 + F-norm(R)**2)**(-1/2)
224*>
225*> on the reciprocal of 2-norm(P), the true reciprocal condition number.
226*> S cannot underestimate 1 / 2-norm(P) by more than a factor of
227*> sqrt(N).
228*>
229*> An approximate error bound for the computed average of the
230*> eigenvalues of T11 is
231*>
232*> EPS * norm(T) / S
233*>
234*> where EPS is the machine precision.
235*>
236*> The reciprocal condition number of the right invariant subspace
237*> spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.
238*> SEP is defined as the separation of T11 and T22:
239*>
240*> sep( T11, T22 ) = sigma-min( C )
241*>
242*> where sigma-min(C) is the smallest singular value of the
243*> n1*n2-by-n1*n2 matrix
244*>
245*> C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )
246*>
247*> I(m) is an m by m identity matrix, and kprod denotes the Kronecker
248*> product. We estimate sigma-min(C) by the reciprocal of an estimate of
249*> the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)
250*> cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).
251*>
252*> When SEP is small, small changes in T can cause large changes in
253*> the invariant subspace. An approximate bound on the maximum angular
254*> error in the computed right invariant subspace is
255*>
256*> EPS * norm(T) / SEP
257*> \endverbatim
258*>
259* =====================================================================
260 SUBROUTINE ctrsen( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M,
261 $ S,
262 $ SEP, WORK, LWORK, INFO )
263*
264* -- LAPACK computational routine --
265* -- LAPACK is a software package provided by Univ. of Tennessee, --
266* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
267*
268* .. Scalar Arguments ..
269 CHARACTER COMPQ, JOB
270 INTEGER INFO, LDQ, LDT, LWORK, M, N
271 REAL S, SEP
272* ..
273* .. Array Arguments ..
274 LOGICAL SELECT( * )
275 COMPLEX Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )
276* ..
277*
278* =====================================================================
279*
280* .. Parameters ..
281 REAL ZERO, ONE
282 PARAMETER ( ZERO = 0.0e+0, one = 1.0e+0 )
283* ..
284* .. Local Scalars ..
285 LOGICAL LQUERY, WANTBH, WANTQ, WANTS, WANTSP
286 INTEGER IERR, K, KASE, KS, LWMIN, N1, N2, NN
287 REAL EST, RNORM, SCALE
288* ..
289* .. Local Arrays ..
290 INTEGER ISAVE( 3 )
291 REAL RWORK( 1 )
292* ..
293* .. External Functions ..
294 LOGICAL LSAME
295 REAL CLANGE, SROUNDUP_LWORK
296 EXTERNAL lsame, clange, sroundup_lwork
297* ..
298* .. External Subroutines ..
299 EXTERNAL clacn2, clacpy, ctrexc, ctrsyl,
300 $ xerbla
301* ..
302* .. Intrinsic Functions ..
303 INTRINSIC max, sqrt
304* ..
305* .. Executable Statements ..
306*
307* Decode and test the input parameters.
308*
309 wantbh = lsame( job, 'B' )
310 wants = lsame( job, 'E' ) .OR. wantbh
311 wantsp = lsame( job, 'V' ) .OR. wantbh
312 wantq = lsame( compq, 'V' )
313*
314* Set M to the number of selected eigenvalues.
315*
316 m = 0
317 DO 10 k = 1, n
318 IF( SELECT( k ) )
319 $ m = m + 1
320 10 CONTINUE
321*
322 n1 = m
323 n2 = n - m
324 nn = n1*n2
325*
326 info = 0
327 lquery = ( lwork.EQ.-1 )
328*
329 IF( wantsp ) THEN
330 lwmin = max( 1, 2*nn )
331 ELSE IF( lsame( job, 'N' ) ) THEN
332 lwmin = 1
333 ELSE IF( lsame( job, 'E' ) ) THEN
334 lwmin = max( 1, nn )
335 END IF
336*
337 IF( .NOT.lsame( job, 'N' ) .AND. .NOT.wants .AND. .NOT.wantsp )
338 $ THEN
339 info = -1
340 ELSE IF( .NOT.lsame( compq, 'N' ) .AND. .NOT.wantq ) THEN
341 info = -2
342 ELSE IF( n.LT.0 ) THEN
343 info = -4
344 ELSE IF( ldt.LT.max( 1, n ) ) THEN
345 info = -6
346 ELSE IF( ldq.LT.1 .OR. ( wantq .AND. ldq.LT.n ) ) THEN
347 info = -8
348 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
349 info = -14
350 END IF
351*
352 IF( info.EQ.0 ) THEN
353 work( 1 ) = sroundup_lwork(lwmin)
354 END IF
355*
356 IF( info.NE.0 ) THEN
357 CALL xerbla( 'CTRSEN', -info )
358 RETURN
359 ELSE IF( lquery ) THEN
360 RETURN
361 END IF
362*
363* Quick return if possible
364*
365 IF( m.EQ.n .OR. m.EQ.0 ) THEN
366 IF( wants )
367 $ s = one
368 IF( wantsp )
369 $ sep = clange( '1', n, n, t, ldt, rwork )
370 GO TO 40
371 END IF
372*
373* Collect the selected eigenvalues at the top left corner of T.
374*
375 ks = 0
376 DO 20 k = 1, n
377 IF( SELECT( k ) ) THEN
378 ks = ks + 1
379*
380* Swap the K-th eigenvalue to position KS.
381*
382 IF( k.NE.ks )
383 $ CALL ctrexc( compq, n, t, ldt, q, ldq, k, ks, ierr )
384 END IF
385 20 CONTINUE
386*
387 IF( wants ) THEN
388*
389* Solve the Sylvester equation for R:
390*
391* T11*R - R*T22 = scale*T12
392*
393 CALL clacpy( 'F', n1, n2, t( 1, n1+1 ), ldt, work, n1 )
394 CALL ctrsyl( 'N', 'N', -1, n1, n2, t, ldt, t( n1+1, n1+1 ),
395 $ ldt, work, n1, scale, ierr )
396*
397* Estimate the reciprocal of the condition number of the cluster
398* of eigenvalues.
399*
400 rnorm = clange( 'F', n1, n2, work, n1, rwork )
401 IF( rnorm.EQ.zero ) THEN
402 s = one
403 ELSE
404 s = scale / ( sqrt( scale*scale / rnorm+rnorm )*
405 $ sqrt( rnorm ) )
406 END IF
407 END IF
408*
409 IF( wantsp ) THEN
410*
411* Estimate sep(T11,T22).
412*
413 est = zero
414 kase = 0
415 30 CONTINUE
416 CALL clacn2( nn, work( nn+1 ), work, est, kase, isave )
417 IF( kase.NE.0 ) THEN
418 IF( kase.EQ.1 ) THEN
419*
420* Solve T11*R - R*T22 = scale*X.
421*
422 CALL ctrsyl( 'N', 'N', -1, n1, n2, t, ldt,
423 $ t( n1+1, n1+1 ), ldt, work, n1, scale,
424 $ ierr )
425 ELSE
426*
427* Solve T11**H*R - R*T22**H = scale*X.
428*
429 CALL ctrsyl( 'C', 'C', -1, n1, n2, t, ldt,
430 $ t( n1+1, n1+1 ), ldt, work, n1, scale,
431 $ ierr )
432 END IF
433 GO TO 30
434 END IF
435*
436 sep = scale / est
437 END IF
438*
439 40 CONTINUE
440*
441* Copy reordered eigenvalues to W.
442*
443 DO 50 k = 1, n
444 w( k ) = t( k, k )
445 50 CONTINUE
446*
447 work( 1 ) = sroundup_lwork(lwmin)
448*
449 RETURN
450*
451* End of CTRSEN
452*
453 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine clacn2(n, v, x, est, kase, isave)
CLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vec...
Definition clacn2.f:131
subroutine clacpy(uplo, m, n, a, lda, b, ldb)
CLACPY copies all or part of one two-dimensional array to another.
Definition clacpy.f:101
subroutine ctrexc(compq, n, t, ldt, q, ldq, ifst, ilst, info)
CTREXC
Definition ctrexc.f:124
subroutine ctrsen(job, compq, select, n, t, ldt, q, ldq, w, m, s, sep, work, lwork, info)
CTRSEN
Definition ctrsen.f:263
subroutine ctrsyl(trana, tranb, isgn, m, n, a, lda, b, ldb, c, ldc, scale, info)
CTRSYL
Definition ctrsyl.f:155