Télécharger dlaqr0.eso

Retour à la liste

Numérotation des lignes :

  1. C DLAQR0 SOURCE BP208322 20/09/18 21:15:58 10718
  2. *> \brief \b DLAQR0 computes the eigenvalues of a Hessenberg matrix, and optionally the matrices from the Schur decomposition.
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DLAQR0 + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlaqr0.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlaqr0.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlaqr0.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
  23. * ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
  27. * LOGICAL WANTT, WANTZ
  28. * ..
  29. * .. Array Arguments ..
  30. * REAL*8 H( LDH, * ), WI( * ), WORK( * ), WR( * ),
  31. * $ Z( LDZ, * )
  32. * ..
  33. *
  34. *
  35. *> \par Purpose:
  36. * =============
  37. *>
  38. *> \verbatim
  39. *>
  40. *> DLAQR0 computes the eigenvalues of a Hessenberg matrix H
  41. *> and, optionally, the matrices T and Z from the Schur decomposition
  42. *> H = Z T Z**T, where T is an upper quasi-triangular matrix (the
  43. *> Schur form), and Z is the orthogonal matrix of Schur vectors.
  44. *>
  45. *> Optionally Z may be postmultiplied into an input orthogonal
  46. *> matrix Q so that this routine can give the Schur factorization
  47. *> of a matrix A which has been reduced to the Hessenberg form H
  48. *> by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T.
  49. *> \endverbatim
  50. *
  51. * Arguments:
  52. * ==========
  53. *
  54. *> \param[in] WANTT
  55. *> \verbatim
  56. *> WANTT is LOGICAL
  57. *> = .TRUE. : the full Schur form T is required;
  58. *> = .FALSE.: only eigenvalues are required.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] WANTZ
  62. *> \verbatim
  63. *> WANTZ is LOGICAL
  64. *> = .TRUE. : the matrix of Schur vectors Z is required;
  65. *> = .FALSE.: Schur vectors are not required.
  66. *> \endverbatim
  67. *>
  68. *> \param[in] N
  69. *> \verbatim
  70. *> N is INTEGER
  71. *> The order of the matrix H. N .GE. 0.
  72. *> \endverbatim
  73. *>
  74. *> \param[in] ILO
  75. *> \verbatim
  76. *> ILO is INTEGER
  77. *> \endverbatim
  78. *>
  79. *> \param[in] IHI
  80. *> \verbatim
  81. *> IHI is INTEGER
  82. *> It is assumed that H is already upper triangular in rows
  83. *> and columns 1:ILO-1 and IHI+1:N and, if ILO.GT.1,
  84. *> H(ILO,ILO-1) is zero. ILO and IHI are normally set by a
  85. *> previous call to DGEBAL, and then passed to DGEHRD when the
  86. *> matrix output by DGEBAL is reduced to Hessenberg form.
  87. *> Otherwise, ILO and IHI should be set to 1 and N,
  88. *> respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N.
  89. *> If N = 0, then ILO = 1 and IHI = 0.
  90. *> \endverbatim
  91. *>
  92. *> \param[in,out] H
  93. *> \verbatim
  94. *> H is REAL*8 array, dimension (LDH,N)
  95. *> On entry, the upper Hessenberg matrix H.
  96. *> On exit, if INFO = 0 and WANTT is .TRUE., then H contains
  97. *> the upper quasi-triangular matrix T from the Schur
  98. *> decomposition (the Schur form); 2-by-2 diagonal blocks
  99. *> (corresponding to complex conjugate pairs of eigenvalues)
  100. *> are returned in standard form, with H(i,i) = H(i+1,i+1)
  101. *> and H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and WANTT is
  102. *> .FALSE., then the contents of H are unspecified on exit.
  103. *> (The output value of H when INFO.GT.0 is given under the
  104. *> description of INFO below.)
  105. *>
  106. *> This subroutine may explicitly set H(i,j) = 0 for i.GT.j and
  107. *> j = 1, 2, ... ILO-1 or j = IHI+1, IHI+2, ... N.
  108. *> \endverbatim
  109. *>
  110. *> \param[in] LDH
  111. *> \verbatim
  112. *> LDH is INTEGER
  113. *> The leading dimension of the array H. LDH .GE. max(1,N).
  114. *> \endverbatim
  115. *>
  116. *> \param[out] WR
  117. *> \verbatim
  118. *> WR is REAL*8 array, dimension (IHI)
  119. *> \endverbatim
  120. *>
  121. *> \param[out] WI
  122. *> \verbatim
  123. *> WI is REAL*8 array, dimension (IHI)
  124. *> The real and imaginary parts, respectively, of the computed
  125. *> eigenvalues of H(ILO:IHI,ILO:IHI) are stored in WR(ILO:IHI)
  126. *> and WI(ILO:IHI). If two eigenvalues are computed as a
  127. *> complex conjugate pair, they are stored in consecutive
  128. *> elements of WR and WI, say the i-th and (i+1)th, with
  129. *> WI(i) .GT. 0 and WI(i+1) .LT. 0. If WANTT is .TRUE., then
  130. *> the eigenvalues are stored in the same order as on the
  131. *> diagonal of the Schur form returned in H, with
  132. *> WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2 diagonal
  133. *> block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and
  134. *> WI(i+1) = -WI(i).
  135. *> \endverbatim
  136. *>
  137. *> \param[in] ILOZ
  138. *> \verbatim
  139. *> ILOZ is INTEGER
  140. *> \endverbatim
  141. *>
  142. *> \param[in] IHIZ
  143. *> \verbatim
  144. *> IHIZ is INTEGER
  145. *> Specify the rows of Z to which transformations must be
  146. *> applied if WANTZ is .TRUE..
  147. *> 1 .LE. ILOZ .LE. ILO; IHI .LE. IHIZ .LE. N.
  148. *> \endverbatim
  149. *>
  150. *> \param[in,out] Z
  151. *> \verbatim
  152. *> Z is REAL*8 array, dimension (LDZ,IHI)
  153. *> If WANTZ is .FALSE., then Z is not referenced.
  154. *> If WANTZ is .TRUE., then Z(ILO:IHI,ILOZ:IHIZ) is
  155. *> replaced by Z(ILO:IHI,ILOZ:IHIZ)*U where U is the
  156. *> orthogonal Schur factor of H(ILO:IHI,ILO:IHI).
  157. *> (The output value of Z when INFO.GT.0 is given under
  158. *> the description of INFO below.)
  159. *> \endverbatim
  160. *>
  161. *> \param[in] LDZ
  162. *> \verbatim
  163. *> LDZ is INTEGER
  164. *> The leading dimension of the array Z. if WANTZ is .TRUE.
  165. *> then LDZ.GE.MAX(1,IHIZ). Otherwize, LDZ.GE.1.
  166. *> \endverbatim
  167. *>
  168. *> \param[out] WORK
  169. *> \verbatim
  170. *> WORK is REAL*8 array, dimension LWORK
  171. *> On exit, if LWORK = -1, WORK(1) returns an estimate of
  172. *> the optimal value for LWORK.
  173. *> \endverbatim
  174. *>
  175. *> \param[in] LWORK
  176. *> \verbatim
  177. *> LWORK is INTEGER
  178. *> The dimension of the array WORK. LWORK .GE. max(1,N)
  179. *> is sufficient, but LWORK typically as large as 6*N may
  180. *> be required for optimal performance. A workspace query
  181. *> to determine the optimal workspace size is recommended.
  182. *>
  183. *> If LWORK = -1, then DLAQR0 does a workspace query.
  184. *> In this case, DLAQR0 checks the input parameters and
  185. *> estimates the optimal workspace size for the given
  186. *> values of N, ILO and IHI. The estimate is returned
  187. *> in WORK(1). No error message related to LWORK is
  188. *> issued by XERBLA. Neither H nor Z are accessed.
  189. *> \endverbatim
  190. *>
  191. *> \param[out] INFO
  192. *> \verbatim
  193. *> INFO is INTEGER
  194. *> = 0: successful exit
  195. *> .GT. 0: if INFO = i, DLAQR0 failed to compute all of
  196. *> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR
  197. *> and WI contain those eigenvalues which have been
  198. *> successfully computed. (Failures are rare.)
  199. *>
  200. *> If INFO .GT. 0 and WANT is .FALSE., then on exit,
  201. *> the remaining unconverged eigenvalues are the eigen-
  202. *> values of the upper Hessenberg matrix rows and
  203. *> columns ILO through INFO of the final, output
  204. *> value of H.
  205. *>
  206. *> If INFO .GT. 0 and WANTT is .TRUE., then on exit
  207. *>
  208. *> (*) (initial value of H)*U = U*(final value of H)
  209. *>
  210. *> where U is an orthogonal matrix. The final
  211. *> value of H is upper Hessenberg and quasi-triangular
  212. *> in rows and columns INFO+1 through IHI.
  213. *>
  214. *> If INFO .GT. 0 and WANTZ is .TRUE., then on exit
  215. *>
  216. *> (final value of Z(ILO:IHI,ILOZ:IHIZ)
  217. *> = (initial value of Z(ILO:IHI,ILOZ:IHIZ)*U
  218. *>
  219. *> where U is the orthogonal matrix in (*) (regard-
  220. *> less of the value of WANTT.)
  221. *>
  222. *> If INFO .GT. 0 and WANTZ is .FALSE., then Z is not
  223. *> accessed.
  224. *> \endverbatim
  225. *
  226. *> \par Contributors:
  227. * ==================
  228. *>
  229. *> Karen Braman and Ralph Byers, Department of Mathematics,
  230. *> University of Kansas, USA
  231. *
  232. *> \par References:
  233. * ================
  234. *>
  235. *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  236. *> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
  237. *> Performance, SIAM Journal of Matrix Analysis, volume 23, pages
  238. *> 929--947, 2002.
  239. *> \n
  240. *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  241. *> Algorithm Part II: Aggressive Early Deflation, SIAM Journal
  242. *> of Matrix Analysis, volume 23, pages 948--973, 2002.
  243. *
  244. * Authors:
  245. * ========
  246. *
  247. *> \author Univ. of Tennessee
  248. *> \author Univ. of California Berkeley
  249. *> \author Univ. of Colorado Denver
  250. *> \author NAG Ltd.
  251. *
  252. *> \date December 2016
  253. *
  254. *> \ingroup doubleOTHERauxiliary
  255. *
  256. * =====================================================================
  257. SUBROUTINE DLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
  258. $ ILOZ, IHIZ, Z, LDZ, WORK, LWORK, INFO )
  259. *
  260. * -- LAPACK auxiliary routine (version 3.7.0) --
  261. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  262. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  263. * December 2016
  264.  
  265. IMPLICIT INTEGER(I-N)
  266. IMPLICIT REAL*8(A-H,O-Z)
  267. *
  268. * .. Scalar Arguments ..
  269. INTEGER IHI, IHIZ, ILO, ILOZ, INFO, LDH, LDZ, LWORK, N
  270. LOGICAL WANTT, WANTZ
  271. * ..
  272. * .. Array Arguments ..
  273. REAL*8 H( LDH, * ), WI( * ), WORK( * ), WR( * ),
  274. $ Z( LDZ, * )
  275. * ..
  276. *
  277. * ================================================================
  278. *
  279. * .. Parameters ..
  280. *
  281. * ==== Matrices of order NTINY or smaller must be processed by
  282. * . DLAHQR because of insufficient subdiagonal scratch space.
  283. * . (This is a hard limit.) ====
  284. INTEGER NTINY
  285. PARAMETER ( NTINY = 11 )
  286. *
  287. * ==== Exceptional deflation windows: try to cure rare
  288. * . slow convergence by varying the size of the
  289. * . deflation window after KEXNW iterations. ====
  290. INTEGER KEXNW
  291. PARAMETER ( KEXNW = 5 )
  292. *
  293. * ==== Exceptional shifts: try to cure rare slow convergence
  294. * . with ad-hoc exceptional shifts every KEXSH iterations.
  295. * . ====
  296. INTEGER KEXSH
  297. PARAMETER ( KEXSH = 6 )
  298. *
  299. * ==== The constants WILK1 and WILK2 are used to form the
  300. * . exceptional shifts. ====
  301. REAL*8 WILK1, WILK2
  302. PARAMETER ( WILK1 = 0.75d0, WILK2 = -0.4375d0 )
  303. REAL*8 ZERO, ONE
  304. PARAMETER ( ZERO = 0.0d0, ONE = 1.0d0 )
  305. * ..
  306. * .. Local Scalars ..
  307. REAL*8 AA, BB, CC, CS, DD, SN, SS, SWAP
  308. INTEGER I, INF, IT, ITMAX, K, KACC22, KBOT, KDU, KS,
  309. $ KT, KTOP, KU, KV, KWH, KWTOP, KWV, LD, LS,
  310. $ LWKOPT, NDEC, NDFL, NH, NHO, NIBBLE, NMIN, NS,
  311. $ NSMAX, NSR, NVE, NW, NWMAX, NWR, NWUPBD
  312. LOGICAL SORTED
  313. CHARACTER JBCMPZ*2
  314. * ..
  315. * .. External Functions ..
  316. INTEGER ILAENV
  317. * EXTERNAL ILAENV
  318. * ..
  319. * .. Local Arrays ..
  320. REAL*8 ZDUM( 1, 1 )
  321. * ..
  322. * .. External Subroutines ..
  323. * EXTERNAL DLACPY, DLAHQR, DLANV2, DLAQR3, DLAQR4, DLAQR5
  324. * ..
  325. * .. Intrinsic Functions ..
  326. * INTRINSIC ABS, DBLE, INT, MAX, MIN, MOD
  327. * ..
  328. * .. Executable Statements ..
  329. INFO = 0
  330. *
  331. * ==== Quick return for N = 0: nothing to do. ====
  332. *
  333. IF( N.EQ.0 ) THEN
  334. WORK( 1 ) = ONE
  335. RETURN
  336. END IF
  337. *
  338. IF( N.LE.NTINY ) THEN
  339. *
  340. * ==== Tiny matrices must use DLAHQR. ====
  341. *
  342. LWKOPT = 1
  343. IF( LWORK.NE.-1 )
  344. $ CALL DLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI,
  345. $ ILOZ, IHIZ, Z, LDZ, INFO )
  346. ELSE
  347. *
  348. * ==== Use small bulge multi-shift QR with aggressive early
  349. * . deflation on larger-than-tiny matrices. ====
  350. *
  351. * ==== Hope for the best. ====
  352. *
  353. INFO = 0
  354. *
  355. * ==== Set up job flags for ILAENV. ====
  356. *
  357. IF( WANTT ) THEN
  358. JBCMPZ( 1: 1 ) = 'S'
  359. ELSE
  360. JBCMPZ( 1: 1 ) = 'E'
  361. END IF
  362. IF( WANTZ ) THEN
  363. JBCMPZ( 2: 2 ) = 'V'
  364. ELSE
  365. JBCMPZ( 2: 2 ) = 'N'
  366. END IF
  367. *
  368. * ==== NWR = recommended deflation window size. At this
  369. * . point, N .GT. NTINY = 11, so there is enough
  370. * . subdiagonal workspace for NWR.GE.2 as required.
  371. * . (In fact, there is enough subdiagonal space for
  372. * . NWR.GE.3.) ====
  373. *
  374. NWR = ILAENV( 13, 'DLAQR0', JBCMPZ, N, ILO, IHI, LWORK )
  375. NWR = MAX( 2, NWR )
  376. NWR = MIN( IHI-ILO+1, ( N-1 ) / 3, NWR )
  377. *
  378. * ==== NSR = recommended number of simultaneous shifts.
  379. * . At this point N .GT. NTINY = 11, so there is at
  380. * . enough subdiagonal workspace for NSR to be even
  381. * . and greater than or equal to two as required. ====
  382. *
  383. NSR = ILAENV( 15, 'DLAQR0', JBCMPZ, N, ILO, IHI, LWORK )
  384. NSR = MIN( NSR, ( N+6 ) / 9, IHI-ILO )
  385. NSR = MAX( 2, NSR-MOD( NSR, 2 ) )
  386. *
  387. * ==== Estimate optimal workspace ====
  388. *
  389. * ==== Workspace query call to DLAQR3 ====
  390. *
  391. CALL DLAQR3( WANTT, WANTZ, N, ILO, IHI, NWR+1, H, LDH, ILOZ,
  392. $ IHIZ, Z, LDZ, LS, LD, WR, WI, H, LDH, N, H, LDH,
  393. $ N, H, LDH, WORK, -1 )
  394. *
  395. * ==== Optimal workspace = MAX(DLAQR5, DLAQR3) ====
  396. *
  397. LWKOPT = MAX( 3*NSR / 2, INT( WORK( 1 ) ) )
  398. *
  399. * ==== Quick return in case of workspace query. ====
  400. *
  401. IF( LWORK.EQ.-1 ) THEN
  402. WORK( 1 ) = DBLE( LWKOPT )
  403. RETURN
  404. END IF
  405. *
  406. * ==== DLAHQR/DLAQR0 crossover point ====
  407. *
  408. NMIN = ILAENV( 12, 'DLAQR0', JBCMPZ, N, ILO, IHI, LWORK )
  409. NMIN = MAX( NTINY, NMIN )
  410. *
  411. * ==== Nibble crossover point ====
  412. *
  413. NIBBLE = ILAENV( 14, 'DLAQR0', JBCMPZ, N, ILO, IHI, LWORK )
  414. NIBBLE = MAX( 0, NIBBLE )
  415. *
  416. * ==== Accumulate reflections during ttswp? Use block
  417. * . 2-by-2 structure during matrix-matrix multiply? ====
  418. *
  419. KACC22 = ILAENV( 16, 'DLAQR0', JBCMPZ, N, ILO, IHI, LWORK )
  420. KACC22 = MAX( 0, KACC22 )
  421. KACC22 = MIN( 2, KACC22 )
  422. *
  423. * ==== NWMAX = the largest possible deflation window for
  424. * . which there is sufficient workspace. ====
  425. *
  426. NWMAX = MIN( ( N-1 ) / 3, LWORK / 2 )
  427. NW = NWMAX
  428. *
  429. * ==== NSMAX = the Largest number of simultaneous shifts
  430. * . for which there is sufficient workspace. ====
  431. *
  432. NSMAX = MIN( ( N+6 ) / 9, 2*LWORK / 3 )
  433. NSMAX = NSMAX - MOD( NSMAX, 2 )
  434. *
  435. * ==== NDFL: an iteration count restarted at deflation. ====
  436. *
  437. NDFL = 1
  438. *
  439. * ==== ITMAX = iteration limit ====
  440. *
  441. ITMAX = MAX( 30, 2*KEXSH )*MAX( 10, ( IHI-ILO+1 ) )
  442. *
  443. * ==== Last row and column in the active block ====
  444. *
  445. KBOT = IHI
  446. *
  447. * ==== Main Loop ====
  448. *
  449. DO 80 IT = 1, ITMAX
  450. *
  451. * ==== Done when KBOT falls below ILO ====
  452. *
  453. IF( KBOT.LT.ILO )
  454. $ GO TO 90
  455. *
  456. * ==== Locate active block ====
  457. *
  458. DO 10 K = KBOT, ILO + 1, -1
  459. IF( H( K, K-1 ).EQ.ZERO )
  460. $ GO TO 20
  461. 10 CONTINUE
  462. K = ILO
  463. 20 CONTINUE
  464. KTOP = K
  465. *
  466. * ==== Select deflation window size:
  467. * . Typical Case:
  468. * . If possible and advisable, nibble the entire
  469. * . active block. If not, use size MIN(NWR,NWMAX)
  470. * . or MIN(NWR+1,NWMAX) depending upon which has
  471. * . the smaller corresponding subdiagonal entry
  472. * . (a heuristic).
  473. * .
  474. * . Exceptional Case:
  475. * . If there have been no deflations in KEXNW or
  476. * . more iterations, then vary the deflation window
  477. * . size. At first, because, larger windows are,
  478. * . in general, more powerful than smaller ones,
  479. * . rapidly increase the window to the maximum possible.
  480. * . Then, gradually reduce the window size. ====
  481. *
  482. NH = KBOT - KTOP + 1
  483. NWUPBD = MIN( NH, NWMAX )
  484. IF( NDFL.LT.KEXNW ) THEN
  485. NW = MIN( NWUPBD, NWR )
  486. ELSE
  487. NW = MIN( NWUPBD, 2*NW )
  488. END IF
  489. IF( NW.LT.NWMAX ) THEN
  490. IF( NW.GE.NH-1 ) THEN
  491. NW = NH
  492. ELSE
  493. KWTOP = KBOT - NW + 1
  494. IF( ABS( H( KWTOP, KWTOP-1 ) ).GT.
  495. $ ABS( H( KWTOP-1, KWTOP-2 ) ) )NW = NW + 1
  496. END IF
  497. END IF
  498. IF( NDFL.LT.KEXNW ) THEN
  499. NDEC = -1
  500. ELSE IF( NDEC.GE.0 .OR. NW.GE.NWUPBD ) THEN
  501. NDEC = NDEC + 1
  502. IF( NW-NDEC.LT.2 )
  503. $ NDEC = 0
  504. NW = NW - NDEC
  505. END IF
  506. *
  507. * ==== Aggressive early deflation:
  508. * . split workspace under the subdiagonal into
  509. * . - an nw-by-nw work array V in the lower
  510. * . left-hand-corner,
  511. * . - an NW-by-at-least-NW-but-more-is-better
  512. * . (NW-by-NHO) horizontal work array along
  513. * . the bottom edge,
  514. * . - an at-least-NW-but-more-is-better (NHV-by-NW)
  515. * . vertical work array along the left-hand-edge.
  516. * . ====
  517. *
  518. KV = N - NW + 1
  519. KT = NW + 1
  520. NHO = ( N-NW-1 ) - KT + 1
  521. KWV = NW + 2
  522. NVE = ( N-NW ) - KWV + 1
  523. *
  524. * ==== Aggressive early deflation ====
  525. *
  526. CALL DLAQR3( WANTT, WANTZ, N, KTOP, KBOT, NW, H, LDH, ILOZ,
  527. $ IHIZ, Z, LDZ, LS, LD, WR, WI, H( KV, 1 ), LDH,
  528. $ NHO, H( KV, KT ), LDH, NVE, H( KWV, 1 ), LDH,
  529. $ WORK, LWORK )
  530. *
  531. * ==== Adjust KBOT accounting for new deflations. ====
  532. *
  533. KBOT = KBOT - LD
  534. *
  535. * ==== KS points to the shifts. ====
  536. *
  537. KS = KBOT - LS + 1
  538. *
  539. * ==== Skip an expensive QR sweep if there is a (partly
  540. * . heuristic) reason to expect that many eigenvalues
  541. * . will deflate without it. Here, the QR sweep is
  542. * . skipped if many eigenvalues have just been deflated
  543. * . or if the remaining active block is small.
  544. *
  545. IF( ( LD.EQ.0 ) .OR. ( ( 100*LD.LE.NW*NIBBLE ) .AND. ( KBOT-
  546. $ KTOP+1.GT.MIN( NMIN, NWMAX ) ) ) ) THEN
  547. *
  548. * ==== NS = nominal number of simultaneous shifts.
  549. * . This may be lowered (slightly) if DLAQR3
  550. * . did not provide that many shifts. ====
  551. *
  552. NS = MIN( NSMAX, NSR, MAX( 2, KBOT-KTOP ) )
  553. NS = NS - MOD( NS, 2 )
  554. *
  555. * ==== If there have been no deflations
  556. * . in a multiple of KEXSH iterations,
  557. * . then try exceptional shifts.
  558. * . Otherwise use shifts provided by
  559. * . DLAQR3 above or from the eigenvalues
  560. * . of a trailing principal submatrix. ====
  561. *
  562. IF( MOD( NDFL, KEXSH ).EQ.0 ) THEN
  563. KS = KBOT - NS + 1
  564. DO 30 I = KBOT, MAX( KS+1, KTOP+2 ), -2
  565. SS = ABS( H( I, I-1 ) ) + ABS( H( I-1, I-2 ) )
  566. AA = WILK1*SS + H( I, I )
  567. BB = SS
  568. CC = WILK2*SS
  569. DD = AA
  570. CALL DLANV2( AA, BB, CC, DD, WR( I-1 ), WI( I-1 ),
  571. $ WR( I ), WI( I ), CS, SN )
  572. 30 CONTINUE
  573. IF( KS.EQ.KTOP ) THEN
  574. WR( KS+1 ) = H( KS+1, KS+1 )
  575. WI( KS+1 ) = ZERO
  576. WR( KS ) = WR( KS+1 )
  577. WI( KS ) = WI( KS+1 )
  578. END IF
  579. ELSE
  580. *
  581. * ==== Got NS/2 or fewer shifts? Use DLAQR4 or
  582. * . DLAHQR on a trailing principal submatrix to
  583. * . get more. (Since NS.LE.NSMAX.LE.(N+6)/9,
  584. * . there is enough space below the subdiagonal
  585. * . to fit an NS-by-NS scratch array.) ====
  586. *
  587. IF( KBOT-KS+1.LE.NS / 2 ) THEN
  588. KS = KBOT - NS + 1
  589. KT = N - NS + 1
  590. CALL DLACPY( 'A', NS, NS, H( KS, KS ), LDH,
  591. $ H( KT, 1 ), LDH )
  592. IF( NS.GT.NMIN ) THEN
  593. CALL DLAQR4( .false., .false., NS, 1, NS,
  594. $ H( KT, 1 ), LDH, WR( KS ),
  595. $ WI( KS ), 1, 1, ZDUM, 1, WORK,
  596. $ LWORK, INF )
  597. ELSE
  598. CALL DLAHQR( .false., .false., NS, 1, NS,
  599. $ H( KT, 1 ), LDH, WR( KS ),
  600. $ WI( KS ), 1, 1, ZDUM, 1, INF )
  601. END IF
  602. KS = KS + INF
  603. *
  604. * ==== In case of a rare QR failure use
  605. * . eigenvalues of the trailing 2-by-2
  606. * . principal submatrix. ====
  607. *
  608. IF( KS.GE.KBOT ) THEN
  609. AA = H( KBOT-1, KBOT-1 )
  610. CC = H( KBOT, KBOT-1 )
  611. BB = H( KBOT-1, KBOT )
  612. DD = H( KBOT, KBOT )
  613. CALL DLANV2( AA, BB, CC, DD, WR( KBOT-1 ),
  614. $ WI( KBOT-1 ), WR( KBOT ),
  615. $ WI( KBOT ), CS, SN )
  616. KS = KBOT - 1
  617. END IF
  618. END IF
  619. *
  620. IF( KBOT-KS+1.GT.NS ) THEN
  621. *
  622. * ==== Sort the shifts (Helps a little)
  623. * . Bubble sort keeps complex conjugate
  624. * . pairs together. ====
  625. *
  626. SORTED = .false.
  627. DO 50 K = KBOT, KS + 1, -1
  628. IF( SORTED )
  629. $ GO TO 60
  630. SORTED = .true.
  631. DO 40 I = KS, K - 1
  632. IF( ABS( WR( I ) )+ABS( WI( I ) ).LT.
  633. $ ABS( WR( I+1 ) )+ABS( WI( I+1 ) ) ) THEN
  634. SORTED = .false.
  635. *
  636. SWAP = WR( I )
  637. WR( I ) = WR( I+1 )
  638. WR( I+1 ) = SWAP
  639. *
  640. SWAP = WI( I )
  641. WI( I ) = WI( I+1 )
  642. WI( I+1 ) = SWAP
  643. END IF
  644. 40 CONTINUE
  645. 50 CONTINUE
  646. 60 CONTINUE
  647. END IF
  648. *
  649. * ==== Shuffle shifts into pairs of real shifts
  650. * . and pairs of complex conjugate shifts
  651. * . assuming complex conjugate shifts are
  652. * . already adjacent to one another. (Yes,
  653. * . they are.) ====
  654. *
  655. DO 70 I = KBOT, KS + 2, -2
  656. IF( WI( I ).NE.-WI( I-1 ) ) THEN
  657. *
  658. SWAP = WR( I )
  659. WR( I ) = WR( I-1 )
  660. WR( I-1 ) = WR( I-2 )
  661. WR( I-2 ) = SWAP
  662. *
  663. SWAP = WI( I )
  664. WI( I ) = WI( I-1 )
  665. WI( I-1 ) = WI( I-2 )
  666. WI( I-2 ) = SWAP
  667. END IF
  668. 70 CONTINUE
  669. END IF
  670. *
  671. * ==== If there are only two shifts and both are
  672. * . real, then use only one. ====
  673. *
  674. IF( KBOT-KS+1.EQ.2 ) THEN
  675. IF( WI( KBOT ).EQ.ZERO ) THEN
  676. IF( ABS( WR( KBOT )-H( KBOT, KBOT ) ).LT.
  677. $ ABS( WR( KBOT-1 )-H( KBOT, KBOT ) ) ) THEN
  678. WR( KBOT-1 ) = WR( KBOT )
  679. ELSE
  680. WR( KBOT ) = WR( KBOT-1 )
  681. END IF
  682. END IF
  683. END IF
  684. *
  685. * ==== Use up to NS of the the smallest magnatiude
  686. * . shifts. If there aren't NS shifts available,
  687. * . then use them all, possibly dropping one to
  688. * . make the number of shifts even. ====
  689. *
  690. NS = MIN( NS, KBOT-KS+1 )
  691. NS = NS - MOD( NS, 2 )
  692. KS = KBOT - NS + 1
  693. *
  694. * ==== Small-bulge multi-shift QR sweep:
  695. * . split workspace under the subdiagonal into
  696. * . - a KDU-by-KDU work array U in the lower
  697. * . left-hand-corner,
  698. * . - a KDU-by-at-least-KDU-but-more-is-better
  699. * . (KDU-by-NHo) horizontal work array WH along
  700. * . the bottom edge,
  701. * . - and an at-least-KDU-but-more-is-better-by-KDU
  702. * . (NVE-by-KDU) vertical work WV arrow along
  703. * . the left-hand-edge. ====
  704. *
  705. KDU = 3*NS - 3
  706. KU = N - KDU + 1
  707. KWH = KDU + 1
  708. NHO = ( N-KDU+1-4 ) - ( KDU+1 ) + 1
  709. KWV = KDU + 4
  710. NVE = N - KDU - KWV + 1
  711. *
  712. * ==== Small-bulge multi-shift QR sweep ====
  713. *
  714. CALL DLAQR5( WANTT, WANTZ, KACC22, N, KTOP, KBOT, NS,
  715. $ WR( KS ), WI( KS ), H, LDH, ILOZ, IHIZ, Z,
  716. $ LDZ, WORK, 3, H( KU, 1 ), LDH, NVE,
  717. $ H( KWV, 1 ), LDH, NHO, H( KU, KWH ), LDH )
  718. END IF
  719. *
  720. * ==== Note progress (or the lack of it). ====
  721. *
  722. IF( LD.GT.0 ) THEN
  723. NDFL = 1
  724. ELSE
  725. NDFL = NDFL + 1
  726. END IF
  727. *
  728. * ==== End of main loop ====
  729. 80 CONTINUE
  730. *
  731. * ==== Iteration limit exceeded. Set INFO to show where
  732. * . the problem occurred and exit. ====
  733. *
  734. INFO = KBOT
  735. 90 CONTINUE
  736. END IF
  737. *
  738. * ==== Return the optimal value of LWORK. ====
  739. *
  740. WORK( 1 ) = DBLE( LWKOPT )
  741. *
  742. * ==== End of DLAQR0 ====
  743. *
  744. END
  745.  
  746.  
  747.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales