Télécharger dneigh.eso

Retour à la liste

Numérotation des lignes :

dneigh
  1. C DNEIGH SOURCE FANDEUR 22/05/02 21:15:11 11359
  2. c-----------------------------------------------------------------------
  3. c\BeginDoc
  4. c
  5. c\Name: dneigh
  6. c
  7. c\Description:
  8. c Compute the eigenvalues of the current upper Hessenberg matrix
  9. c and the corresponding Ritz estimates given the current residual norm.
  10. c
  11. c\Usage:
  12. c call dneigh(RNORM, N, H, LDH, RITZR, RITZI, BOUNDS,Q ,LDQ,WORKL,IERR)
  13. c
  14. c\Arguments
  15. c RNORM Double precision scalar. (INPUT)
  16. c Residual norm corresponding to the current upper Hessenberg
  17. c matrix H.
  18. c
  19. c N Integer. (INPUT)
  20. c Size of the matrix H.
  21. c
  22. c H REAL*8 N by N array. (INPUT)
  23. c H contains the current upper Hessenberg matrix.
  24. c
  25. c LDH Integer. (INPUT)
  26. c Leading dimension of H exactly as declared in the calling
  27. c program.
  28. c
  29. c RITZR, Double precision arrays of length N. (OUTPUT)
  30. c RITZI On output, RITZR(1:N) (resp. RITZI(1:N)) contains the real
  31. c (respectively imaginary) parts of the eigenvalues of H.
  32. c
  33. c BOUNDS Double precision array of length N. (OUTPUT)
  34. c c On output, BOUNDS contains the Ritz estimates associated with
  35. c the eigenvalues RITZR and RITZI. This is equal to RNORM
  36. c times the last components of the eigenvectors corresponding
  37. c to the eigenvalues in RITZR and RITZI.
  38. c
  39. c Q REAL*8 N by N array. (WORKSPACE)
  40. c Workspace needed to store the eigenvectors of H.
  41. c
  42. c LDQ Integer. (INPUT)
  43. c Leading dimension of Q exactly as declared in the calling
  44. c program.
  45. c
  46. c WORKL Double precision work array of length N**2 + 3*N. (WORKSPACE)
  47. c Private (replicated) array on each PE or array allocated on
  48. c the front end. This is needed to keep the full Schur form
  49. c of H and also in the calculation of the eigenvectors of H.
  50. c
  51. c IERR Integer. (OUTPUT)
  52. c Error exit flag from dlaqrb or dtrevc.
  53. c
  54. c\EndDoc
  55. c
  56. c-----------------------------------------------------------------------
  57. c
  58. c\BeginLib
  59. c
  60. c\Local variables:
  61. c xxxxxx real
  62. c
  63. c\Routines called:
  64. c dlaqrb ARPACK routine to compute the real Schur form of an
  65. c upper Hessenberg matrix and last row of the Schur vectors.
  66. c arscnd ARPACK utility routine for timing.
  67. c dmout ARPACK utility routine that prints matrices
  68. c dvout ARPACK utility routine that prints vectors.
  69. c dlacpy LAPACK matrix copy routine.
  70. c dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
  71. c dtrevc LAPACK routine to compute the eigenvectors of a matrix
  72. c in upper quasi-triangular form
  73. c dgemv Level 2 BLAS routine for matrix vector multiplication.
  74. c dcopy Level 1 BLAS that copies one vector to another .
  75. c dnrm2 Level 1 BLAS that computes the norm of a vector.
  76. c dscal Level 1 BLAS that scales a vector.
  77. c
  78. c
  79. c\Author
  80. c Danny Sorensen Phuong Vu
  81. c Richard Lehoucq CRPC / Rice University
  82. c Dept. of Computational & Houston, Texas
  83. c Applied Mathematics
  84. c Rice University
  85. c Houston, Texas
  86. c
  87. c\Revision history:
  88. c xx/xx/92: Version ' 2.1'
  89. c
  90. c\SCCS Information: @(#)
  91. c FILE: neigh.F SID: 2.3 DATE OF SID: 4/20/96 RELEASE: 2
  92. c
  93. c\Remarks
  94. c None
  95. c
  96. c\EndLib
  97. c
  98. c-----------------------------------------------------------------------
  99. c
  100. subroutine dneigh (rnorm, n, h, ldh, ritzr, ritzi, bounds,
  101. & q, ldq, workl, ierr)
  102. c
  103. c %----------------------------------------------------%
  104. c | Include files for debugging and timing information |
  105. c -INC TARTRAK
  106. c %----------------------------------------------------%
  107. c
  108. c
  109. c %------------------%
  110. c | Scalar Arguments |
  111. c %------------------%
  112. c
  113. integer ierr, n, ldh, ldq
  114. REAL*8
  115. & rnorm
  116. c
  117. c %-----------------%
  118. c | Array Arguments |
  119. c %-----------------%
  120. c
  121. REAL*8
  122. & bounds(n), h(ldh,n), q(ldq,n), ritzi(n), ritzr(n),
  123. & workl(n*(n+3))
  124. c
  125. c %------------%
  126. c | Parameters |
  127. c %------------%
  128. c
  129. REAL*8
  130. & one, zero
  131. parameter (one = 1.0D+0, zero = 0.0D+0)
  132. c
  133. c %------------------------%
  134. c | Local Scalars & Arrays |
  135. c %------------------------%
  136. c
  137. logical select(1)
  138. integer i, iconj, msglvl
  139. REAL*8
  140. & temp, vl(1)
  141. parameter (msglvl=0)
  142. c
  143. c %----------------------%
  144. c | External Subroutines |
  145. c %----------------------%
  146. c
  147. external dcopy, dlacpy, dlaqrb, dtrevc,
  148. & dvout, arscnd
  149. c
  150. c %--------------------%
  151. c | External Functions |
  152. c %--------------------%
  153. c
  154. REAL*8
  155. external dlapy2, dnrm2
  156. c
  157. c %---------------------%
  158. **c | Intrinsic Functions |
  159. **c %---------------------%
  160. **c
  161. ** intrinsic abs
  162. **c
  163. **c %-----------------------%
  164. **c | Executable Statements |
  165. c %-----------------------%
  166. c
  167. c
  168. c %-------------------------------%
  169. c | Initialize timing statistics |
  170. c | & message level for debugging |
  171. c %-------------------------------%
  172. c
  173. * call arscnd (t0)
  174.  
  175.  
  176. c msglvl = mneigh
  177. c
  178. c if (msglvl .gt. 2) then
  179. c call dmout (logfil, n, n, h, ldh, ndigit,
  180. c & '_neigh: Entering upper Hessenberg matrix H ')
  181. c end if
  182. c
  183. c %-----------------------------------------------------------%
  184. c | 1. Compute the eigenvalues, the last components of the |
  185. c | corresponding Schur vectors and the full Schur form T |
  186. c | of the current upper Hessenberg matrix H. |
  187. c | dlaqrb returns the full Schur form of H in WORKL(1:N**2) |
  188. c | and the last components of the Schur vectors in BOUNDS. |
  189. c %-----------------------------------------------------------%
  190. c
  191. call dlacpy ('All', n, n, h, ldh, workl, n)
  192.  
  193. do 5 j = 1, n-1
  194. bounds(j) = zero
  195. 5 continue
  196. bounds(n) = one
  197.  
  198. call dlahqr(.true., .true., n, 1, n, workl, n, ritzr, ritzi, 1,
  199. & 1, bounds, 1, ierr)
  200.  
  201. c call dlaqrb (.true., n, 1, n, workl, n, ritzr, ritzi, bounds,
  202. c & ierr)
  203.  
  204.  
  205. if (ierr .ne. 0) go to 9000
  206. c
  207. c if (msglvl .gt. 1) then
  208. c call dvout ( n, bounds, ndigit,
  209. c & '_neigh: last row of the Schur matrix for H')
  210. c end if
  211. c
  212. c %-----------------------------------------------------------%
  213. c | 2. Compute the eigenvectors of the full Schur form T and |
  214. c | apply the last components of the Schur vectors to get |
  215. c | the last components of the corresponding eigenvectors. |
  216. c | Remember that if the i-th and (i+1)-st eigenvalues are |
  217. c | complex conjugate pairs, then the real & imaginary part |
  218. c | of the eigenvector components are split across adjacent |
  219. c | columns of Q. |
  220. c %-----------------------------------------------------------%
  221. c
  222. call dtrevc ('R', 'A', select, n, workl, n, vl, n, q, ldq,
  223. & n, n, workl(n*n+1), ierr)
  224. c
  225. if (ierr .ne. 0) go to 9000
  226. c
  227. c %------------------------------------------------%
  228. c | Scale the returning eigenvectors so that their |
  229. c | euclidean norms are all one. LAPACK subroutine |
  230. c | dtrevc returns each eigenvector normalized so |
  231. c | that the element of largest magnitude has |
  232. c | magnitude 1; here the magnitude of a complex |
  233. c | number (x,y) is taken to be |x| + |y|. |
  234. c %------------------------------------------------%
  235. c
  236. iconj = 0
  237. do 10 i=1, n
  238. if ( abs( ritzi(i) ) .le. zero ) then
  239. c
  240. c %----------------------%
  241. c | Real eigenvalue case |
  242. c %----------------------%
  243. c
  244. temp = dnrm2( n, q(1,i), 1 )
  245. call dscal ( n, one / temp, q(1,i), 1 )
  246. else
  247. c
  248. c %-------------------------------------------%
  249. c | Complex conjugate pair case. Note that |
  250. c | since the real and imaginary part of |
  251. c | the eigenvector are stored in consecutive |
  252. c | columns, we further normalize by the |
  253. c | square root of two. |
  254. c %-------------------------------------------%
  255. c
  256. if (iconj .eq. 0) then
  257. temp = dlapy2( dnrm2( n, q(1,i), 1 ),
  258. & dnrm2( n, q(1,i+1), 1 ) )
  259. call dscal ( n, one / temp, q(1,i), 1 )
  260. call dscal ( n, one / temp, q(1,i+1), 1 )
  261. iconj = 1
  262. else
  263. iconj = 0
  264. end if
  265. end if
  266. 10 continue
  267. c
  268. call dgemv ('T', n, n, one, q, ldq, bounds, 1, zero, workl, 1)
  269. c
  270. c if (msglvl .gt. 1) then
  271. c call dvout ( n, workl, ndigit,
  272. c & '_neigh: Last row of the eigenvector matrix for H')
  273. c end if
  274. c
  275. c %----------------------------%
  276. c | Compute the Ritz estimates |
  277. c %----------------------------%
  278. c
  279. iconj = 0
  280. do 20 i = 1, n
  281. if ( abs( ritzi(i) ) .le. zero ) then
  282. c
  283. c %----------------------%
  284. c | Real eigenvalue case |
  285. c %----------------------%
  286. c
  287. bounds(i) = rnorm * abs( workl(i) )
  288. else
  289. c
  290. c %-------------------------------------------%
  291. c | Complex conjugate pair case. Note that |
  292. c | since the real and imaginary part of |
  293. c | the eigenvector are stored in consecutive |
  294. c | columns, we need to take the magnitude |
  295. c | of the last components of the two vectors |
  296. c %-------------------------------------------%
  297. c
  298. if (iconj .eq. 0) then
  299. bounds(i) = rnorm * dlapy2( workl(i), workl(i+1) )
  300. bounds(i+1) = bounds(i)
  301. iconj = 1
  302. else
  303. iconj = 0
  304. end if
  305. end if
  306. 20 continue
  307. c
  308. c if (msglvl .gt. 2) then
  309. c call dvout ( n, ritzr, ndigit,
  310. c & '_neigh: Real part of the eigenvalues of H')
  311. c call dvout ( n, ritzi, ndigit,
  312. c & '_neigh: Imaginary part of the eigenvalues of H')
  313. c call dvout ( n, bounds, ndigit,
  314. c & '_neigh: Ritz estimates for the eigenvalues of H')
  315. c end if
  316. c
  317. * call arscnd (t1)
  318. * tneigh = tneigh + (t1 - t0)
  319. c
  320. 9000 continue
  321. return
  322. c
  323. c %---------------%
  324. c | End of dneigh |
  325. c %---------------%
  326. c
  327. end
  328.  
  329.  
  330.  
  331.  

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