3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download ZTRSEN + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/ztrsen.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/ztrsen.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/ztrsen.f">
21 * SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,
22 * SEP, WORK, LWORK, INFO )
24 * .. Scalar Arguments ..
25 * CHARACTER COMPQ, JOB
26 * INTEGER INFO, LDQ, LDT, LWORK, M, N
27 * DOUBLE PRECISION S, SEP
29 * .. Array Arguments ..
31 * COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )
40 *> ZTRSEN reorders the Schur factorization of a complex matrix
41 *> A = Q*T*Q**H, so that a selected cluster of eigenvalues appears in
42 *> the leading positions on the diagonal of the upper triangular matrix
43 *> T, and the leading columns of Q form an orthonormal basis of the
44 *> corresponding right invariant subspace.
46 *> Optionally the routine computes the reciprocal condition numbers of
47 *> the cluster of eigenvalues and/or the invariant subspace.
56 *> Specifies whether condition numbers are required for the
57 *> cluster of eigenvalues (S) or the invariant subspace (SEP):
59 *> = 'E': for eigenvalues only (S);
60 *> = 'V': for invariant subspace only (SEP);
61 *> = 'B': for both eigenvalues and invariant subspace (S and
67 *> COMPQ is CHARACTER*1
68 *> = 'V': update the matrix Q of Schur vectors;
69 *> = 'N': do not update Q.
74 *> SELECT is LOGICAL array, dimension (N)
75 *> SELECT specifies the eigenvalues in the selected cluster. To
76 *> select the j-th eigenvalue, SELECT(j) must be set to .TRUE..
82 *> The order of the matrix T. N >= 0.
87 *> T is COMPLEX*16 array, dimension (LDT,N)
88 *> On entry, the upper triangular matrix T.
89 *> On exit, T is overwritten by the reordered matrix T, with the
90 *> selected eigenvalues as the leading diagonal elements.
96 *> The leading dimension of the array T. LDT >= max(1,N).
101 *> Q is COMPLEX*16 array, dimension (LDQ,N)
102 *> On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
103 *> On exit, if COMPQ = 'V', Q has been postmultiplied by the
104 *> unitary transformation matrix which reorders T; the leading M
105 *> columns of Q form an orthonormal basis for the specified
106 *> invariant subspace.
107 *> If COMPQ = 'N', Q is not referenced.
113 *> The leading dimension of the array Q.
114 *> LDQ >= 1; and if COMPQ = 'V', LDQ >= N.
119 *> W is COMPLEX*16 array, dimension (N)
120 *> The reordered eigenvalues of T, in the same order as they
121 *> appear on the diagonal of T.
127 *> The dimension of the specified invariant subspace.
133 *> S is DOUBLE PRECISION
134 *> If JOB = 'E' or 'B', S is a lower bound on the reciprocal
135 *> condition number for the selected cluster of eigenvalues.
136 *> S cannot underestimate the true reciprocal condition number
137 *> by more than a factor of sqrt(N). If M = 0 or N, S = 1.
138 *> If JOB = 'N' or 'V', S is not referenced.
143 *> SEP is DOUBLE PRECISION
144 *> If JOB = 'V' or 'B', SEP is the estimated reciprocal
145 *> condition number of the specified invariant subspace. If
146 *> M = 0 or N, SEP = norm(T).
147 *> If JOB = 'N' or 'E', SEP is not referenced.
152 *> WORK is COMPLEX*16 array, dimension (MAX(1,LWORK))
153 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
159 *> The dimension of the array WORK.
160 *> If JOB = 'N', LWORK >= 1;
161 *> if JOB = 'E', LWORK = max(1,M*(N-M));
162 *> if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).
164 *> If LWORK = -1, then a workspace query is assumed; the routine
165 *> only calculates the optimal size of the WORK array, returns
166 *> this value as the first entry of the WORK array, and no error
167 *> message related to LWORK is issued by XERBLA.
173 *> = 0: successful exit
174 *> < 0: if INFO = -i, the i-th argument had an illegal value
180 *> \author Univ. of Tennessee
181 *> \author Univ. of California Berkeley
182 *> \author Univ. of Colorado Denver
185 *> \date November 2011
187 *> \ingroup complex16OTHERcomputational
189 *> \par Further Details:
190 * =====================
194 *> ZTRSEN first collects the selected eigenvalues by computing a unitary
195 *> transformation Z to move them to the top left corner of T. In other
196 *> words, the selected eigenvalues are the eigenvalues of T11 in:
198 *> Z**H * T * Z = ( T11 T12 ) n1
202 *> where N = n1+n2. The first
203 *> n1 columns of Z span the specified invariant subspace of T.
205 *> If T has been obtained from the Schur factorization of a matrix
206 *> A = Q*T*Q**H, then the reordered Schur factorization of A is given by
207 *> A = (Q*Z)*(Z**H*T*Z)*(Q*Z)**H, and the first n1 columns of Q*Z span the
208 *> corresponding invariant subspace of A.
210 *> The reciprocal condition number of the average of the eigenvalues of
211 *> T11 may be returned in S. S lies between 0 (very badly conditioned)
212 *> and 1 (very well conditioned). It is computed as follows. First we
219 *> is the projector on the invariant subspace associated with T11.
220 *> R is the solution of the Sylvester equation:
222 *> T11*R - R*T22 = T12.
224 *> Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote
225 *> the two-norm of M. Then S is computed as the lower bound
227 *> (1 + F-norm(R)**2)**(-1/2)
229 *> on the reciprocal of 2-norm(P), the true reciprocal condition number.
230 *> S cannot underestimate 1 / 2-norm(P) by more than a factor of
233 *> An approximate error bound for the computed average of the
234 *> eigenvalues of T11 is
238 *> where EPS is the machine precision.
240 *> The reciprocal condition number of the right invariant subspace
241 *> spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.
242 *> SEP is defined as the separation of T11 and T22:
244 *> sep( T11, T22 ) = sigma-min( C )
246 *> where sigma-min(C) is the smallest singular value of the
247 *> n1*n2-by-n1*n2 matrix
249 *> C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )
251 *> I(m) is an m by m identity matrix, and kprod denotes the Kronecker
252 *> product. We estimate sigma-min(C) by the reciprocal of an estimate of
253 *> the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)
254 *> cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).
256 *> When SEP is small, small changes in T can cause large changes in
257 *> the invariant subspace. An approximate bound on the maximum angular
258 *> error in the computed right invariant subspace is
260 *> EPS * norm(T) / SEP
263 * =====================================================================
264 SUBROUTINE ZTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, W, M, S,
265 $ SEP, WORK, LWORK, INFO )
267 * -- LAPACK computational routine (version 3.4.0) --
268 * -- LAPACK is a software package provided by Univ. of Tennessee, --
269 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
272 * .. Scalar Arguments ..
274 INTEGER INFO, LDQ, LDT, LWORK, M, N
275 DOUBLE PRECISION S, SEP
277 * .. Array Arguments ..
279 COMPLEX*16 Q( LDQ, * ), T( LDT, * ), W( * ), WORK( * )
282 * =====================================================================
285 DOUBLE PRECISION ZERO, ONE
286 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
288 * .. Local Scalars ..
289 LOGICAL LQUERY, WANTBH, WANTQ, WANTS, WANTSP
290 INTEGER IERR, K, KASE, KS, LWMIN, N1, N2, NN
291 DOUBLE PRECISION EST, RNORM, SCALE
295 DOUBLE PRECISION RWORK( 1 )
297 * .. External Functions ..
299 DOUBLE PRECISION ZLANGE
300 EXTERNAL LSAME, ZLANGE
302 * .. External Subroutines ..
303 EXTERNAL XERBLA, ZLACN2, ZLACPY, ZTREXC, ZTRSYL
305 * .. Intrinsic Functions ..
308 * .. Executable Statements ..
310 * Decode and test the input parameters.
312 WANTBH = LSAME( JOB, 'B' )
313 WANTS = LSAME( JOB, 'E' ) .OR. WANTBH
314 WANTSP = LSAME( JOB, 'V' ) .OR. WANTBH
315 WANTQ = LSAME( COMPQ, 'V' )
317 * Set M to the number of selected eigenvalues.
330 LQUERY = ( LWORK.EQ.-1 )
333 LWMIN = MAX( 1, 2*NN )
334 ELSE IF( LSAME( JOB, 'N' ) ) THEN
336 ELSE IF( LSAME( JOB, 'E' ) ) THEN
340 IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.WANTS .AND. .NOT.WANTSP )
343 ELSE IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THEN
345 ELSE IF( N.LT.0 ) THEN
347 ELSE IF( LDT.LT.MAX( 1, N ) ) THEN
349 ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
351 ELSE IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN
360 CALL XERBLA( 'ZTRSEN', -INFO )
362 ELSE IF( LQUERY ) THEN
366 * Quick return if possible
368 IF( M.EQ.N .OR. M.EQ.0 ) THEN
372 $ SEP = ZLANGE( '1', N, N, T, LDT, RWORK )
376 * Collect the selected eigenvalues at the top left corner of T.
380 IF( SELECT( K ) ) THEN
383 * Swap the K-th eigenvalue to position KS.
386 $ CALL ZTREXC( COMPQ, N, T, LDT, Q, LDQ, K, KS, IERR )
392 * Solve the Sylvester equation for R:
394 * T11*R - R*T22 = scale*T12
396 CALL ZLACPY( 'F', N1, N2, T( 1, N1+1 ), LDT, WORK, N1 )
397 CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT, T( N1+1, N1+1 ),
398 $ LDT, WORK, N1, SCALE, IERR )
400 * Estimate the reciprocal of the condition number of the cluster
403 RNORM = ZLANGE( 'F', N1, N2, WORK, N1, RWORK )
404 IF( RNORM.EQ.ZERO ) THEN
407 S = SCALE / ( SQRT( SCALE*SCALE / RNORM+RNORM )*
414 * Estimate sep(T11,T22).
419 CALL ZLACN2( NN, WORK( NN+1 ), WORK, EST, KASE, ISAVE )
423 * Solve T11*R - R*T22 = scale*X.
425 CALL ZTRSYL( 'N', 'N', -1, N1, N2, T, LDT,
426 $ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,
430 * Solve T11**H*R - R*T22**H = scale*X.
432 CALL ZTRSYL( 'C', 'C', -1, N1, N2, T, LDT,
433 $ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE,
444 * Copy reordered eigenvalues to W.