Télécharger dhseqr.eso

Retour à la liste

Numérotation des lignes :

dhseqr
  1. C DHSEQR SOURCE BP208322 20/09/18 21:15:55 10718
  2. *> \brief \b DHSEQR
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DHSEQR + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dhseqr.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dhseqr.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dhseqr.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DHSEQR( JOB, COMPZ, N, ILO, IHI, H, LDH, WR, WI, Z,
  23. * LDZ, WORK, LWORK, INFO )
  24. *
  25. * .. Scalar Arguments ..
  26. * INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, N
  27. * CHARACTER COMPZ, JOB
  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. *> DHSEQR 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] JOB
  55. *> \verbatim
  56. *> JOB is CHARACTER*1
  57. *> = 'E': compute eigenvalues only;
  58. *> = 'S': compute eigenvalues and the Schur form T.
  59. *> \endverbatim
  60. *>
  61. *> \param[in] COMPZ
  62. *> \verbatim
  63. *> COMPZ is CHARACTER*1
  64. *> = 'N': no Schur vectors are computed;
  65. *> = 'I': Z is initialized to the unit matrix and the matrix Z
  66. *> of Schur vectors of H is returned;
  67. *> = 'V': Z must contain an orthogonal matrix Q on entry, and
  68. *> the product Q*Z is returned.
  69. *> \endverbatim
  70. *>
  71. *> \param[in] N
  72. *> \verbatim
  73. *> N is INTEGER
  74. *> The order of the matrix H. N .GE. 0.
  75. *> \endverbatim
  76. *>
  77. *> \param[in] ILO
  78. *> \verbatim
  79. *> ILO is INTEGER
  80. *> \endverbatim
  81. *>
  82. *> \param[in] IHI
  83. *> \verbatim
  84. *> IHI is INTEGER
  85. *>
  86. *> It is assumed that H is already upper triangular in rows
  87. *> and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  88. *> set by a previous call to DGEBAL, and then passed to ZGEHRD
  89. *> when the matrix output by DGEBAL is reduced to Hessenberg
  90. *> form. Otherwise ILO and IHI should be set to 1 and N
  91. *> respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N.
  92. *> If N = 0, then ILO = 1 and IHI = 0.
  93. *> \endverbatim
  94. *>
  95. *> \param[in,out] H
  96. *> \verbatim
  97. *> H is REAL*8 array, dimension (LDH,N)
  98. *> On entry, the upper Hessenberg matrix H.
  99. *> On exit, if INFO = 0 and JOB = 'S', then H contains the
  100. *> upper quasi-triangular matrix T from the Schur decomposition
  101. *> (the Schur form); 2-by-2 diagonal blocks (corresponding to
  102. *> complex conjugate pairs of eigenvalues) are returned in
  103. *> standard form, with H(i,i) = H(i+1,i+1) and
  104. *> H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and JOB = 'E', the
  105. *> contents of H are unspecified on exit. (The output value of
  106. *> H when INFO.GT.0 is given under the description of INFO
  107. *> below.)
  108. *>
  109. *> Unlike earlier versions of DHSEQR, this subroutine may
  110. *> explicitly H(i,j) = 0 for i.GT.j and j = 1, 2, ... ILO-1
  111. *> or j = IHI+1, IHI+2, ... N.
  112. *> \endverbatim
  113. *>
  114. *> \param[in] LDH
  115. *> \verbatim
  116. *> LDH is INTEGER
  117. *> The leading dimension of the array H. LDH .GE. max(1,N).
  118. *> \endverbatim
  119. *>
  120. *> \param[out] WR
  121. *> \verbatim
  122. *> WR is REAL*8 array, dimension (N)
  123. *> \endverbatim
  124. *>
  125. *> \param[out] WI
  126. *> \verbatim
  127. *> WI is REAL*8 array, dimension (N)
  128. *>
  129. *> The real and imaginary parts, respectively, of the computed
  130. *> eigenvalues. If two eigenvalues are computed as a complex
  131. *> conjugate pair, they are stored in consecutive elements of
  132. *> WR and WI, say the i-th and (i+1)th, with WI(i) .GT. 0 and
  133. *> WI(i+1) .LT. 0. If JOB = 'S', the eigenvalues are stored in
  134. *> the same order as on the diagonal of the Schur form returned
  135. *> in H, with WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2
  136. *> diagonal block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and
  137. *> WI(i+1) = -WI(i).
  138. *> \endverbatim
  139. *>
  140. *> \param[in,out] Z
  141. *> \verbatim
  142. *> Z is REAL*8 array, dimension (LDZ,N)
  143. *> If COMPZ = 'N', Z is not referenced.
  144. *> If COMPZ = 'I', on entry Z need not be set and on exit,
  145. *> if INFO = 0, Z contains the orthogonal matrix Z of the Schur
  146. *> vectors of H. If COMPZ = 'V', on entry Z must contain an
  147. *> N-by-N matrix Q, which is assumed to be equal to the unit
  148. *> matrix except for the submatrix Z(ILO:IHI,ILO:IHI). On exit,
  149. *> if INFO = 0, Z contains Q*Z.
  150. *> Normally Q is the orthogonal matrix generated by DORGHR
  151. *> after the call to DGEHRD which formed the Hessenberg matrix
  152. *> H. (The output value of Z when INFO.GT.0 is given under
  153. *> the description of INFO below.)
  154. *> \endverbatim
  155. *>
  156. *> \param[in] LDZ
  157. *> \verbatim
  158. *> LDZ is INTEGER
  159. *> The leading dimension of the array Z. if COMPZ = 'I' or
  160. *> COMPZ = 'V', then LDZ.GE.MAX(1,N). Otherwize, LDZ.GE.1.
  161. *> \endverbatim
  162. *>
  163. *> \param[out] WORK
  164. *> \verbatim
  165. *> WORK is REAL*8 array, dimension (LWORK)
  166. *> On exit, if INFO = 0, WORK(1) returns an estimate of
  167. *> the optimal value for LWORK.
  168. *> \endverbatim
  169. *>
  170. *> \param[in] LWORK
  171. *> \verbatim
  172. *> LWORK is INTEGER
  173. *> The dimension of the array WORK. LWORK .GE. max(1,N)
  174. *> is sufficient and delivers very good and sometimes
  175. *> optimal performance. However, LWORK as large as 11*N
  176. *> may be required for optimal performance. A workspace
  177. *> query is recommended to determine the optimal workspace
  178. *> size.
  179. *>
  180. *> If LWORK = -1, then DHSEQR does a workspace query.
  181. *> In this case, DHSEQR checks the input parameters and
  182. *> estimates the optimal workspace size for the given
  183. *> values of N, ILO and IHI. The estimate is returned
  184. *> in WORK(1). No error message related to LWORK is
  185. *> issued by XERBLA. Neither H nor Z are accessed.
  186. *> \endverbatim
  187. *>
  188. *> \param[out] INFO
  189. *> \verbatim
  190. *> INFO is INTEGER
  191. *> = 0: successful exit
  192. *> .LT. 0: if INFO = -i, the i-th argument had an illegal
  193. *> value
  194. *> .GT. 0: if INFO = i, DHSEQR failed to compute all of
  195. *> the eigenvalues. Elements 1:ilo-1 and i+1:n of WR
  196. *> and WI contain those eigenvalues which have been
  197. *> successfully computed. (Failures are rare.)
  198. *>
  199. *> If INFO .GT. 0 and JOB = 'E', then on exit, the
  200. *> remaining unconverged eigenvalues are the eigen-
  201. *> values of the upper Hessenberg matrix rows and
  202. *> columns ILO through INFO of the final, output
  203. *> value of H.
  204. *>
  205. *> If INFO .GT. 0 and JOB = 'S', then on exit
  206. *>
  207. *> (*) (initial value of H)*U = U*(final value of H)
  208. *>
  209. *> where U is an orthogonal matrix. The final
  210. *> value of H is upper Hessenberg and quasi-triangular
  211. *> in rows and columns INFO+1 through IHI.
  212. *>
  213. *> If INFO .GT. 0 and COMPZ = 'V', then on exit
  214. *>
  215. *> (final value of Z) = (initial value of Z)*U
  216. *>
  217. *> where U is the orthogonal matrix in (*) (regard-
  218. *> less of the value of JOB.)
  219. *>
  220. *> If INFO .GT. 0 and COMPZ = 'I', then on exit
  221. *> (final value of Z) = U
  222. *> where U is the orthogonal matrix in (*) (regard-
  223. *> less of the value of JOB.)
  224. *>
  225. *> If INFO .GT. 0 and COMPZ = 'N', then Z is not
  226. *> accessed.
  227. *> \endverbatim
  228. *
  229. * Authors:
  230. * ========
  231. *
  232. *> \author Univ. of Tennessee
  233. *> \author Univ. of California Berkeley
  234. *> \author Univ. of Colorado Denver
  235. *> \author NAG Ltd.
  236. *
  237. *> \date December 2016
  238. *
  239. *> \ingroup doubleOTHERcomputational
  240. *
  241. *> \par Contributors:
  242. * ==================
  243. *>
  244. *> Karen Braman and Ralph Byers, Department of Mathematics,
  245. *> University of Kansas, USA
  246. *
  247. *> \par Further Details:
  248. * =====================
  249. *>
  250. *> \verbatim
  251. *>
  252. *> Default values supplied by
  253. *> ILAENV(ISPEC,'DHSEQR',JOB(:1)//COMPZ(:1),N,ILO,IHI,LWORK).
  254. *> It is suggested that these defaults be adjusted in order
  255. *> to attain best performance in each particular
  256. *> computational environment.
  257. *>
  258. *> ISPEC=12: The DLAHQR vs DLAQR0 crossover point.
  259. *> Default: 75. (Must be at least 11.)
  260. *>
  261. *> ISPEC=13: Recommended deflation window size.
  262. *> This depends on ILO, IHI and NS. NS is the
  263. *> number of simultaneous shifts returned
  264. *> by ILAENV(ISPEC=15). (See ISPEC=15 below.)
  265. *> The default for (IHI-ILO+1).LE.500 is NS.
  266. *> The default for (IHI-ILO+1).GT.500 is 3*NS/2.
  267. *>
  268. *> ISPEC=14: Nibble crossover point. (See IPARMQ for
  269. *> details.) Default: 14% of deflation window
  270. *> size.
  271. *>
  272. *> ISPEC=15: Number of simultaneous shifts in a multishift
  273. *> QR iteration.
  274. *>
  275. *> If IHI-ILO+1 is ...
  276. *>
  277. *> greater than ...but less ... the
  278. *> or equal to ... than default is
  279. *>
  280. *> 1 30 NS = 2(+)
  281. *> 30 60 NS = 4(+)
  282. *> 60 150 NS = 10(+)
  283. *> 150 590 NS = **
  284. *> 590 3000 NS = 64
  285. *> 3000 6000 NS = 128
  286. *> 6000 infinity NS = 256
  287. *>
  288. *> (+) By default some or all matrices of this order
  289. *> are passed to the implicit double shift routine
  290. *> DLAHQR and this parameter is ignored. See
  291. *> ISPEC=12 above and comments in IPARMQ for
  292. *> details.
  293. *>
  294. *> (**) The asterisks (**) indicate an ad-hoc
  295. *> function of N increasing from 10 to 64.
  296. *>
  297. *> ISPEC=16: Select structured matrix multiply.
  298. *> If the number of simultaneous shifts (specified
  299. *> by ISPEC=15) is less than 14, then the default
  300. *> for ISPEC=16 is 0. Otherwise the default for
  301. *> ISPEC=16 is 2.
  302. *> \endverbatim
  303. *
  304. *> \par References:
  305. * ================
  306. *>
  307. *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  308. *> Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
  309. *> Performance, SIAM Journal of Matrix Analysis, volume 23, pages
  310. *> 929--947, 2002.
  311. *> \n
  312. *> K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  313. *> Algorithm Part II: Aggressive Early Deflation, SIAM Journal
  314. *> of Matrix Analysis, volume 23, pages 948--973, 2002.
  315. *
  316. * =====================================================================
  317. SUBROUTINE DHSEQR( JOB, COMPZ, N, ILO, IHI, H, LDH, WR, WI, Z,
  318. $ LDZ, WORK, LWORK, INFO )
  319. *
  320. * -- LAPACK computational routine (version 3.7.0) --
  321. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  322. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  323. * December 2016
  324.  
  325. IMPLICIT INTEGER(I-N)
  326. IMPLICIT REAL*8(A-H,O-Z)
  327. *
  328. * .. Scalar Arguments ..
  329. INTEGER IHI, ILO, INFO, LDH, LDZ, LWORK, N
  330. CHARACTER COMPZ, JOB
  331. * ..
  332. * .. Array Arguments ..
  333. REAL*8 H( LDH, * ), WI( * ), WORK( * ), WR( * ),
  334. $ Z( LDZ, * )
  335. * ..
  336. *
  337. * =====================================================================
  338. *
  339. * .. Parameters ..
  340. *
  341. * ==== Matrices of order NTINY or smaller must be processed by
  342. * . DLAHQR because of insufficient subdiagonal scratch space.
  343. * . (This is a hard limit.) ====
  344. INTEGER NTINY
  345. PARAMETER ( NTINY = 11 )
  346. *
  347. * ==== NL allocates some local workspace to help small matrices
  348. * . through a rare DLAHQR failure. NL .GT. NTINY = 11 is
  349. * . required and NL .LE. NMIN = ILAENV(ISPEC=12,...) is recom-
  350. * . mended. (The default value of NMIN is 75.) Using NL = 49
  351. * . allows up to six simultaneous shifts and a 16-by-16
  352. * . deflation window. ====
  353. INTEGER NL
  354. PARAMETER ( NL = 49 )
  355. REAL*8 ZERO, ONE
  356. PARAMETER ( ZERO = 0.0d0, ONE = 1.0d0 )
  357. * ..
  358. * .. Local Arrays ..
  359. REAL*8 HL( NL, NL ), WORKL( NL )
  360. * ..
  361. * .. Local Scalars ..
  362. INTEGER I, KBOT, NMIN
  363. LOGICAL INITZ, LQUERY, WANTT, WANTZ
  364. * ..
  365. * .. External Functions ..
  366. INTEGER ILAENV
  367. LOGICAL LSAME
  368. * EXTERNAL ILAENV, LSAME
  369. * ..
  370. * .. External Subroutines ..
  371. * EXTERNAL DLACPY, DLAHQR, DLAQR0, DLASET, XERBLA
  372. * ..
  373. * .. Intrinsic Functions ..
  374. * INTRINSIC DBLE, MAX, MIN
  375. * ..
  376. * .. Executable Statements ..
  377. *
  378. * ==== Decode and check the input parameters. ====
  379. *
  380. WANTT = LSAME( JOB, 'S' )
  381. INITZ = LSAME( COMPZ, 'I' )
  382. WANTZ = INITZ .OR. LSAME( COMPZ, 'V' )
  383. WORK( 1 ) = DBLE( MAX( 1, N ) )
  384. LQUERY = LWORK.EQ.-1
  385. *
  386. INFO = 0
  387. IF( .NOT.LSAME( JOB, 'E' ) .AND. .NOT.WANTT ) THEN
  388. INFO = -1
  389. ELSE IF( .NOT.LSAME( COMPZ, 'N' ) .AND. .NOT.WANTZ ) THEN
  390. INFO = -2
  391. ELSE IF( N.LT.0 ) THEN
  392. INFO = -3
  393. ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THEN
  394. INFO = -4
  395. ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THEN
  396. INFO = -5
  397. ELSE IF( LDH.LT.MAX( 1, N ) ) THEN
  398. INFO = -7
  399. ELSE IF( LDZ.LT.1 .OR. ( WANTZ .AND. LDZ.LT.MAX( 1, N ) ) ) THEN
  400. INFO = -11
  401. ELSE IF( LWORK.LT.MAX( 1, N ) .AND. .NOT.LQUERY ) THEN
  402. INFO = -13
  403. END IF
  404. *
  405. IF( INFO.NE.0 ) THEN
  406. *
  407. * ==== Quick return in case of invalid argument. ====
  408. *
  409. CALL XERBLA( 'DHSEQR', -INFO )
  410. RETURN
  411. *
  412. ELSE IF( N.EQ.0 ) THEN
  413. *
  414. * ==== Quick return in case N = 0; nothing to do. ====
  415. *
  416. RETURN
  417. *
  418. ELSE IF( LQUERY ) THEN
  419. *
  420. * ==== Quick return in case of a workspace query ====
  421. *
  422. CALL DLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, ILO,
  423. $ IHI, Z, LDZ, WORK, LWORK, INFO )
  424. * ==== Ensure reported workspace size is backward-compatible with
  425. * . previous LAPACK versions. ====
  426. WORK( 1 ) = MAX( DBLE( MAX( 1, N ) ), WORK( 1 ) )
  427. RETURN
  428. *
  429. ELSE
  430. *
  431. * ==== copy eigenvalues isolated by DGEBAL ====
  432. *
  433. DO 10 I = 1, ILO - 1
  434. WR( I ) = H( I, I )
  435. WI( I ) = ZERO
  436. 10 CONTINUE
  437. DO 20 I = IHI + 1, N
  438. WR( I ) = H( I, I )
  439. WI( I ) = ZERO
  440. 20 CONTINUE
  441. *
  442. * ==== Initialize Z, if requested ====
  443. *
  444. IF( INITZ )
  445. $ CALL DLASET( 'A', N, N, ZERO, ONE, Z, LDZ )
  446. *
  447. * ==== Quick return if possible ====
  448. *
  449. IF( ILO.EQ.IHI ) THEN
  450. WR( ILO ) = H( ILO, ILO )
  451. WI( ILO ) = ZERO
  452. RETURN
  453. END IF
  454. *
  455. * ==== DLAHQR/DLAQR0 crossover point ====
  456. *
  457. NMIN = ILAENV( 12, 'DHSEQR', JOB( : 1 ) // COMPZ( : 1 ), N,
  458. $ ILO, IHI, LWORK )
  459. NMIN = MAX( NTINY, NMIN )
  460. *
  461. * ==== DLAQR0 for big matrices; DLAHQR for small ones ====
  462. *
  463. IF( N.GT.NMIN ) THEN
  464. CALL DLAQR0( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, ILO,
  465. $ IHI, Z, LDZ, WORK, LWORK, INFO )
  466. ELSE
  467. *
  468. * ==== Small matrix ====
  469. *
  470. CALL DLAHQR( WANTT, WANTZ, N, ILO, IHI, H, LDH, WR, WI, ILO,
  471. $ IHI, Z, LDZ, INFO )
  472. *
  473. IF( INFO.GT.0 ) THEN
  474. *
  475. * ==== A rare DLAHQR failure! DLAQR0 sometimes succeeds
  476. * . when DLAHQR fails. ====
  477. *
  478. KBOT = INFO
  479. *
  480. IF( N.GE.NL ) THEN
  481. *
  482. * ==== Larger matrices have enough subdiagonal scratch
  483. * . space to call DLAQR0 directly. ====
  484. *
  485. CALL DLAQR0( WANTT, WANTZ, N, ILO, KBOT, H, LDH, WR,
  486. $ WI, ILO, IHI, Z, LDZ, WORK, LWORK, INFO )
  487. *
  488. ELSE
  489. *
  490. * ==== Tiny matrices don't have enough subdiagonal
  491. * . scratch space to benefit from DLAQR0. Hence,
  492. * . tiny matrices must be copied into a larger
  493. * . array before calling DLAQR0. ====
  494. *
  495. CALL DLACPY( 'A', N, N, H, LDH, HL, NL )
  496. HL( N+1, N ) = ZERO
  497. CALL DLASET( 'A', NL, NL-N, ZERO, ZERO, HL( 1, N+1 ),
  498. $ NL )
  499. CALL DLAQR0( WANTT, WANTZ, NL, ILO, KBOT, HL, NL, WR,
  500. $ WI, ILO, IHI, Z, LDZ, WORKL, NL, INFO )
  501. IF( WANTT .OR. INFO.NE.0 )
  502. $ CALL DLACPY( 'A', N, N, HL, NL, H, LDH )
  503. END IF
  504. END IF
  505. END IF
  506. *
  507. * ==== Clear out the trash, if necessary. ====
  508. *
  509. IF( ( WANTT .OR. INFO.NE.0 ) .AND. N.GT.2 )
  510. $ CALL DLASET( 'L', N-2, N-2, ZERO, ZERO, H( 3, 1 ), LDH )
  511. *
  512. * ==== Ensure reported workspace size is backward-compatible with
  513. * . previous LAPACK versions. ====
  514. *
  515. WORK( 1 ) = MAX( DBLE( MAX( 1, N ) ), WORK( 1 ) )
  516. END IF
  517. *
  518. * ==== End of DHSEQR ====
  519. *
  520. END
  521.  
  522.  
  523.  

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