![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SLAQR4 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SLAQR4 + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slaqr4.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slaqr4.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slaqr4.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE SLAQR4( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, 00022 * ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO ) 00023 * 00024 * .. Scalar Arguments .. 00025 * INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N 00026 * LOGICAL WANTT, WANTZ 00027 * .. 00028 * .. Array Arguments .. 00029 * REAL H( LDH, * ), WI( * ), WORK( * ), WR( * ), 00030 * $ Z( LDZ, * ) 00031 * .. 00032 * 00033 * 00034 *> \par Purpose: 00035 * ============= 00036 *> 00037 *> \verbatim 00038 *> 00039 *> SLAQR4 implements one level of recursion for SLAQR0. 00040 *> It is a complete implementation of the small bulge multi-shift 00041 *> QR algorithm. It may be called by SLAQR0 and, for large enough 00042 *> deflation window size, it may be called by SLAQR3. This 00043 *> subroutine is identical to SLAQR0 except that it calls SLAQR2 00044 *> instead of SLAQR3. 00045 *> 00046 *> SLAQR4 computes the eigenvalues of a Hessenberg matrix H 00047 *> and, optionally, the matrices T and Z from the Schur decomposition 00048 *> H = Z T Z**T, where T is an upper quasi-triangular matrix (the 00049 *> Schur form), and Z is the orthogonal matrix of Schur vectors. 00050 *> 00051 *> Optionally Z may be postmultiplied into an input orthogonal 00052 *> matrix Q so that this routine can give the Schur factorization 00053 *> of a matrix A which has been reduced to the Hessenberg form H 00054 *> by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T. 00055 *> \endverbatim 00056 * 00057 * Arguments: 00058 * ========== 00059 * 00060 *> \param[in] WANTT 00061 *> \verbatim 00062 *> WANTT is LOGICAL 00063 *> = .TRUE. : the full Schur form T is required; 00064 *> = .FALSE.: only eigenvalues are required. 00065 *> \endverbatim 00066 *> 00067 *> \param[in] WANTZ 00068 *> \verbatim 00069 *> WANTZ is LOGICAL 00070 *> = .TRUE. : the matrix of Schur vectors Z is required; 00071 *> = .FALSE.: Schur vectors are not required. 00072 *> \endverbatim 00073 *> 00074 *> \param[in] N 00075 *> \verbatim 00076 *> N is INTEGER 00077 *> The order of the matrix H. N .GE. 0. 00078 *> \endverbatim 00079 *> 00080 *> \param[in] ILO 00081 *> \verbatim 00082 *> ILO is INTEGER 00083 *> \endverbatim 00084 *> 00085 *> \param[in] IHI 00086 *> \verbatim 00087 *> IHI is INTEGER 00088 *> It is assumed that H is already upper triangular in rows 00089 *> and columns 1:ILO-1 and IHI+1:N and, if ILO.GT.1, 00090 *> H(ILO,ILO-1) is zero. ILO and IHI are normally set by a 00091 *> previous call to SGEBAL, and then passed to SGEHRD when the 00092 *> matrix output by SGEBAL is reduced to Hessenberg form. 00093 *> Otherwise, ILO and IHI should be set to 1 and N, 00094 *> respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N. 00095 *> If N = 0, then ILO = 1 and IHI = 0. 00096 *> \endverbatim 00097 *> 00098 *> \param[in,out] H 00099 *> \verbatim 00100 *> H is REAL array, dimension (LDH,N) 00101 *> On entry, the upper Hessenberg matrix H. 00102 *> On exit, if INFO = 0 and WANTT is .TRUE., then H contains 00103 *> the upper quasi-triangular matrix T from the Schur 00104 *> decomposition (the Schur form); 2-by-2 diagonal blocks 00105 *> (corresponding to complex conjugate pairs of eigenvalues) 00106 *> are returned in standard form, with H(i,i) = H(i+1,i+1) 00107 *> and H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and WANTT is 00108 *> .FALSE., then the contents of H are unspecified on exit. 00109 *> (The output value of H when INFO.GT.0 is given under the 00110 *> description of INFO below.) 00111 *> 00112 *> This subroutine may explicitly set H(i,j) = 0 for i.GT.j and 00113 *> j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N. 00114 *> \endverbatim 00115 *> 00116 *> \param[in] LDH 00117 *> \verbatim 00118 *> LDH is INTEGER 00119 *> The leading dimension of the array H. LDH .GE. max(1,N). 00120 *> \endverbatim 00121 *> 00122 *> \param[out] WR 00123 *> \verbatim 00124 *> WR is REAL array, dimension (IHI) 00125 *> \endverbatim 00126 *> 00127 *> \param[out] WI 00128 *> \verbatim 00129 *> WI is REAL array, dimension (IHI) 00130 *> The real and imaginary parts, respectively, of the computed 00131 *> eigenvalues of H(ILO:IHI,ILO:IHI) are stored in WR(ILO:IHI) 00132 *> and WI(ILO:IHI). If two eigenvalues are computed as a 00133 *> complex conjugate pair, they are stored in consecutive 00134 *> elements of WR and WI, say the i-th and (i+1)th, with 00135 *> WI(i) .GT. 0 and WI(i+1) .LT. 0. If WANTT is .TRUE., then 00136 *> the eigenvalues are stored in the same order as on the 00137 *> diagonal of the Schur form returned in H, with 00138 *> WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2 diagonal 00139 *> block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and 00140 *> WI(i+1) = -WI(i). 00141 *> \endverbatim 00142 *> 00143 *> \param[in] ILOZ 00144 *> \verbatim 00145 *> ILOZ is INTEGER 00146 *> \endverbatim 00147 *> 00148 *> \param[in] IHIZ 00149 *> \verbatim 00150 *> IHIZ is INTEGER 00151 *> Specify the rows of Z to which transformations must be 00152 *> applied if WANTZ is .TRUE.. 00153 *> 1 .LE. ILOZ .LE. ILO; IHI .LE. IHIZ .LE. N. 00154 *> \endverbatim 00155 *> 00156 *> \param[in,out] Z 00157 *> \verbatim 00158 *> Z is REAL array, dimension (LDZ,IHI) 00159 *> If WANTZ is .FALSE., then Z is not referenced. 00160 *> If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is 00161 *> replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the 00162 *> orthogonal Schur factor of H(ILO:IHI,ILO:IHI). 00163 *> (The output value of Z when INFO.GT.0 is given under 00164 *> the description of INFO below.) 00165 *> \endverbatim 00166 *> 00167 *> \param[in] LDZ 00168 *> \verbatim 00169 *> LDZ is INTEGER 00170 *> The leading dimension of the array Z. if WANTZ is .TRUE. 00171 *> then LDZ.GE.MAX(1,IHIZ). Otherwize, LDZ.GE.1. 00172 *> \endverbatim 00173 *> 00174 *> \param[out] WORK 00175 *> \verbatim 00176 *> WORK is REAL array, dimension LWORK 00177 *> On exit, if LWORK = -1, WORK(1) returns an estimate of 00178 *> the optimal value for LWORK. 00179 *> \endverbatim 00180 *> 00181 *> \param[in] LWORK 00182 *> \verbatim 00183 *> LWORK is INTEGER 00184 *> The dimension of the array WORK. LWORK .GE. max(1,N) 00185 *> is sufficient, but LWORK typically as large as 6*N may 00186 *> be required for optimal performance. A workspace query 00187 *> to determine the optimal workspace size is recommended. 00188 *> 00189 *> If LWORK = -1, then SLAQR4 does a workspace query. 00190 *> In this case, SLAQR4 checks the input parameters and 00191 *> estimates the optimal workspace size for the given 00192 *> values of N, ILO and IHI. The estimate is returned 00193 *> in WORK(1). No error message related to LWORK is 00194 *> issued by XERBLA. Neither H nor Z are accessed. 00195 *> \endverbatim 00196 *> 00197 *> \param[out] INFO 00198 *> \verbatim 00199 *> INFO is INTEGER 00200 *> \verbatim 00201 *> INFO is INTEGER 00202 *> = 0: successful exit 00203 *> .GT. 0: if INFO = i, SLAQR4 failed to compute all of 00204 *> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR 00205 *> and WI contain those eigenvalues which have been 00206 *> successfully computed. (Failures are rare.) 00207 *> 00208 *> If INFO .GT. 0 and WANT is .FALSE., then on exit, 00209 *> the remaining unconverged eigenvalues are the eigen- 00210 *> values of the upper Hessenberg matrix rows and 00211 *> columns ILO through INFO of the final, output 00212 *> value of H. 00213 *> 00214 *> If INFO .GT. 0 and WANTT is .TRUE., then on exit 00215 *> 00216 *> (*) (initial value of H)*U = U*(final value of H) 00217 *> 00218 *> where U is a orthogonal matrix. The final 00219 *> value of H is upper Hessenberg and triangular in 00220 *> rows and columns INFO+1 through IHI. 00221 *> 00222 *> If INFO .GT. 0 and WANTZ is .TRUE., then on exit 00223 *> 00224 *> (final value of Z(ILO:IHI,ILOZ:IHIZ) 00225 *> = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U 00226 *> 00227 *> where U is the orthogonal matrix in (*) (regard- 00228 *> less of the value of WANTT.) 00229 *> 00230 *> If INFO .GT. 0 and WANTZ is .FALSE., then Z is not 00231 *> accessed. 00232 *> \endverbatim 00233 * 00234 * Authors: 00235 * ======== 00236 * 00237 *> \author Univ. of Tennessee 00238 *> \author Univ. of California Berkeley 00239 *> \author Univ. of Colorado Denver 00240 *> \author NAG Ltd. 00241 * 00242 *> \date November 2011 00243 * 00244 *> \ingroup realOTHERauxiliary 00245 * 00246 *> \par Contributors: 00247 * ================== 00248 *> 00249 *> Karen Braman and Ralph Byers, Department of Mathematics, 00250 *> University of Kansas, USA 00251 * 00252 *> \par References: 00253 * ================ 00254 *> 00255 *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR 00256 *> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 00257 *> Performance, SIAM Journal of Matrix Analysis, volume 23, pages 00258 *> 929--947, 2002. 00259 *> \n 00260 *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR 00261 *> Algorithm Part II: Aggressive Early Deflation, SIAM Journal 00262 *> of Matrix Analysis, volume 23, pages 948--973, 2002. 00263 *> 00264 * ===================================================================== 00265 SUBROUTINE SLAQR4( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, 00266 $ ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO ) 00267 * 00268 * -- LAPACK auxiliary routine (version 3.4.0) -- 00269 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00270 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00271 * November 2011 00272 * 00273 * .. Scalar Arguments .. 00274 INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N 00275 LOGICAL WANTT, WANTZ 00276 * .. 00277 * .. Array Arguments .. 00278 REAL H( LDH, * ), WI( * ), WORK( * ), WR( * ), 00279 $ Z( LDZ, * ) 00280 * .. 00281 * 00282 * ================================================================ 00283 * 00284 * .. Parameters .. 00285 * 00286 * ==== Matrices of order NTINY or smaller must be processed by 00287 * . SLAHQR because of insufficient subdiagonal scratch space. 00288 * . (This is a hard limit.) ==== 00289 INTEGER NTINY 00290 PARAMETER ( NTINY = 11 ) 00291 * 00292 * ==== Exceptional deflation windows: try to cure rare 00293 * . slow convergence by varying the size of the 00294 * . deflation window after KEXNW iterations. ==== 00295 INTEGER KEXNW 00296 PARAMETER ( KEXNW = 5 ) 00297 * 00298 * ==== Exceptional shifts: try to cure rare slow convergence 00299 * . with ad-hoc exceptional shifts every KEXSH iterations. 00300 * . ==== 00301 INTEGER KEXSH 00302 PARAMETER ( KEXSH = 6 ) 00303 * 00304 * ==== The constants WILK1 and WILK2 are used to form the 00305 * . exceptional shifts. ==== 00306 REAL WILK1, WILK2 00307 PARAMETER ( WILK1 = 0.75e0, WILK2 = -0.4375e0 ) 00308 REAL ZERO, ONE 00309 PARAMETER ( ZERO = 0.0e0, ONE = 1.0e0 ) 00310 * .. 00311 * .. Local Scalars .. 00312 REAL AA, BB, CC, CS, DD, SN, SS, SWAP 00313 INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS, 00314 $ KT, KTOP, KU, KV, KWH, KWTOP, KWV, LD, LS, 00315 $ LWKOPT, NDEC, NDFL, NH, NHO, NIBBLE, NMIN, NS, 00316 $ NSMAX, NSR, NVE, NW, NWMAX, NWR, NWUPBD 00317 LOGICAL SORTED 00318 CHARACTER JBCMPZ*2 00319 * .. 00320 * .. External Functions .. 00321 INTEGER ILAENV 00322 EXTERNAL ILAENV 00323 * .. 00324 * .. Local Arrays .. 00325 REAL ZDUM( 1, 1 ) 00326 * .. 00327 * .. External Subroutines .. 00328 EXTERNAL SLACPY, SLAHQR, SLANV2, SLAQR2, SLAQR5 00329 * .. 00330 * .. Intrinsic Functions .. 00331 INTRINSIC ABS, INT, MAX, MIN, MOD, REAL 00332 * .. 00333 * .. Executable Statements .. 00334 INFO = 0 00335 * 00336 * ==== Quick return for N = 0: nothing to do. ==== 00337 * 00338 IF( N.EQ.0 ) THEN 00339 WORK( 1 ) = ONE 00340 RETURN 00341 END IF 00342 * 00343 IF( N.LE.NTINY ) THEN 00344 * 00345 * ==== Tiny matrices must use SLAHQR. ==== 00346 * 00347 LWKOPT = 1 00348 IF( LWORK.NE.-1 ) 00349 $ CALL SLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, 00350 $ ILOZ, IHIZ, Z, LDZ, INFO ) 00351 ELSE 00352 * 00353 * ==== Use small bulge multi-shift QR with aggressive early 00354 * . deflation on larger-than-tiny matrices. ==== 00355 * 00356 * ==== Hope for the best. ==== 00357 * 00358 INFO = 0 00359 * 00360 * ==== Set up job flags for ILAENV. ==== 00361 * 00362 IF( WANTT ) THEN 00363 JBCMPZ( 1: 1 ) = 'S' 00364 ELSE 00365 JBCMPZ( 1: 1 ) = 'E' 00366 END IF 00367 IF( WANTZ ) THEN 00368 JBCMPZ( 2: 2 ) = 'V' 00369 ELSE 00370 JBCMPZ( 2: 2 ) = 'N' 00371 END IF 00372 * 00373 * ==== NWR = recommended deflation window size. At this 00374 * . point, N .GT. NTINY = 11, so there is enough 00375 * . subdiagonal workspace for NWR.GE.2 as required. 00376 * . (In fact, there is enough subdiagonal space for 00377 * . NWR.GE.3.) ==== 00378 * 00379 NWR = ILAENV( 13, 'SLAQR4', JBCMPZ, N, ILO, IHI, LWORK ) 00380 NWR = MAX( 2, NWR ) 00381 NWR = MIN( IHI-ILO+1, ( N-1 ) / 3, NWR ) 00382 * 00383 * ==== NSR = recommended number of simultaneous shifts. 00384 * . At this point N .GT. NTINY = 11, so there is at 00385 * . enough subdiagonal workspace for NSR to be even 00386 * . and greater than or equal to two as required. ==== 00387 * 00388 NSR = ILAENV( 15, 'SLAQR4', JBCMPZ, N, ILO, IHI, LWORK ) 00389 NSR = MIN( NSR, ( N+6 ) / 9, IHI-ILO ) 00390 NSR = MAX( 2, NSR-MOD( NSR, 2 ) ) 00391 * 00392 * ==== Estimate optimal workspace ==== 00393 * 00394 * ==== Workspace query call to SLAQR2 ==== 00395 * 00396 CALL SLAQR2( WANTT, WANTZ, N, ILO, IHI, NWR+1, H, LDH, ILOZ, 00397 $ IHIZ, Z, LDZ, LS, LD, WR, WI, H, LDH, N, H, LDH, 00398 $ N, H, LDH, WORK, -1 ) 00399 * 00400 * ==== Optimal workspace = MAX(SLAQR5, SLAQR2) ==== 00401 * 00402 LWKOPT = MAX( 3*NSR / 2, INT( WORK( 1 ) ) ) 00403 * 00404 * ==== Quick return in case of workspace query. ==== 00405 * 00406 IF( LWORK.EQ.-1 ) THEN 00407 WORK( 1 ) = REAL( LWKOPT ) 00408 RETURN 00409 END IF 00410 * 00411 * ==== SLAHQR/SLAQR0 crossover point ==== 00412 * 00413 NMIN = ILAENV( 12, 'SLAQR4', JBCMPZ, N, ILO, IHI, LWORK ) 00414 NMIN = MAX( NTINY, NMIN ) 00415 * 00416 * ==== Nibble crossover point ==== 00417 * 00418 NIBBLE = ILAENV( 14, 'SLAQR4', JBCMPZ, N, ILO, IHI, LWORK ) 00419 NIBBLE = MAX( 0, NIBBLE ) 00420 * 00421 * ==== Accumulate reflections during ttswp? Use block 00422 * . 2-by-2 structure during matrix-matrix multiply? ==== 00423 * 00424 KACC22 = ILAENV( 16, 'SLAQR4', JBCMPZ, N, ILO, IHI, LWORK ) 00425 KACC22 = MAX( 0, KACC22 ) 00426 KACC22 = MIN( 2, KACC22 ) 00427 * 00428 * ==== NWMAX = the largest possible deflation window for 00429 * . which there is sufficient workspace. ==== 00430 * 00431 NWMAX = MIN( ( N-1 ) / 3, LWORK / 2 ) 00432 NW = NWMAX 00433 * 00434 * ==== NSMAX = the Largest number of simultaneous shifts 00435 * . for which there is sufficient workspace. ==== 00436 * 00437 NSMAX = MIN( ( N+6 ) / 9, 2*LWORK / 3 ) 00438 NSMAX = NSMAX - MOD( NSMAX, 2 ) 00439 * 00440 * ==== NDFL: an iteration count restarted at deflation. ==== 00441 * 00442 NDFL = 1 00443 * 00444 * ==== ITMAX = iteration limit ==== 00445 * 00446 ITMAX = MAX( 30, 2*KEXSH )*MAX( 10, ( IHI-ILO+1 ) ) 00447 * 00448 * ==== Last row and column in the active block ==== 00449 * 00450 KBOT = IHI 00451 * 00452 * ==== Main Loop ==== 00453 * 00454 DO 80 IT = 1, ITMAX 00455 * 00456 * ==== Done when KBOT falls below ILO ==== 00457 * 00458 IF( KBOT.LT.ILO ) 00459 $ GO TO 90 00460 * 00461 * ==== Locate active block ==== 00462 * 00463 DO 10 K = KBOT, ILO + 1, -1 00464 IF( H( K, K-1 ).EQ.ZERO ) 00465 $ GO TO 20 00466 10 CONTINUE 00467 K = ILO 00468 20 CONTINUE 00469 KTOP = K 00470 * 00471 * ==== Select deflation window size: 00472 * . Typical Case: 00473 * . If possible and advisable, nibble the entire 00474 * . active block. If not, use size MIN(NWR,NWMAX) 00475 * . or MIN(NWR+1,NWMAX) depending upon which has 00476 * . the smaller corresponding subdiagonal entry 00477 * . (a heuristic). 00478 * . 00479 * . Exceptional Case: 00480 * . If there have been no deflations in KEXNW or 00481 * . more iterations, then vary the deflation window 00482 * . size. At first, because, larger windows are, 00483 * . in general, more powerful than smaller ones, 00484 * . rapidly increase the window to the maximum possible. 00485 * . Then, gradually reduce the window size. ==== 00486 * 00487 NH = KBOT - KTOP + 1 00488 NWUPBD = MIN( NH, NWMAX ) 00489 IF( NDFL.LT.KEXNW ) THEN 00490 NW = MIN( NWUPBD, NWR ) 00491 ELSE 00492 NW = MIN( NWUPBD, 2*NW ) 00493 END IF 00494 IF( NW.LT.NWMAX ) THEN 00495 IF( NW.GE.NH-1 ) THEN 00496 NW = NH 00497 ELSE 00498 KWTOP = KBOT - NW + 1 00499 IF( ABS( H( KWTOP, KWTOP-1 ) ).GT. 00500 $ ABS( H( KWTOP-1, KWTOP-2 ) ) )NW = NW + 1 00501 END IF 00502 END IF 00503 IF( NDFL.LT.KEXNW ) THEN 00504 NDEC = -1 00505 ELSE IF( NDEC.GE.0 .OR. NW.GE.NWUPBD ) THEN 00506 NDEC = NDEC + 1 00507 IF( NW-NDEC.LT.2 ) 00508 $ NDEC = 0 00509 NW = NW - NDEC 00510 END IF 00511 * 00512 * ==== Aggressive early deflation: 00513 * . split workspace under the subdiagonal into 00514 * . - an nw-by-nw work array V in the lower 00515 * . left-hand-corner, 00516 * . - an NW-by-at-least-NW-but-more-is-better 00517 * . (NW-by-NHO) horizontal work array along 00518 * . the bottom edge, 00519 * . - an at-least-NW-but-more-is-better (NHV-by-NW) 00520 * . vertical work array along the left-hand-edge. 00521 * . ==== 00522 * 00523 KV = N - NW + 1 00524 KT = NW + 1 00525 NHO = ( N-NW-1 ) - KT + 1 00526 KWV = NW + 2 00527 NVE = ( N-NW ) - KWV + 1 00528 * 00529 * ==== Aggressive early deflation ==== 00530 * 00531 CALL SLAQR2( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ, 00532 $ IHIZ, Z, LDZ, LS, LD, WR, WI, H( KV, 1 ), LDH, 00533 $ NHO, H( KV, KT ), LDH, NVE, H( KWV, 1 ), LDH, 00534 $ WORK, LWORK ) 00535 * 00536 * ==== Adjust KBOT accounting for new deflations. ==== 00537 * 00538 KBOT = KBOT - LD 00539 * 00540 * ==== KS points to the shifts. ==== 00541 * 00542 KS = KBOT - LS + 1 00543 * 00544 * ==== Skip an expensive QR sweep if there is a (partly 00545 * . heuristic) reason to expect that many eigenvalues 00546 * . will deflate without it. Here, the QR sweep is 00547 * . skipped if many eigenvalues have just been deflated 00548 * . or if the remaining active block is small. 00549 * 00550 IF( ( LD.EQ.0 ) .OR. ( ( 100*LD.LE.NW*NIBBLE ) .AND. ( KBOT- 00551 $ KTOP+1.GT.MIN( NMIN, NWMAX ) ) ) ) THEN 00552 * 00553 * ==== NS = nominal number of simultaneous shifts. 00554 * . This may be lowered (slightly) if SLAQR2 00555 * . did not provide that many shifts. ==== 00556 * 00557 NS = MIN( NSMAX, NSR, MAX( 2, KBOT-KTOP ) ) 00558 NS = NS - MOD( NS, 2 ) 00559 * 00560 * ==== If there have been no deflations 00561 * . in a multiple of KEXSH iterations, 00562 * . then try exceptional shifts. 00563 * . Otherwise use shifts provided by 00564 * . SLAQR2 above or from the eigenvalues 00565 * . of a trailing principal submatrix. ==== 00566 * 00567 IF( MOD( NDFL, KEXSH ).EQ.0 ) THEN 00568 KS = KBOT - NS + 1 00569 DO 30 I = KBOT, MAX( KS+1, KTOP+2 ), -2 00570 SS = ABS( H( I, I-1 ) ) + ABS( H( I-1, I-2 ) ) 00571 AA = WILK1*SS + H( I, I ) 00572 BB = SS 00573 CC = WILK2*SS 00574 DD = AA 00575 CALL SLANV2( AA, BB, CC, DD, WR( I-1 ), WI( I-1 ), 00576 $ WR( I ), WI( I ), CS, SN ) 00577 30 CONTINUE 00578 IF( KS.EQ.KTOP ) THEN 00579 WR( KS+1 ) = H( KS+1, KS+1 ) 00580 WI( KS+1 ) = ZERO 00581 WR( KS ) = WR( KS+1 ) 00582 WI( KS ) = WI( KS+1 ) 00583 END IF 00584 ELSE 00585 * 00586 * ==== Got NS/2 or fewer shifts? Use SLAHQR 00587 * . on a trailing principal submatrix to 00588 * . get more. (Since NS.LE.NSMAX.LE.(N+6)/9, 00589 * . there is enough space below the subdiagonal 00590 * . to fit an NS-by-NS scratch array.) ==== 00591 * 00592 IF( KBOT-KS+1.LE.NS / 2 ) THEN 00593 KS = KBOT - NS + 1 00594 KT = N - NS + 1 00595 CALL SLACPY( 'A', NS, NS, H( KS, KS ), LDH, 00596 $ H( KT, 1 ), LDH ) 00597 CALL SLAHQR( .false., .false., NS, 1, NS, 00598 $ H( KT, 1 ), LDH, WR( KS ), WI( KS ), 00599 $ 1, 1, ZDUM, 1, INF ) 00600 KS = KS + INF 00601 * 00602 * ==== In case of a rare QR failure use 00603 * . eigenvalues of the trailing 2-by-2 00604 * . principal submatrix. ==== 00605 * 00606 IF( KS.GE.KBOT ) THEN 00607 AA = H( KBOT-1, KBOT-1 ) 00608 CC = H( KBOT, KBOT-1 ) 00609 BB = H( KBOT-1, KBOT ) 00610 DD = H( KBOT, KBOT ) 00611 CALL SLANV2( AA, BB, CC, DD, WR( KBOT-1 ), 00612 $ WI( KBOT-1 ), WR( KBOT ), 00613 $ WI( KBOT ), CS, SN ) 00614 KS = KBOT - 1 00615 END IF 00616 END IF 00617 * 00618 IF( KBOT-KS+1.GT.NS ) THEN 00619 * 00620 * ==== Sort the shifts (Helps a little) 00621 * . Bubble sort keeps complex conjugate 00622 * . pairs together. ==== 00623 * 00624 SORTED = .false. 00625 DO 50 K = KBOT, KS + 1, -1 00626 IF( SORTED ) 00627 $ GO TO 60 00628 SORTED = .true. 00629 DO 40 I = KS, K - 1 00630 IF( ABS( WR( I ) )+ABS( WI( I ) ).LT. 00631 $ ABS( WR( I+1 ) )+ABS( WI( I+1 ) ) ) THEN 00632 SORTED = .false. 00633 * 00634 SWAP = WR( I ) 00635 WR( I ) = WR( I+1 ) 00636 WR( I+1 ) = SWAP 00637 * 00638 SWAP = WI( I ) 00639 WI( I ) = WI( I+1 ) 00640 WI( I+1 ) = SWAP 00641 END IF 00642 40 CONTINUE 00643 50 CONTINUE 00644 60 CONTINUE 00645 END IF 00646 * 00647 * ==== Shuffle shifts into pairs of real shifts 00648 * . and pairs of complex conjugate shifts 00649 * . assuming complex conjugate shifts are 00650 * . already adjacent to one another. (Yes, 00651 * . they are.) ==== 00652 * 00653 DO 70 I = KBOT, KS + 2, -2 00654 IF( WI( I ).NE.-WI( I-1 ) ) THEN 00655 * 00656 SWAP = WR( I ) 00657 WR( I ) = WR( I-1 ) 00658 WR( I-1 ) = WR( I-2 ) 00659 WR( I-2 ) = SWAP 00660 * 00661 SWAP = WI( I ) 00662 WI( I ) = WI( I-1 ) 00663 WI( I-1 ) = WI( I-2 ) 00664 WI( I-2 ) = SWAP 00665 END IF 00666 70 CONTINUE 00667 END IF 00668 * 00669 * ==== If there are only two shifts and both are 00670 * . real, then use only one. ==== 00671 * 00672 IF( KBOT-KS+1.EQ.2 ) THEN 00673 IF( WI( KBOT ).EQ.ZERO ) THEN 00674 IF( ABS( WR( KBOT )-H( KBOT, KBOT ) ).LT. 00675 $ ABS( WR( KBOT-1 )-H( KBOT, KBOT ) ) ) THEN 00676 WR( KBOT-1 ) = WR( KBOT ) 00677 ELSE 00678 WR( KBOT ) = WR( KBOT-1 ) 00679 END IF 00680 END IF 00681 END IF 00682 * 00683 * ==== Use up to NS of the the smallest magnatiude 00684 * . shifts. If there aren't NS shifts available, 00685 * . then use them all, possibly dropping one to 00686 * . make the number of shifts even. ==== 00687 * 00688 NS = MIN( NS, KBOT-KS+1 ) 00689 NS = NS - MOD( NS, 2 ) 00690 KS = KBOT - NS + 1 00691 * 00692 * ==== Small-bulge multi-shift QR sweep: 00693 * . split workspace under the subdiagonal into 00694 * . - a KDU-by-KDU work array U in the lower 00695 * . left-hand-corner, 00696 * . - a KDU-by-at-least-KDU-but-more-is-better 00697 * . (KDU-by-NHo) horizontal work array WH along 00698 * . the bottom edge, 00699 * . - and an at-least-KDU-but-more-is-better-by-KDU 00700 * . (NVE-by-KDU) vertical work WV arrow along 00701 * . the left-hand-edge. ==== 00702 * 00703 KDU = 3*NS - 3 00704 KU = N - KDU + 1 00705 KWH = KDU + 1 00706 NHO = ( N-KDU+1-4 ) - ( KDU+1 ) + 1 00707 KWV = KDU + 4 00708 NVE = N - KDU - KWV + 1 00709 * 00710 * ==== Small-bulge multi-shift QR sweep ==== 00711 * 00712 CALL SLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NS, 00713 $ WR( KS ), WI( KS ), H, LDH, ILOZ, IHIZ, Z, 00714 $ LDZ, WORK, 3, H( KU, 1 ), LDH, NVE, 00715 $ H( KWV, 1 ), LDH, NHO, H( KU, KWH ), LDH ) 00716 END IF 00717 * 00718 * ==== Note progress (or the lack of it). ==== 00719 * 00720 IF( LD.GT.0 ) THEN 00721 NDFL = 1 00722 ELSE 00723 NDFL = NDFL + 1 00724 END IF 00725 * 00726 * ==== End of main loop ==== 00727 80 CONTINUE 00728 * 00729 * ==== Iteration limit exceeded. Set INFO to show where 00730 * . the problem occurred and exit. ==== 00731 * 00732 INFO = KBOT 00733 90 CONTINUE 00734 END IF 00735 * 00736 * ==== Return the optimal value of LWORK. ==== 00737 * 00738 WORK( 1 ) = REAL( LWKOPT ) 00739 * 00740 * ==== End of SLAQR4 ==== 00741 * 00742 END