![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DTRSEN 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DTRSEN + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dtrsen.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dtrsen.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dtrsen.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, WR, WI, 00022 * M, S, SEP, WORK, LWORK, IWORK, LIWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * CHARACTER COMPQ, JOB 00026 * INTEGER INFO, LDQ, LDT, LIWORK, LWORK, M, N 00027 * DOUBLE PRECISION S, SEP 00028 * .. 00029 * .. Array Arguments .. 00030 * LOGICAL SELECT( * ) 00031 * INTEGER IWORK( * ) 00032 * DOUBLE PRECISION Q( LDQ, * ), T( LDT, * ), WI( * ), WORK( * ), 00033 * $ WR( * ) 00034 * .. 00035 * 00036 * 00037 *> \par Purpose: 00038 * ============= 00039 *> 00040 *> \verbatim 00041 *> 00042 *> DTRSEN reorders the real Schur factorization of a real matrix 00043 *> A = Q*T*Q**T, so that a selected cluster of eigenvalues appears in 00044 *> the leading diagonal blocks of the upper quasi-triangular matrix T, 00045 *> and the leading columns of Q form an orthonormal basis of the 00046 *> corresponding right invariant subspace. 00047 *> 00048 *> Optionally the routine computes the reciprocal condition numbers of 00049 *> the cluster of eigenvalues and/or the invariant subspace. 00050 *> 00051 *> T must be in Schur canonical form (as returned by DHSEQR), that is, 00052 *> block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each 00053 *> 2-by-2 diagonal block has its diagonal elements equal and its 00054 *> off-diagonal elements of opposite sign. 00055 *> \endverbatim 00056 * 00057 * Arguments: 00058 * ========== 00059 * 00060 *> \param[in] JOB 00061 *> \verbatim 00062 *> JOB is CHARACTER*1 00063 *> Specifies whether condition numbers are required for the 00064 *> cluster of eigenvalues (S) or the invariant subspace (SEP): 00065 *> = 'N': none; 00066 *> = 'E': for eigenvalues only (S); 00067 *> = 'V': for invariant subspace only (SEP); 00068 *> = 'B': for both eigenvalues and invariant subspace (S and 00069 *> SEP). 00070 *> \endverbatim 00071 *> 00072 *> \param[in] COMPQ 00073 *> \verbatim 00074 *> COMPQ is CHARACTER*1 00075 *> = 'V': update the matrix Q of Schur vectors; 00076 *> = 'N': do not update Q. 00077 *> \endverbatim 00078 *> 00079 *> \param[in] SELECT 00080 *> \verbatim 00081 *> SELECT is LOGICAL array, dimension (N) 00082 *> SELECT specifies the eigenvalues in the selected cluster. To 00083 *> select a real eigenvalue w(j), SELECT(j) must be set to 00084 *> .TRUE.. To select a complex conjugate pair of eigenvalues 00085 *> w(j) and w(j+1), corresponding to a 2-by-2 diagonal block, 00086 *> either SELECT(j) or SELECT(j+1) or both must be set to 00087 *> .TRUE.; a complex conjugate pair of eigenvalues must be 00088 *> either both included in the cluster or both excluded. 00089 *> \endverbatim 00090 *> 00091 *> \param[in] N 00092 *> \verbatim 00093 *> N is INTEGER 00094 *> The order of the matrix T. N >= 0. 00095 *> \endverbatim 00096 *> 00097 *> \param[in,out] T 00098 *> \verbatim 00099 *> T is DOUBLE PRECISION array, dimension (LDT,N) 00100 *> On entry, the upper quasi-triangular matrix T, in Schur 00101 *> canonical form. 00102 *> On exit, T is overwritten by the reordered matrix T, again in 00103 *> Schur canonical form, with the selected eigenvalues in the 00104 *> leading diagonal blocks. 00105 *> \endverbatim 00106 *> 00107 *> \param[in] LDT 00108 *> \verbatim 00109 *> LDT is INTEGER 00110 *> The leading dimension of the array T. LDT >= max(1,N). 00111 *> \endverbatim 00112 *> 00113 *> \param[in,out] Q 00114 *> \verbatim 00115 *> Q is DOUBLE PRECISION array, dimension (LDQ,N) 00116 *> On entry, if COMPQ = 'V', the matrix Q of Schur vectors. 00117 *> On exit, if COMPQ = 'V', Q has been postmultiplied by the 00118 *> orthogonal transformation matrix which reorders T; the 00119 *> leading M columns of Q form an orthonormal basis for the 00120 *> specified invariant subspace. 00121 *> If COMPQ = 'N', Q is not referenced. 00122 *> \endverbatim 00123 *> 00124 *> \param[in] LDQ 00125 *> \verbatim 00126 *> LDQ is INTEGER 00127 *> The leading dimension of the array Q. 00128 *> LDQ >= 1; and if COMPQ = 'V', LDQ >= N. 00129 *> \endverbatim 00130 *> 00131 *> \param[out] WR 00132 *> \verbatim 00133 *> WR is DOUBLE PRECISION array, dimension (N) 00134 *> \endverbatim 00135 *> \param[out] WI 00136 *> \verbatim 00137 *> WI is DOUBLE PRECISION array, dimension (N) 00138 *> 00139 *> The real and imaginary parts, respectively, of the reordered 00140 *> eigenvalues of T. The eigenvalues are stored in the same 00141 *> order as on the diagonal of T, with WR(i) = T(i,i) and, if 00142 *> T(i:i+1,i:i+1) is a 2-by-2 diagonal block, WI(i) > 0 and 00143 *> WI(i+1) = -WI(i). Note that if a complex eigenvalue is 00144 *> sufficiently ill-conditioned, then its value may differ 00145 *> significantly from its value before reordering. 00146 *> \endverbatim 00147 *> 00148 *> \param[out] M 00149 *> \verbatim 00150 *> M is INTEGER 00151 *> The dimension of the specified invariant subspace. 00152 *> 0 < = M <= N. 00153 *> \endverbatim 00154 *> 00155 *> \param[out] S 00156 *> \verbatim 00157 *> S is DOUBLE PRECISION 00158 *> If JOB = 'E' or 'B', S is a lower bound on the reciprocal 00159 *> condition number for the selected cluster of eigenvalues. 00160 *> S cannot underestimate the true reciprocal condition number 00161 *> by more than a factor of sqrt(N). If M = 0 or N, S = 1. 00162 *> If JOB = 'N' or 'V', S is not referenced. 00163 *> \endverbatim 00164 *> 00165 *> \param[out] SEP 00166 *> \verbatim 00167 *> SEP is DOUBLE PRECISION 00168 *> If JOB = 'V' or 'B', SEP is the estimated reciprocal 00169 *> condition number of the specified invariant subspace. If 00170 *> M = 0 or N, SEP = norm(T). 00171 *> If JOB = 'N' or 'E', SEP is not referenced. 00172 *> \endverbatim 00173 *> 00174 *> \param[out] WORK 00175 *> \verbatim 00176 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)) 00177 *> On exit, if INFO = 0, WORK(1) returns the optimal LWORK. 00178 *> \endverbatim 00179 *> 00180 *> \param[in] LWORK 00181 *> \verbatim 00182 *> LWORK is INTEGER 00183 *> The dimension of the array WORK. 00184 *> If JOB = 'N', LWORK >= max(1,N); 00185 *> if JOB = 'E', LWORK >= max(1,M*(N-M)); 00186 *> if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)). 00187 *> 00188 *> If LWORK = -1, then a workspace query is assumed; the routine 00189 *> only calculates the optimal size of the WORK array, returns 00190 *> this value as the first entry of the WORK array, and no error 00191 *> message related to LWORK is issued by XERBLA. 00192 *> \endverbatim 00193 *> 00194 *> \param[out] IWORK 00195 *> \verbatim 00196 *> IWORK is INTEGER array, dimension (MAX(1,LIWORK)) 00197 *> On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. 00198 *> \endverbatim 00199 *> 00200 *> \param[in] LIWORK 00201 *> \verbatim 00202 *> LIWORK is INTEGER 00203 *> The dimension of the array IWORK. 00204 *> If JOB = 'N' or 'E', LIWORK >= 1; 00205 *> if JOB = 'V' or 'B', LIWORK >= max(1,M*(N-M)). 00206 *> 00207 *> If LIWORK = -1, then a workspace query is assumed; the 00208 *> routine only calculates the optimal size of the IWORK array, 00209 *> returns this value as the first entry of the IWORK array, and 00210 *> no error message related to LIWORK is issued by XERBLA. 00211 *> \endverbatim 00212 *> 00213 *> \param[out] INFO 00214 *> \verbatim 00215 *> INFO is INTEGER 00216 *> = 0: successful exit 00217 *> < 0: if INFO = -i, the i-th argument had an illegal value 00218 *> = 1: reordering of T failed because some eigenvalues are too 00219 *> close to separate (the problem is very ill-conditioned); 00220 *> T may have been partially reordered, and WR and WI 00221 *> contain the eigenvalues in the same order as in T; S and 00222 *> SEP (if requested) are set to zero. 00223 *> \endverbatim 00224 * 00225 * Authors: 00226 * ======== 00227 * 00228 *> \author Univ. of Tennessee 00229 *> \author Univ. of California Berkeley 00230 *> \author Univ. of Colorado Denver 00231 *> \author NAG Ltd. 00232 * 00233 *> \date April 2012 00234 * 00235 *> \ingroup doubleOTHERcomputational 00236 * 00237 *> \par Further Details: 00238 * ===================== 00239 *> 00240 *> \verbatim 00241 *> 00242 *> DTRSEN first collects the selected eigenvalues by computing an 00243 *> orthogonal transformation Z to move them to the top left corner of T. 00244 *> In other words, the selected eigenvalues are the eigenvalues of T11 00245 *> in: 00246 *> 00247 *> Z**T * T * Z = ( T11 T12 ) n1 00248 *> ( 0 T22 ) n2 00249 *> n1 n2 00250 *> 00251 *> where N = n1+n2 and Z**T means the transpose of Z. The first n1 columns 00252 *> of Z span the specified invariant subspace of T. 00253 *> 00254 *> If T has been obtained from the real Schur factorization of a matrix 00255 *> A = Q*T*Q**T, then the reordered real Schur factorization of A is given 00256 *> by A = (Q*Z)*(Z**T*T*Z)*(Q*Z)**T, and the first n1 columns of Q*Z span 00257 *> the corresponding invariant subspace of A. 00258 *> 00259 *> The reciprocal condition number of the average of the eigenvalues of 00260 *> T11 may be returned in S. S lies between 0 (very badly conditioned) 00261 *> and 1 (very well conditioned). It is computed as follows. First we 00262 *> compute R so that 00263 *> 00264 *> P = ( I R ) n1 00265 *> ( 0 0 ) n2 00266 *> n1 n2 00267 *> 00268 *> is the projector on the invariant subspace associated with T11. 00269 *> R is the solution of the Sylvester equation: 00270 *> 00271 *> T11*R - R*T22 = T12. 00272 *> 00273 *> Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote 00274 *> the two-norm of M. Then S is computed as the lower bound 00275 *> 00276 *> (1 + F-norm(R)**2)**(-1/2) 00277 *> 00278 *> on the reciprocal of 2-norm(P), the true reciprocal condition number. 00279 *> S cannot underestimate 1 / 2-norm(P) by more than a factor of 00280 *> sqrt(N). 00281 *> 00282 *> An approximate error bound for the computed average of the 00283 *> eigenvalues of T11 is 00284 *> 00285 *> EPS * norm(T) / S 00286 *> 00287 *> where EPS is the machine precision. 00288 *> 00289 *> The reciprocal condition number of the right invariant subspace 00290 *> spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP. 00291 *> SEP is defined as the separation of T11 and T22: 00292 *> 00293 *> sep( T11, T22 ) = sigma-min( C ) 00294 *> 00295 *> where sigma-min(C) is the smallest singular value of the 00296 *> n1*n2-by-n1*n2 matrix 00297 *> 00298 *> C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) ) 00299 *> 00300 *> I(m) is an m by m identity matrix, and kprod denotes the Kronecker 00301 *> product. We estimate sigma-min(C) by the reciprocal of an estimate of 00302 *> the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C) 00303 *> cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2). 00304 *> 00305 *> When SEP is small, small changes in T can cause large changes in 00306 *> the invariant subspace. An approximate bound on the maximum angular 00307 *> error in the computed right invariant subspace is 00308 *> 00309 *> EPS * norm(T) / SEP 00310 *> \endverbatim 00311 *> 00312 * ===================================================================== 00313 SUBROUTINE DTRSEN( JOB, COMPQ, SELECT, N, T, LDT, Q, LDQ, WR, WI, 00314 $ M, S, SEP, WORK, LWORK, IWORK, LIWORK, INFO ) 00315 * 00316 * -- LAPACK computational routine (version 3.4.1) -- 00317 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00318 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00319 * April 2012 00320 * 00321 * .. Scalar Arguments .. 00322 CHARACTER COMPQ, JOB 00323 INTEGER INFO, LDQ, LDT, LIWORK, LWORK, M, N 00324 DOUBLE PRECISION S, SEP 00325 * .. 00326 * .. Array Arguments .. 00327 LOGICAL SELECT( * ) 00328 INTEGER IWORK( * ) 00329 DOUBLE PRECISION Q( LDQ, * ), T( LDT, * ), WI( * ), WORK( * ), 00330 $ WR( * ) 00331 * .. 00332 * 00333 * ===================================================================== 00334 * 00335 * .. Parameters .. 00336 DOUBLE PRECISION ZERO, ONE 00337 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00338 * .. 00339 * .. Local Scalars .. 00340 LOGICAL LQUERY, PAIR, SWAP, WANTBH, WANTQ, WANTS, 00341 $ WANTSP 00342 INTEGER IERR, K, KASE, KK, KS, LIWMIN, LWMIN, N1, N2, 00343 $ NN 00344 DOUBLE PRECISION EST, RNORM, SCALE 00345 * .. 00346 * .. Local Arrays .. 00347 INTEGER ISAVE( 3 ) 00348 * .. 00349 * .. External Functions .. 00350 LOGICAL LSAME 00351 DOUBLE PRECISION DLANGE 00352 EXTERNAL LSAME, DLANGE 00353 * .. 00354 * .. External Subroutines .. 00355 EXTERNAL DLACN2, DLACPY, DTREXC, DTRSYL, XERBLA 00356 * .. 00357 * .. Intrinsic Functions .. 00358 INTRINSIC ABS, MAX, SQRT 00359 * .. 00360 * .. Executable Statements .. 00361 * 00362 * Decode and test the input parameters 00363 * 00364 WANTBH = LSAME( JOB, 'B' ) 00365 WANTS = LSAME( JOB, 'E' ) .OR. WANTBH 00366 WANTSP = LSAME( JOB, 'V' ) .OR. WANTBH 00367 WANTQ = LSAME( COMPQ, 'V' ) 00368 * 00369 INFO = 0 00370 LQUERY = ( LWORK.EQ.-1 ) 00371 IF( .NOT.LSAME( JOB, 'N' ) .AND. .NOT.WANTS .AND. .NOT.WANTSP ) 00372 $ THEN 00373 INFO = -1 00374 ELSE IF( .NOT.LSAME( COMPQ, 'N' ) .AND. .NOT.WANTQ ) THEN 00375 INFO = -2 00376 ELSE IF( N.LT.0 ) THEN 00377 INFO = -4 00378 ELSE IF( LDT.LT.MAX( 1, N ) ) THEN 00379 INFO = -6 00380 ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN 00381 INFO = -8 00382 ELSE 00383 * 00384 * Set M to the dimension of the specified invariant subspace, 00385 * and test LWORK and LIWORK. 00386 * 00387 M = 0 00388 PAIR = .FALSE. 00389 DO 10 K = 1, N 00390 IF( PAIR ) THEN 00391 PAIR = .FALSE. 00392 ELSE 00393 IF( K.LT.N ) THEN 00394 IF( T( K+1, K ).EQ.ZERO ) THEN 00395 IF( SELECT( K ) ) 00396 $ M = M + 1 00397 ELSE 00398 PAIR = .TRUE. 00399 IF( SELECT( K ) .OR. SELECT( K+1 ) ) 00400 $ M = M + 2 00401 END IF 00402 ELSE 00403 IF( SELECT( N ) ) 00404 $ M = M + 1 00405 END IF 00406 END IF 00407 10 CONTINUE 00408 * 00409 N1 = M 00410 N2 = N - M 00411 NN = N1*N2 00412 * 00413 IF( WANTSP ) THEN 00414 LWMIN = MAX( 1, 2*NN ) 00415 LIWMIN = MAX( 1, NN ) 00416 ELSE IF( LSAME( JOB, 'N' ) ) THEN 00417 LWMIN = MAX( 1, N ) 00418 LIWMIN = 1 00419 ELSE IF( LSAME( JOB, 'E' ) ) THEN 00420 LWMIN = MAX( 1, NN ) 00421 LIWMIN = 1 00422 END IF 00423 * 00424 IF( LWORK.LT.LWMIN .AND. .NOT.LQUERY ) THEN 00425 INFO = -15 00426 ELSE IF( LIWORK.LT.LIWMIN .AND. .NOT.LQUERY ) THEN 00427 INFO = -17 00428 END IF 00429 END IF 00430 * 00431 IF( INFO.EQ.0 ) THEN 00432 WORK( 1 ) = LWMIN 00433 IWORK( 1 ) = LIWMIN 00434 END IF 00435 * 00436 IF( INFO.NE.0 ) THEN 00437 CALL XERBLA( 'DTRSEN', -INFO ) 00438 RETURN 00439 ELSE IF( LQUERY ) THEN 00440 RETURN 00441 END IF 00442 * 00443 * Quick return if possible. 00444 * 00445 IF( M.EQ.N .OR. M.EQ.0 ) THEN 00446 IF( WANTS ) 00447 $ S = ONE 00448 IF( WANTSP ) 00449 $ SEP = DLANGE( '1', N, N, T, LDT, WORK ) 00450 GO TO 40 00451 END IF 00452 * 00453 * Collect the selected blocks at the top-left corner of T. 00454 * 00455 KS = 0 00456 PAIR = .FALSE. 00457 DO 20 K = 1, N 00458 IF( PAIR ) THEN 00459 PAIR = .FALSE. 00460 ELSE 00461 SWAP = SELECT( K ) 00462 IF( K.LT.N ) THEN 00463 IF( T( K+1, K ).NE.ZERO ) THEN 00464 PAIR = .TRUE. 00465 SWAP = SWAP .OR. SELECT( K+1 ) 00466 END IF 00467 END IF 00468 IF( SWAP ) THEN 00469 KS = KS + 1 00470 * 00471 * Swap the K-th block to position KS. 00472 * 00473 IERR = 0 00474 KK = K 00475 IF( K.NE.KS ) 00476 $ CALL DTREXC( COMPQ, N, T, LDT, Q, LDQ, KK, KS, WORK, 00477 $ IERR ) 00478 IF( IERR.EQ.1 .OR. IERR.EQ.2 ) THEN 00479 * 00480 * Blocks too close to swap: exit. 00481 * 00482 INFO = 1 00483 IF( WANTS ) 00484 $ S = ZERO 00485 IF( WANTSP ) 00486 $ SEP = ZERO 00487 GO TO 40 00488 END IF 00489 IF( PAIR ) 00490 $ KS = KS + 1 00491 END IF 00492 END IF 00493 20 CONTINUE 00494 * 00495 IF( WANTS ) THEN 00496 * 00497 * Solve Sylvester equation for R: 00498 * 00499 * T11*R - R*T22 = scale*T12 00500 * 00501 CALL DLACPY( 'F', N1, N2, T( 1, N1+1 ), LDT, WORK, N1 ) 00502 CALL DTRSYL( 'N', 'N', -1, N1, N2, T, LDT, T( N1+1, N1+1 ), 00503 $ LDT, WORK, N1, SCALE, IERR ) 00504 * 00505 * Estimate the reciprocal of the condition number of the cluster 00506 * of eigenvalues. 00507 * 00508 RNORM = DLANGE( 'F', N1, N2, WORK, N1, WORK ) 00509 IF( RNORM.EQ.ZERO ) THEN 00510 S = ONE 00511 ELSE 00512 S = SCALE / ( SQRT( SCALE*SCALE / RNORM+RNORM )* 00513 $ SQRT( RNORM ) ) 00514 END IF 00515 END IF 00516 * 00517 IF( WANTSP ) THEN 00518 * 00519 * Estimate sep(T11,T22). 00520 * 00521 EST = ZERO 00522 KASE = 0 00523 30 CONTINUE 00524 CALL DLACN2( NN, WORK( NN+1 ), WORK, IWORK, EST, KASE, ISAVE ) 00525 IF( KASE.NE.0 ) THEN 00526 IF( KASE.EQ.1 ) THEN 00527 * 00528 * Solve T11*R - R*T22 = scale*X. 00529 * 00530 CALL DTRSYL( 'N', 'N', -1, N1, N2, T, LDT, 00531 $ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE, 00532 $ IERR ) 00533 ELSE 00534 * 00535 * Solve T11**T*R - R*T22**T = scale*X. 00536 * 00537 CALL DTRSYL( 'T', 'T', -1, N1, N2, T, LDT, 00538 $ T( N1+1, N1+1 ), LDT, WORK, N1, SCALE, 00539 $ IERR ) 00540 END IF 00541 GO TO 30 00542 END IF 00543 * 00544 SEP = SCALE / EST 00545 END IF 00546 * 00547 40 CONTINUE 00548 * 00549 * Store the output eigenvalues in WR and WI. 00550 * 00551 DO 50 K = 1, N 00552 WR( K ) = T( K, K ) 00553 WI( K ) = ZERO 00554 50 CONTINUE 00555 DO 60 K = 1, N - 1 00556 IF( T( K+1, K ).NE.ZERO ) THEN 00557 WI( K ) = SQRT( ABS( T( K, K+1 ) ) )* 00558 $ SQRT( ABS( T( K+1, K ) ) ) 00559 WI( K+1 ) = -WI( K ) 00560 END IF 00561 60 CONTINUE 00562 * 00563 WORK( 1 ) = LWMIN 00564 IWORK( 1 ) = LIWMIN 00565 * 00566 RETURN 00567 * 00568 * End of DTRSEN 00569 * 00570 END