1
SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,
2
$ SEP, WORK, LWORK, INFO )
4
* -- LAPACK routine (version 3.1) --
5
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
8
* Modified to call ZLACN2 in place of ZLACON, 10 Feb 03, SJH.
10
* .. Scalar Arguments ..
12
INTEGER INFO, LDQ, LDT, LWORK, M, N
13
DOUBLE PRECISION S, SEP
15
* .. Array Arguments ..
17
COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )
23
* ZTRSEN reorders the Schur factorization of a complex matrix
24
* A = Q*T*Q**H, so that a selected cluster of eigenvalues appears in
25
* the leading positions on the diagonal of the upper triangular matrix
26
* T, and the leading columns of Q form an orthonormal basis of the
27
* corresponding right invariant subspace.
29
* Optionally the routine computes the reciprocal condition numbers of
30
* the cluster of eigenvalues and/or the invariant subspace.
35
* JOB (input) CHARACTER*1
36
* Specifies whether condition numbers are required for the
37
* cluster of eigenvalues (S) or the invariant subspace (SEP):
39
* = 'E': for eigenvalues only (S);
40
* = 'V': for invariant subspace only (SEP);
41
* = 'B': for both eigenvalues and invariant subspace (S and
44
* COMPQ (input) CHARACTER*1
45
* = 'V': update the matrix Q of Schur vectors;
46
* = 'N': do not update Q.
48
* SELECT (input) LOGICAL array, dimension (N)
49
* SELECT specifies the eigenvalues in the selected cluster. To
50
* select the j-th eigenvalue, SELECT(j) must be set to .TRUE..
53
* The order of the matrix T. N >= 0.
55
* T (input/output) COMPLEX*16 array, dimension (LDT,N)
56
* On entry, the upper triangular matrix T.
57
* On exit, T is overwritten by the reordered matrix T, with the
58
* selected eigenvalues as the leading diagonal elements.
61
* The leading dimension of the array T. LDT >= max(1,N).
63
* Q (input/output) COMPLEX*16 array, dimension (LDQ,N)
64
* On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
65
* On exit, if COMPQ = 'V', Q has been postmultiplied by the
66
* unitary transformation matrix which reorders T; the leading M
67
* columns of Q form an orthonormal basis for the specified
69
* If COMPQ = 'N', Q is not referenced.
72
* The leading dimension of the array Q.
73
* LDQ >= 1; and if COMPQ = 'V', LDQ >= N.
75
* W (output) COMPLEX*16 array, dimension (N)
76
* The reordered eigenvalues of T, in the same order as they
77
* appear on the diagonal of T.
80
* The dimension of the specified invariant subspace.
83
* S (output) DOUBLE PRECISION
84
* If JOB = 'E' or 'B', S is a lower bound on the reciprocal
85
* condition number for the selected cluster of eigenvalues.
86
* S cannot underestimate the true reciprocal condition number
87
* by more than a factor of sqrt(N). If M = 0 or N, S = 1.
88
* If JOB = 'N' or 'V', S is not referenced.
90
* SEP (output) DOUBLE PRECISION
91
* If JOB = 'V' or 'B', SEP is the estimated reciprocal
92
* condition number of the specified invariant subspace. If
93
* M = 0 or N, SEP = norm(T).
94
* If JOB = 'N' or 'E', SEP is not referenced.
96
* WORK (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK))
97
* On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
99
* LWORK (input) INTEGER
100
* The dimension of the array WORK.
101
* If JOB = 'N', LWORK >= 1;
102
* if JOB = 'E', LWORK = max(1,M*(N-M));
103
* if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).
105
* If LWORK = -1, then a workspace query is assumed; the routine
106
* only calculates the optimal size of the WORK array, returns
107
* this value as the first entry of the WORK array, and no error
108
* message related to LWORK is issued by XERBLA.
110
* INFO (output) INTEGER
111
* = 0: successful exit
112
* < 0: if INFO = -i, the i-th argument had an illegal value
117
* ZTRSEN first collects the selected eigenvalues by computing a unitary
118
* transformation Z to move them to the top left corner of T. In other
119
* words, the selected eigenvalues are the eigenvalues of T11 in:
121
* Z'*T*Z = ( T11 T12 ) n1
125
* where N = n1+n2 and Z' means the conjugate transpose of Z. The first
126
* n1 columns of Z span the specified invariant subspace of T.
128
* If T has been obtained from the Schur factorization of a matrix
129
* A = Q*T*Q', then the reordered Schur factorization of A is given by
130
* A = (Q*Z)*(Z'*T*Z)*(Q*Z)', and the first n1 columns of Q*Z span the
131
* corresponding invariant subspace of A.
133
* The reciprocal condition number of the average of the eigenvalues of
134
* T11 may be returned in S. S lies between 0 (very badly conditioned)
135
* and 1 (very well conditioned). It is computed as follows. First we
142
* is the projector on the invariant subspace associated with T11.
143
* R is the solution of the Sylvester equation:
145
* T11*R - R*T22 = T12.
147
* Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote
148
* the two-norm of M. Then S is computed as the lower bound
150
* (1 + F-norm(R)**2)**(-1/2)
152
* on the reciprocal of 2-norm(P), the true reciprocal condition number.
153
* S cannot underestimate 1 / 2-norm(P) by more than a factor of
156
* An approximate error bound for the computed average of the
157
* eigenvalues of T11 is
161
* where EPS is the machine precision.
163
* The reciprocal condition number of the right invariant subspace
164
* spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.
165
* SEP is defined as the separation of T11 and T22:
167
* sep( T11, T22 ) = sigma-min( C )
169
* where sigma-min(C) is the smallest singular value of the
170
* n1*n2-by-n1*n2 matrix
172
* C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )
174
* I(m) is an m by m identity matrix, and kprod denotes the Kronecker
175
* product. We estimate sigma-min(C) by the reciprocal of an estimate of
176
* the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)
177
* cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).
179
* When SEP is small, small changes in T can cause large changes in
180
* the invariant subspace. An approximate bound on the maximum angular
181
* error in the computed right invariant subspace is
183
* EPS * norm(T) / SEP
185
* =====================================================================
188
DOUBLE PRECISION ZERO, ONE
189
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
191
* .. Local Scalars ..
192
LOGICAL LQUERY, WANTBH, WANTQ, WANTS, WANTSP
193
INTEGER IERR, K, KASE, KS, LWMIN, N1, N2, NN
194
DOUBLE PRECISION EST, RNORM, SCALE
198
DOUBLE PRECISION RWORK( 1 )
200
* .. External Functions ..
202
DOUBLE PRECISION ZLANGE
203
EXTERNAL LSAME, ZLANGE
205
* .. External Subroutines ..
206
EXTERNAL XERBLA, ZLACN2, ZLACPY, ZTREXC, ZTRSYL
208
* .. Intrinsic Functions ..
211
* .. Executable Statements ..
213
* Decode and test the input parameters.
215
WANTBH = LSAME( JOB, 'B' )
216
WANTS = LSAME( JOB, 'E' ) .OR. WANTBH
217
WANTSP = LSAME( JOB, 'V' ) .OR. WANTBH
218
WANTQ = LSAME( COMPQ, 'V' )
220
* Set M to the number of selected eigenvalues.
233
LQUERY = ( LWORK.EQ.-1 )
236
LWMIN = MAX( 1, 2*NN )
237
ELSE IF( LSAME( JOB, 'N' ) ) THEN
239
ELSE IF( LSAME( JOB, 'E' ) ) THEN
243
IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.WANTS .AND. .NOT.WANTSP )
246
ELSE IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THEN
248
ELSE IF( N.LT.0 ) THEN
250
ELSE IF( LDT.LT.MAX( 1, N ) ) THEN
252
ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
254
ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
263
CALL XERBLA( 'ZTRSEN', -INFO )
265
ELSE IF( LQUERY ) THEN
269
* Quick return if possible
271
IF( M.EQ.N .OR. M.EQ.0 ) THEN
275
$ SEP = ZLANGE( '1', N, N, T, LDT, RWORK )
279
* Collect the selected eigenvalues at the top left corner of T.
283
IF( SELECT( K ) ) THEN
286
* Swap the K-th eigenvalue to position KS.
289
$ CALL ZTREXC( COMPQ, N, T, LDT, Q, LDQ, K, KS, IERR )
295
* Solve the Sylvester equation for R:
297
* T11*R - R*T22 = scale*T12
299
CALL ZLACPY( 'F', N1, N2, T( 1, N1+1 ), LDT, WORK, N1 )
300
CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT, T( N1+1, N1+1 ),
301
$ LDT, WORK, N1, SCALE, IERR )
303
* Estimate the reciprocal of the condition number of the cluster
306
RNORM = ZLANGE( 'F', N1, N2, WORK, N1, RWORK )
307
IF( RNORM.EQ.ZERO ) THEN
310
S = SCALE / ( SQRT( SCALE*SCALE / RNORM+RNORM )*
317
* Estimate sep(T11,T22).
322
CALL ZLACN2( NN, WORK( NN+1 ), WORK, EST, KASE, ISAVE )
326
* Solve T11*R - R*T22 = scale*X.
328
CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT,
329
$ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,
333
* Solve T11'*R - R*T22' = scale*X.
335
CALL ZTRSYL( 'C', 'C', -1, N1, N2, T, LDT,
336
$ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,
347
* Copy reordered eigenvalues to W.