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