Télécharger dneupd.eso

Retour à la liste

Numérotation des lignes :

  1. C DNEUPD SOURCE BP208322 15/10/13 21:15:47 8670
  2. c\BeginDoc
  3. c
  4. c\Name: dneupd
  5. c
  6. c\Description:
  7. c
  8. c This subroutine returns the converged approximations to eigenvalues
  9. c of A*z = lambda*B*z and (optionally):
  10. c
  11. c (1) The corresponding approximate eigenvectors;
  12. c
  13. c (2) An orthonormal basis for the associated approximate
  14. c invariant subspace;
  15. c
  16. c (3) Both.
  17. c
  18. c There is negligible additional cost to obtain eigenvectors. An orthonormal
  19. c basis is always computed. There is an additional storage cost of n*nev
  20. c if both are requested (in this case a separate array Z must be supplied).
  21. c
  22. c The approximate eigenvalues and eigenvectors of A*z = lambda*B*z
  23. c are derived from approximate eigenvalues and eigenvectors of
  24. c of the linear operator OP prescribed by the MODE selection in the
  25. c call to DNAUPD . DNAUPD must be called before this routine is called.
  26. c These approximate eigenvalues and vectors are commonly called Ritz
  27. c values and Ritz vectors respectively. They are referred to as such
  28. c in the comments that follow. The computed orthonormal basis for the
  29. c invariant subspace corresponding to these Ritz values is referred to as a
  30. c Schur basis.
  31. c
  32. c See documentation in the header of the subroutine DNAUPD for
  33. c definition of OP as well as other terms and the relation of computed
  34. c Ritz values and Ritz vectors of OP with respect to the given problem
  35. c A*z = lambda*B*z. For a brief description, see definitions of
  36. c IPARAM(7), MODE and WHICH in the documentation of DNAUPD .
  37. c
  38. c\Usage:
  39. c call dneupd
  40. c ( RVEC, HOWMNY, SELECT, DR, DI, Z, LDZ, SIGMAR, SIGMAI, WORKEV, BMAT,
  41. c N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, WORKD, WORKL,
  42. c LWORKL, INFO )
  43. c
  44. c\Arguments:
  45. c RVEC LOGICAL (INPUT)
  46. c Specifies whether a basis for the invariant subspace corresponding
  47. c to the converged Ritz value approximations for the eigenproblem
  48. c A*z = lambda*B*z is computed.
  49. c
  50. c RVEC = .FALSE. Compute Ritz values only.
  51. c
  52. c RVEC = .TRUE. Compute the Ritz vectors or Schur vectors.
  53. c See Remarks below.
  54. c
  55. c HOWMNY Character*1 (INPUT)
  56. c Specifies the form of the basis for the invariant subspace
  57. c corresponding to the converged Ritz values that is to be computed.
  58. c
  59. c = 'A': Compute NEV Ritz vectors;
  60. c = 'P': Compute NEV Schur vectors;
  61. c = 'S': compute some of the Ritz vectors, specified
  62. c by the logical array SELECT.
  63. c
  64. c SELECT Logical array of dimension NCV. (INPUT)
  65. c If HOWMNY = 'S', SELECT specifies the Ritz vectors to be
  66. c computed. To select the Ritz vector corresponding to a
  67. c Ritz value (DR(j), DI(j)), SELECT(j) must be set to .TRUE..
  68. c If HOWMNY = 'A' or 'P', SELECT is used as internal workspace.
  69. c
  70. c DR REAL*8 array of dimension NEV+1. (OUTPUT)
  71. c If IPARAM(7) = 1,2 or 3 and SIGMAI=0.0 then on exit: DR contains
  72. c the real part of the Ritz approximations to the eigenvalues of
  73. c A*z = lambda*B*z.
  74. c If IPARAM(7) = 3, 4 and SIGMAI is not equal to zero, then on exit:
  75. c DR contains the real part of the Ritz values of OP computed by
  76. c DNAUPD . A further computation must be performed by the user
  77. c to transform the Ritz values computed for OP by DNAUPD to those
  78. c of the original system A*z = lambda*B*z. See remark 3 below.
  79. c
  80. c DI REAL*8 array of dimension NEV+1. (OUTPUT)
  81. c On exit, DI contains the imaginary part of the Ritz value
  82. c approximations to the eigenvalues of A*z = lambda*B*z associated
  83. c with DR.
  84. c
  85. c NOTE: When Ritz values are complex, they will come in complex
  86. c conjugate pairs. If eigenvectors are requested, the
  87. c corresponding Ritz vectors will also come in conjugate
  88. c pairs and the real and imaginary parts of these are
  89. c represented in two consecutive columns of the array Z
  90. c (see below).
  91. c
  92. c Z REAL*8 N by NEV+1 array if RVEC = .TRUE. and HOWMNY = 'A'. (OUTPUT)
  93. c On exit, if RVEC = .TRUE. and HOWMNY = 'A', then the columns of
  94. c Z represent approximate eigenvectors (Ritz vectors) corresponding
  95. c to the NCONV=IPARAM(5) Ritz values for eigensystem
  96. c A*z = lambda*B*z.
  97. c
  98. c The complex Ritz vector associated with the Ritz value
  99. c with positive imaginary part is stored in two consecutive
  100. c columns. The first column holds the real part of the Ritz
  101. c vector and the second column holds the imaginary part. The
  102. c Ritz vector associated with the Ritz value with negative
  103. c imaginary part is simply the complex conjugate of the Ritz vector
  104. c associated with the positive imaginary part.
  105. c
  106. c If RVEC = .FALSE. or HOWMNY = 'P', then Z is not referenced.
  107. c
  108. c NOTE: If if RVEC = .TRUE. and a Schur basis is not required,
  109. c the array Z may be set equal to first NEV+1 columns of the Arnoldi
  110. c basis array V computed by DNAUPD . In this case the Arnoldi basis
  111. c will be destroyed and overwritten with the eigenvector basis.
  112. c
  113. c LDZ Integer. (INPUT)
  114. c The leading dimension of the array Z. If Ritz vectors are
  115. c desired, then LDZ >= max( 1, N ). In any case, LDZ >= 1.
  116. c
  117. c SIGMAR Double precision (INPUT)
  118. c If IPARAM(7) = 3 or 4, represents the real part of the shift.
  119. c Not referenced if IPARAM(7) = 1 or 2.
  120. c
  121. c SIGMAI Double precision (INPUT)
  122. c If IPARAM(7) = 3 or 4, represents the imaginary part of the shift.
  123. c Not referenced if IPARAM(7) = 1 or 2. See remark 3 below.
  124. c
  125. c WORKEV Double precision work array of dimension 3*NCV. (WORKSPACE)
  126. c
  127. c **** The remaining arguments MUST be the same as for the ****
  128. c **** call to DNAUPD that was just completed. ****
  129. c
  130. c NOTE: The remaining arguments
  131. c
  132. c BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR,
  133. c WORKD, WORKL, LWORKL, INFO
  134. c
  135. c must be passed directly to DNEUPD following the last call
  136. c to DNAUPD . These arguments MUST NOT BE MODIFIED between
  137. c the the last call to DNAUPD and the call to DNEUPD .
  138. c
  139. c Three of these parameters (V, WORKL, INFO) are also output parameters:
  140. c
  141. c V REAL*8 N by NCV array. (INPUT/OUTPUT)
  142. c
  143. c Upon INPUT: the NCV columns of V contain the Arnoldi basis
  144. c vectors for OP as constructed by DNAUPD .
  145. c
  146. c Upon OUTPUT: If RVEC = .TRUE. the first NCONV=IPARAM(5) columns
  147. c contain approximate Schur vectors that span the
  148. c desired invariant subspace. See Remark 2 below.
  149. c
  150. c NOTE: If the array Z has been set equal to first NEV+1 columns
  151. c of the array V and RVEC=.TRUE. and HOWMNY= 'A', then the
  152. c Arnoldi basis held by V has been overwritten by the desired
  153. c Ritz vectors. If a separate array Z has been passed then
  154. c the first NCONV=IPARAM(5) columns of V will contain approximate
  155. c Schur vectors that span the desired invariant subspace.
  156. c
  157. c WORKL Double precision work array of length LWORKL. (OUTPUT/WORKSPACE)
  158. c WORKL(1:ncv*ncv+3*ncv) contains information obtained in
  159. c dnaupd . They are not changed by dneupd .
  160. c WORKL(ncv*ncv+3*ncv+1:3*ncv*ncv+6*ncv) holds the
  161. c real and imaginary part of the untransformed Ritz values,
  162. c the upper quasi-triangular matrix for H, and the
  163. c associated matrix representation of the invariant subspace for H.
  164. c
  165. c Note: IPNTR(9:13) contains the pointer into WORKL for addresses
  166. c of the above information computed by dneupd .
  167. c -------------------------------------------------------------
  168. c IPNTR(9): pointer to the real part of the NCV RITZ values of the
  169. c original system.
  170. c IPNTR(10): pointer to the imaginary part of the NCV RITZ values of
  171. c the original system.
  172. c IPNTR(11): pointer to the NCV corresponding error bounds.
  173. c IPNTR(12): pointer to the NCV by NCV upper quasi-triangular
  174. c Schur matrix for H.
  175. c IPNTR(13): pointer to the NCV by NCV matrix of eigenvectors
  176. c of the upper Hessenberg matrix H. Only referenced by
  177. c dneupd if RVEC = .TRUE. See Remark 2 below.
  178. c -------------------------------------------------------------
  179. c
  180. c INFO Integer. (OUTPUT)
  181. c Error flag on output.
  182. c
  183. c = 0: Normal exit.
  184. c
  185. c = 1: The Schur form computed by LAPACK routine dlahqr
  186. c could not be reordered by LAPACK routine dtrsen .
  187. c Re-enter subroutine dneupd with IPARAM(5)=NCV and
  188. c increase the size of the arrays DR and DI to have
  189. c dimension at least dimension NCV and allocate at least NCV
  190. c columns for Z. NOTE: Not necessary if Z and V share
  191. c the same space. Please notify the authors if this error
  192. c occurs.
  193. c
  194. c = -1: N must be positive.
  195. c = -2: NEV must be positive.
  196. c = -3: NCV-NEV >= 2 and less than or equal to N.
  197. c = -5: WHICH must be one of 'LM', 'SM', 'LR', 'SR', 'LI', 'SI'
  198. c = -6: BMAT must be one of 'I' or 'G'.
  199. c = -7: Length of private work WORKL array is not sufficient.
  200. c = -8: Error return from calculation of a real Schur form.
  201. c Informational error from LAPACK routine dlahqr .
  202. c = -9: Error return from calculation of eigenvectors.
  203. c Informational error from LAPACK routine dtrevc .
  204. c = -10: IPARAM(7) must be 1,2,3,4.
  205. c = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatible.
  206. c = -12: HOWMNY = 'S' not yet implemented
  207. c = -13: HOWMNY must be one of 'A' or 'P' if RVEC = .true.
  208. c = -14: DNAUPD did not find any eigenvalues to sufficient
  209. c accuracy.
  210. c = -15: DNEUPD got a different count of the number of converged
  211. c Ritz values than DNAUPD got. This indicates the user
  212. c probably made an error in passing data from DNAUPD to
  213. c DNEUPD or that the data was modified before entering
  214. c DNEUPD
  215. c
  216. c\BeginLib
  217. c
  218. c\References:
  219. c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
  220. c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
  221. c pp 357-385.
  222. c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
  223. c Restarted Arnoldi Iteration", Rice University Technical Report
  224. c TR95-13, Department of Computational and Applied Mathematics.
  225. c 3. B.N. Parlett & Y. Saad, "Complex Shift and Invert Strategies for
  226. c Real Matrices", Linear Algebra and its Applications, vol 88/89,
  227. c pp 575-595, (1987).
  228. c
  229. c\Routines called:
  230. c ivout ARPACK utility routine that prints integers.
  231. c dmout ARPACK utility routine that prints matrices
  232. c dvout ARPACK utility routine that prints vectors.
  233. c dgeqr2 LAPACK routine that computes the QR factorization of
  234. c a matrix.
  235. c dlacpy LAPACK matrix copy routine.
  236. c dlahqr LAPACK routine to compute the real Schur form of an
  237. c upper Hessenberg matrix.
  238. c dlamch LAPACK routine that determines machine constants.
  239. c dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
  240. c dlaset LAPACK matrix initialization routine.
  241. c dorm2r LAPACK routine that applies an orthogonal matrix in
  242. c factored form.
  243. c dtrevc LAPACK routine to compute the eigenvectors of a matrix
  244. c in upper quasi-triangular form.
  245. c dtrsen LAPACK routine that re-orders the Schur form.
  246. c dtrmm Level 3 BLAS matrix times an upper triangular matrix.
  247. c dger Level 2 BLAS rank one update to a matrix.
  248. c dcopy Level 1 BLAS that copies one vector to another .
  249. c ddot Level 1 BLAS that computes the scalar product of two vectors.
  250. c dnrm2 Level 1 BLAS that computes the norm of a vector.
  251. c dscal Level 1 BLAS that scales a vector.
  252. c
  253. c\Remarks
  254. c
  255. c 1. Currently only HOWMNY = 'A' and 'P' are implemented.
  256. c
  257. c Let trans(X) denote the transpose of X.
  258. c
  259. c 2. Schur vectors are an orthogonal representation for the basis of
  260. c Ritz vectors. Thus, their numerical properties are often superior.
  261. c If RVEC = .TRUE. then the relationship
  262. c A * V(:,1:IPARAM(5)) = V(:,1:IPARAM(5)) * T, and
  263. c trans(V(:,1:IPARAM(5))) * V(:,1:IPARAM(5)) = I are approximately
  264. c satisfied. Here T is the leading submatrix of order IPARAM(5) of the
  265. c real upper quasi-triangular matrix stored workl(ipntr(12)). That is,
  266. c T is block upper triangular with 1-by-1 and 2-by-2 diagonal blocks;
  267. c each 2-by-2 diagonal block has its diagonal elements equal and its
  268. c off-diagonal elements of opposite sign. Corresponding to each 2-by-2
  269. c diagonal block is a complex conjugate pair of Ritz values. The real
  270. c Ritz values are stored on the diagonal of T.
  271. c
  272. c 3. If IPARAM(7) = 3 or 4 and SIGMAI is not equal zero, then the user must
  273. c form the IPARAM(5) Rayleigh quotients in order to transform the Ritz
  274. c values computed by DNAUPD for OP to those of A*z = lambda*B*z.
  275. c Set RVEC = .true. and HOWMNY = 'A', and
  276. c compute
  277. c trans(Z(:,I)) * A * Z(:,I) if DI(I) = 0.
  278. c If DI(I) is not equal to zero and DI(I+1) = - D(I),
  279. c then the desired real and imaginary parts of the Ritz value are
  280. c trans(Z(:,I)) * A * Z(:,I) + trans(Z(:,I+1)) * A * Z(:,I+1),
  281. c trans(Z(:,I)) * A * Z(:,I+1) - trans(Z(:,I+1)) * A * Z(:,I),
  282. c respectively.
  283. c Another possibility is to set RVEC = .true. and HOWMNY = 'P' and
  284. c compute trans(V(:,1:IPARAM(5))) * A * V(:,1:IPARAM(5)) and then an upper
  285. c quasi-triangular matrix of order IPARAM(5) is computed. See remark
  286. c 2 above.
  287. c
  288. c\Authors
  289. c Danny Sorensen Phuong Vu
  290. c Richard Lehoucq CRPC / Rice University
  291. c Chao Yang Houston, Texas
  292. c Dept. of Computational &
  293. c Applied Mathematics
  294. c Rice University
  295. c Houston, Texas
  296. c
  297. c\SCCS Information: @(#)
  298. c FILE: neupd.F SID: 2.7 DATE OF SID: 09/20/00 RELEASE: 2
  299. c
  300. c\EndLib
  301. c
  302. c-----------------------------------------------------------------------
  303. subroutine dneupd (rvec , howmny, select, dr , di,
  304. & z , ldz , sigmar, sigmai, workev,
  305. & bmat , n , which , nev , tol,
  306. & resid, ncv , v , ldv , iparam,
  307. & ipntr, workd , workl , lworkl, info)
  308. c
  309. c %----------------------------------------------------%
  310. c | Include files for debugging and timing information |
  311. -INC TARTRAK
  312. c %----------------------------------------------------%
  313. c
  314. c
  315. c %------------------%
  316. c | Scalar Arguments |
  317. c %------------------%
  318. c
  319. character bmat, howmny, which*2
  320. logical rvec
  321. integer info, ldz, ldv, lworkl, n, ncv, nev
  322. REAL*8
  323. & sigmar, sigmai, tol
  324. c
  325. c %-----------------%
  326. c | Array Arguments |
  327. c %-----------------%
  328. c
  329. integer iparam(11), ipntr(14)
  330. logical select(ncv)
  331. REAL*8
  332. & dr(nev+1) , di(nev+1), resid(n) ,
  333. & v(ldv,ncv) , z(ldz,*) , workd(3*n),
  334. & workl(lworkl), workev(3*ncv)
  335. c
  336. c %------------%
  337. c | Parameters |
  338. c %------------%
  339. c
  340. REAL*8
  341. & one, zero
  342. parameter (one = 1.0D+0 , zero = 0.0D+0 )
  343. c
  344. c %---------------%
  345. c | Local Scalars |
  346. c %---------------%
  347. c
  348. character type*6
  349. integer bounds, ierr , ih , ihbds ,
  350. & iheigr, iheigi, iconj , nconv ,
  351. & invsub, iuptri, iwev , iwork(1),
  352. & j , k , ldh , ldq ,
  353. & mode , msglvl, outncv, ritzr ,
  354. & ritzi , wri , wrr , irr ,
  355. & iri , ibd , ishift, numcnv ,
  356. & np , jj , nconv2
  357. logical reord
  358. REAL*8
  359. & conds , rnorm, sep , temp,
  360. & vl(1,1), temp1, eps23
  361. c
  362. c %----------------------%
  363. c | External Subroutines |
  364. c %----------------------%
  365. c
  366. external dcopy , dger , dgeqr2 , dlacpy ,
  367. c
  368. c %--------------------%
  369. c | External Functions |
  370. c %--------------------%
  371. c
  372. REAL*8
  373. external dlapy2 , dnrm2 , dlamch , ddot
  374. c
  375. c %---------------------%
  376. **c | Intrinsic Functions |
  377. **c %---------------------%
  378. **c
  379. ** intrinsic abs, min, sqrt
  380. **c
  381. **c %-----------------------%
  382. **c | Executable Statements |
  383. c %-----------------------%
  384. c
  385. c %------------------------%
  386. c | Set default parameters |
  387. c %------------------------%
  388. c
  389. msglvl = mneupd
  390. mode = iparam(7)
  391. nconv = iparam(5)
  392. info = 0
  393. c
  394. c %---------------------------------%
  395. c | Get machine dependent constant. |
  396. c %---------------------------------%
  397. c
  398. eps23 = dlamch ('Epsilon-Machine')
  399. eps23 = eps23**(2.0D+0 / 3.0D+0 )
  400. c
  401. c %--------------%
  402. c | Quick return |
  403. c %--------------%
  404. c
  405. ierr = 0
  406. c
  407. if (nconv .le. 0) then
  408. ierr = -14
  409. else if (n .le. 0) then
  410. ierr = -1
  411. else if (nev .le. 0) then
  412. ierr = -2
  413. else if (ncv .le. nev+1 .or. ncv .gt. n) then
  414. ierr = -3
  415. else if (which .ne. 'LM' .and.
  416. & which .ne. 'SM' .and.
  417. & which .ne. 'LR' .and.
  418. & which .ne. 'SR' .and.
  419. & which .ne. 'LI' .and.
  420. & which .ne. 'SI') then
  421. ierr = -5
  422. else if (bmat .ne. 'I' .and. bmat .ne. 'G') then
  423. ierr = -6
  424. else if (lworkl .lt. 3*ncv**2 + 6*ncv) then
  425. ierr = -7
  426. else if ( (howmny .ne. 'A' .and.
  427. & howmny .ne. 'P' .and.
  428. & howmny .ne. 'S') .and. rvec ) then
  429. ierr = -13
  430. else if (howmny .eq. 'S' ) then
  431. ierr = -12
  432. end if
  433. c
  434. if (mode .eq. 1 .or. mode .eq. 2) then
  435. type = 'REGULR'
  436. else if (mode .eq. 3 .and. sigmai .eq. zero) then
  437. type = 'SHIFTI'
  438. else if (mode .eq. 3 ) then
  439. type = 'REALPT'
  440. else if (mode .eq. 4 ) then
  441. type = 'IMAGPT'
  442. else
  443. ierr = -10
  444. end if
  445. if (mode .eq. 1 .and. bmat .eq. 'G') ierr = -11
  446. c
  447. c %------------%
  448. c | Error Exit |
  449. c %------------%
  450. c
  451. if (ierr .ne. 0) then
  452. info = ierr
  453. go to 9000
  454. end if
  455. c
  456. c %--------------------------------------------------------%
  457. c | Pointer into WORKL for address of H, RITZ, BOUNDS, Q |
  458. c | etc... and the remaining workspace. |
  459. c | Also update pointer to be used on output. |
  460. c | Memory is laid out as follows: |
  461. c | workl(1:ncv*ncv) := generated Hessenberg matrix |
  462. c | workl(ncv*ncv+1:ncv*ncv+2*ncv) := real and imaginary |
  463. c | parts of ritz values |
  464. c | workl(ncv*ncv+2*ncv+1:ncv*ncv+3*ncv) := error bounds |
  465. c %--------------------------------------------------------%
  466. c
  467. c %-----------------------------------------------------------%
  468. c | The following is used and set by DNEUPD . |
  469. c | workl(ncv*ncv+3*ncv+1:ncv*ncv+4*ncv) := The untransformed |
  470. c | real part of the Ritz values. |
  471. c | workl(ncv*ncv+4*ncv+1:ncv*ncv+5*ncv) := The untransformed |
  472. c | imaginary part of the Ritz values. |
  473. c | workl(ncv*ncv+5*ncv+1:ncv*ncv+6*ncv) := The untransformed |
  474. c | error bounds of the Ritz values |
  475. c | workl(ncv*ncv+6*ncv+1:2*ncv*ncv+6*ncv) := Holds the upper |
  476. c | quasi-triangular matrix for H |
  477. c | workl(2*ncv*ncv+6*ncv+1: 3*ncv*ncv+6*ncv) := Holds the |
  478. c | associated matrix representation of the invariant |
  479. c | subspace for H. |
  480. c | GRAND total of NCV * ( 3 * NCV + 6 ) locations. |
  481. c %-----------------------------------------------------------%
  482. c
  483. ih = ipntr(5)
  484. ritzr = ipntr(6)
  485. ritzi = ipntr(7)
  486. bounds = ipntr(8)
  487. ldh = ncv
  488. ldq = ncv
  489. iheigr = bounds + ldh
  490. iheigi = iheigr + ldh
  491. ihbds = iheigi + ldh
  492. iuptri = ihbds + ldh
  493. invsub = iuptri + ldh*ncv
  494. ipntr(9) = iheigr
  495. ipntr(10) = iheigi
  496. ipntr(11) = ihbds
  497. ipntr(12) = iuptri
  498. ipntr(13) = invsub
  499. wrr = 1
  500. wri = ncv + 1
  501. iwev = wri + ncv
  502. c
  503. c %-----------------------------------------%
  504. c | irr points to the REAL part of the Ritz |
  505. c | values computed by _neigh before |
  506. c | exiting _naup2. |
  507. c | iri points to the IMAGINARY part of the |
  508. c | Ritz values computed by _neigh |
  509. c | before exiting _naup2. |
  510. c | ibd points to the Ritz estimates |
  511. c | computed by _neigh before exiting |
  512. c | _naup2. |
  513. c %-----------------------------------------%
  514. c
  515. irr = ipntr(14)+ncv*ncv
  516. iri = irr+ncv
  517. ibd = iri+ncv
  518. c
  519. c %------------------------------------%
  520. c | RNORM is B-norm of the RESID(1:N). |
  521. c %------------------------------------%
  522. c
  523. rnorm = workl(ih+2)
  524. workl(ih+2) = zero
  525. c
  526. if (msglvl .gt. 2) then
  527. call dvout (logfil, ncv, workl(irr), ndigit,
  528. & '_neupd: Real part of Ritz values passed in from _NAUPD.')
  529. call dvout (logfil, ncv, workl(iri), ndigit,
  530. & '_neupd: Imag part of Ritz values passed in from _NAUPD.')
  531. call dvout (logfil, ncv, workl(ibd), ndigit,
  532. & '_neupd: Ritz estimates passed in from _NAUPD.')
  533. end if
  534. c
  535. if (rvec) then
  536. c
  537. reord = .false.
  538. c
  539. c %---------------------------------------------------%
  540. c | Use the temporary bounds array to store indices |
  541. c | These will be used to mark the select array later |
  542. c %---------------------------------------------------%
  543. c
  544. do 10 j = 1,ncv
  545. workl(bounds+j-1) = j
  546. select(j) = .false.
  547. 10 continue
  548. c
  549. c %-------------------------------------%
  550. c | Select the wanted Ritz values. |
  551. c | Sort the Ritz values so that the |
  552. c | wanted ones appear at the tailing |
  553. c | NEV positions of workl(irr) and |
  554. c | workl(iri). Move the corresponding |
  555. c | error estimates in workl(bound) |
  556. c | accordingly. |
  557. c %-------------------------------------%
  558. c
  559. np = ncv - nev
  560. ishift = 0
  561. call dngets (ishift , which , nev ,
  562. & np , workl(irr), workl(iri),
  563. & workl(bounds), workl , workl(np+1))
  564. c
  565. if (msglvl .gt. 2) then
  566. call dvout (logfil, ncv, workl(irr), ndigit,
  567. & '_neupd: Real part of Ritz values after calling _NGETS.')
  568. call dvout (logfil, ncv, workl(iri), ndigit,
  569. & '_neupd: Imag part of Ritz values after calling _NGETS.')
  570. call dvout (logfil, ncv, workl(bounds), ndigit,
  571. & '_neupd: Ritz value indices after calling _NGETS.')
  572. end if
  573. c
  574. c %-----------------------------------------------------%
  575. c | Record indices of the converged wanted Ritz values |
  576. c | Mark the select array for possible reordering |
  577. c %-----------------------------------------------------%
  578. c
  579. numcnv = 0
  580. do 11 j = 1,ncv
  581. temp1 = max(eps23,
  582. & dlapy2 ( workl(irr+ncv-j), workl(iri+ncv-j) ))
  583. jj = int(workl(bounds + ncv - j))
  584. if (numcnv .lt. nconv .and.
  585. & workl(ibd+jj-1) .le. tol*temp1) then
  586. select(jj) = .true.
  587. numcnv = numcnv + 1
  588. if (jj .gt. nconv) reord = .true.
  589. endif
  590. 11 continue
  591. c
  592. c %-----------------------------------------------------------%
  593. c | Check the count (numcnv) of converged Ritz values with |
  594. c | the number (nconv) reported by dnaupd. If these two |
  595. c | are different then there has probably been an error |
  596. c | caused by incorrect passing of the dnaupd data. |
  597. c %-----------------------------------------------------------%
  598. c
  599. if (msglvl .gt. 2) then
  600. call ivout(logfil, 1, numcnv, ndigit,
  601. & '_neupd: Number of specified eigenvalues')
  602. call ivout(logfil, 1, nconv, ndigit,
  603. & '_neupd: Number of "converged" eigenvalues')
  604. end if
  605. c
  606. if (numcnv .ne. nconv) then
  607. info = -15
  608. go to 9000
  609. end if
  610. c
  611. c %-----------------------------------------------------------%
  612. c | Call LAPACK routine dlahqr to compute the real Schur form |
  613. c | of the upper Hessenberg matrix returned by DNAUPD . |
  614. c | Make a copy of the upper Hessenberg matrix. |
  615. c | Initialize the Schur vector matrix Q to the identity. |
  616. c %-----------------------------------------------------------%
  617. c
  618. call dcopy (ldh*ncv, workl(ih), 1, workl(iuptri), 1)
  619. call dlaset ('All', ncv, ncv,
  620. & zero , one, workl(invsub),
  621. & ldq)
  622. call dlahqr (.true., .true. , ncv,
  623. & 1 , ncv , workl(iuptri),
  624. & ldh , workl(iheigr), workl(iheigi),
  625. & 1 , ncv , workl(invsub),
  626. & ldq , ierr)
  627. call dcopy (ncv , workl(invsub+ncv-1), ldq,
  628. & workl(ihbds), 1)
  629. c
  630. if (ierr .ne. 0) then
  631. info = -8
  632. go to 9000
  633. end if
  634. c
  635. if (msglvl .gt. 1) then
  636. call dvout (logfil, ncv, workl(iheigr), ndigit,
  637. & '_neupd: Real part of the eigenvalues of H')
  638. call dvout (logfil, ncv, workl(iheigi), ndigit,
  639. & '_neupd: Imaginary part of the Eigenvalues of H')
  640. call dvout (logfil, ncv, workl(ihbds), ndigit,
  641. & '_neupd: Last row of the Schur vector matrix')
  642. if (msglvl .gt. 3) then
  643. call dmout (logfil , ncv, ncv ,
  644. & workl(iuptri), ldh, ndigit,
  645. & '_neupd: The upper quasi-triangular matrix ')
  646. end if
  647. end if
  648. c
  649. if (reord) then
  650. c
  651. c %-----------------------------------------------------%
  652. c | Reorder the computed upper quasi-triangular matrix. |
  653. c %-----------------------------------------------------%
  654. c
  655. call dtrsen ('None' , 'V' ,
  656. & select , ncv ,
  657. & workl(iuptri), ldh ,
  658. & workl(invsub), ldq ,
  659. & workl(iheigr), workl(iheigi),
  660. & nconv2 , conds ,
  661. & sep , workl(ihbds) ,
  662. & ncv , iwork ,
  663. & 1 , ierr)
  664. c
  665. if (nconv2 .lt. nconv) then
  666. nconv = nconv2
  667. end if
  668.  
  669. if (ierr .eq. 1) then
  670. info = 1
  671. go to 9000
  672. end if
  673. c
  674.  
  675. if (msglvl .gt. 2) then
  676. call dvout (logfil, ncv, workl(iheigr), ndigit,
  677. & '_neupd: Real part of the eigenvalues of H--reordered')
  678. call dvout (logfil, ncv, workl(iheigi), ndigit,
  679. & '_neupd: Imag part of the eigenvalues of H--reordered')
  680. if (msglvl .gt. 3) then
  681. call dmout (logfil , ncv, ncv ,
  682. & workl(iuptri), ldq, ndigit,
  683. & '_neupd: Quasi-triangular matrix after re-ordering')
  684. end if
  685. end if
  686. c
  687. end if
  688. c
  689. c %---------------------------------------%
  690. c | Copy the last row of the Schur vector |
  691. c | into workl(ihbds). This will be used |
  692. c | to compute the Ritz estimates of |
  693. c | converged Ritz values. |
  694. c %---------------------------------------%
  695. c
  696. call dcopy (ncv, workl(invsub+ncv-1), ldq, workl(ihbds), 1)
  697. c
  698. c %----------------------------------------------------%
  699. c | Place the computed eigenvalues of H into DR and DI |
  700. c | if a spectral transformation was not used. |
  701. c %----------------------------------------------------%
  702. c
  703. if (type .eq. 'REGULR') then
  704. call dcopy (nconv, workl(iheigr), 1, dr, 1)
  705. call dcopy (nconv, workl(iheigi), 1, di, 1)
  706. end if
  707. c
  708. c %----------------------------------------------------------%
  709. c | Compute the QR factorization of the matrix representing |
  710. c | the wanted invariant subspace located in the first NCONV |
  711. c | columns of workl(invsub,ldq). |
  712. c %----------------------------------------------------------%
  713. c
  714. call dgeqr2 (ncv, nconv , workl(invsub),
  715. & ldq, workev, workev(ncv+1),
  716. & ierr)
  717. c
  718. c %---------------------------------------------------------%
  719. c | * Postmultiply V by Q using dorm2r . |
  720. c | * Copy the first NCONV columns of VQ into Z. |
  721. c | * Postmultiply Z by R. |
  722. c | The N by NCONV matrix Z is now a matrix representation |
  723. c | of the approximate invariant subspace associated with |
  724. c | the Ritz values in workl(iheigr) and workl(iheigi) |
  725. c | The first NCONV columns of V are now approximate Schur |
  726. c | vectors associated with the real upper quasi-triangular |
  727. c | matrix of order NCONV in workl(iuptri) |
  728. c %---------------------------------------------------------%
  729. c
  730. call dorm2r ('Right', 'Notranspose', n ,
  731. & ncv , nconv , workl(invsub),
  732. & ldq , workev , v ,
  733. & ldv , workd(n+1) , ierr)
  734. call dlacpy ('All', n, nconv, v, ldv, z, ldz)
  735. c
  736. do 20 j=1, nconv
  737. c
  738. c %---------------------------------------------------%
  739. c | Perform both a column and row scaling if the |
  740. c | diagonal element of workl(invsub,ldq) is negative |
  741. c | I'm lazy and don't take advantage of the upper |
  742. c | quasi-triangular form of workl(iuptri,ldq) |
  743. c | Note that since Q is orthogonal, R is a diagonal |
  744. c | matrix consisting of plus or minus ones |
  745. c %---------------------------------------------------%
  746. c
  747. if (workl(invsub+(j-1)*ldq+j-1) .lt. zero) then
  748. call dscal (nconv, -one, workl(iuptri+j-1), ldq)
  749. call dscal (nconv, -one, workl(iuptri+(j-1)*ldq), 1)
  750. end if
  751. c
  752. 20 continue
  753. c
  754. if (howmny .eq. 'A') then
  755. c
  756. c %--------------------------------------------%
  757. c | Compute the NCONV wanted eigenvectors of T |
  758. c | located in workl(iuptri,ldq). |
  759. c %--------------------------------------------%
  760. c
  761. do 30 j=1, ncv
  762. if (j .le. nconv) then
  763. select(j) = .true.
  764. else
  765. select(j) = .false.
  766. end if
  767. 30 continue
  768. c
  769. call dtrevc ('Right', 'Select' , select ,
  770. & ncv , workl(iuptri), ldq ,
  771. & vl , 1 , workl(invsub),
  772. & ldq , ncv , outncv ,
  773. & workev , ierr)
  774. c
  775. if (ierr .ne. 0) then
  776. info = -9
  777. go to 9000
  778. end if
  779. c
  780. c %------------------------------------------------%
  781. c | Scale the returning eigenvectors so that their |
  782. c | Euclidean norms are all one. LAPACK subroutine |
  783. c | dtrevc returns each eigenvector normalized so |
  784. c | that the element of largest magnitude has |
  785. c | magnitude 1; |
  786. c %------------------------------------------------%
  787. c
  788. iconj = 0
  789. do 40 j=1, nconv
  790. c
  791. if ( workl(iheigi+j-1) .eq. zero ) then
  792. c
  793. c %----------------------%
  794. c | real eigenvalue case |
  795. c %----------------------%
  796. c
  797. temp = dnrm2 ( ncv, workl(invsub+(j-1)*ldq), 1 )
  798. call dscal ( ncv, one / temp,
  799. & workl(invsub+(j-1)*ldq), 1 )
  800. c
  801. else
  802. c
  803. c %-------------------------------------------%
  804. c | Complex conjugate pair case. Note that |
  805. c | since the real and imaginary part of |
  806. c | the eigenvector are stored in consecutive |
  807. c | columns, we further normalize by the |
  808. c | square root of two. |
  809. c %-------------------------------------------%
  810. c
  811. if (iconj .eq. 0) then
  812. temp = dlapy2 (dnrm2 (ncv,
  813. & workl(invsub+(j-1)*ldq),
  814. & 1),
  815. & dnrm2 (ncv,
  816. & workl(invsub+j*ldq),
  817. & 1))
  818. call dscal (ncv, one/temp,
  819. & workl(invsub+(j-1)*ldq), 1 )
  820. call dscal (ncv, one/temp,
  821. & workl(invsub+j*ldq), 1 )
  822. iconj = 1
  823. else
  824. iconj = 0
  825. end if
  826. c
  827. end if
  828. c
  829. 40 continue
  830. c
  831. call dgemv ('T', ncv, nconv, one, workl(invsub),
  832. & ldq, workl(ihbds), 1, zero, workev, 1)
  833. c
  834. iconj = 0
  835. do 45 j=1, nconv
  836. if (workl(iheigi+j-1) .ne. zero) then
  837. c
  838. c %-------------------------------------------%
  839. c | Complex conjugate pair case. Note that |
  840. c | since the real and imaginary part of |
  841. c | the eigenvector are stored in consecutive |
  842. c %-------------------------------------------%
  843. c
  844. if (iconj .eq. 0) then
  845. workev(j) = dlapy2 (workev(j), workev(j+1))
  846. workev(j+1) = workev(j)
  847. iconj = 1
  848. else
  849. iconj = 0
  850. end if
  851. end if
  852. 45 continue
  853. c
  854. if (msglvl .gt. 2) then
  855. call dcopy (ncv, workl(invsub+ncv-1), ldq,
  856. & workl(ihbds), 1)
  857. call dvout (logfil, ncv, workl(ihbds), ndigit,
  858. & '_neupd: Last row of the eigenvector matrix for T')
  859. if (msglvl .gt. 3) then
  860. call dmout (logfil, ncv, ncv, workl(invsub), ldq,
  861. & ndigit, '_neupd: The eigenvector matrix for T')
  862. end if
  863. end if
  864. c
  865. c %---------------------------------------%
  866. c | Copy Ritz estimates into workl(ihbds) |
  867. c %---------------------------------------%
  868. c
  869. call dcopy (nconv, workev, 1, workl(ihbds), 1)
  870. c
  871. c %---------------------------------------------------------%
  872. c | Compute the QR factorization of the eigenvector matrix |
  873. c | associated with leading portion of T in the first NCONV |
  874. c | columns of workl(invsub,ldq). |
  875. c %---------------------------------------------------------%
  876. c
  877. call dgeqr2 (ncv, nconv , workl(invsub),
  878. & ldq, workev, workev(ncv+1),
  879. & ierr)
  880. c
  881. c %----------------------------------------------%
  882. c | * Postmultiply Z by Q. |
  883. c | * Postmultiply Z by R. |
  884. c | The N by NCONV matrix Z is now contains the |
  885. c | Ritz vectors associated with the Ritz values |
  886. c | in workl(iheigr) and workl(iheigi). |
  887. c %----------------------------------------------%
  888. c
  889. call dorm2r ('Right', 'Notranspose', n ,
  890. & ncv , nconv , workl(invsub),
  891. & ldq , workev , z ,
  892. & ldz , workd(n+1) , ierr)
  893. c
  894. call dtrmm ('Right' , 'Upper' , 'No transpose',
  895. & 'Non-unit', n , nconv ,
  896. & one , workl(invsub), ldq ,
  897. & z , ldz)
  898. c
  899. end if
  900. c
  901. else
  902. c
  903. c %------------------------------------------------------%
  904. c | An approximate invariant subspace is not needed. |
  905. c | Place the Ritz values computed DNAUPD into DR and DI |
  906. c %------------------------------------------------------%
  907. c
  908. call dcopy (nconv, workl(ritzr), 1, dr, 1)
  909. call dcopy (nconv, workl(ritzi), 1, di, 1)
  910. call dcopy (nconv, workl(ritzr), 1, workl(iheigr), 1)
  911. call dcopy (nconv, workl(ritzi), 1, workl(iheigi), 1)
  912. call dcopy (nconv, workl(bounds), 1, workl(ihbds), 1)
  913. end if
  914. c
  915. c %------------------------------------------------%
  916. c | Transform the Ritz values and possibly vectors |
  917. c | and corresponding error bounds of OP to those |
  918. c | of A*x = lambda*B*x. |
  919. c %------------------------------------------------%
  920. c
  921. if (type .eq. 'REGULR') then
  922. c
  923. if (rvec)
  924. & call dscal (ncv, rnorm, workl(ihbds), 1)
  925. c
  926. else
  927. c
  928. c %---------------------------------------%
  929. c | A spectral transformation was used. |
  930. c | * Determine the Ritz estimates of the |
  931. c | Ritz values in the original system. |
  932. c %---------------------------------------%
  933. c
  934. if (type .eq. 'SHIFTI') then
  935. c
  936. if (rvec)
  937. & call dscal (ncv, rnorm, workl(ihbds), 1)
  938. c
  939. do 50 k=1, ncv
  940. temp = dlapy2 ( workl(iheigr+k-1),
  941. & workl(iheigi+k-1) )
  942. workl(ihbds+k-1) = abs( workl(ihbds+k-1) )
  943. & / temp / temp
  944. 50 continue
  945. c
  946. else if (type .eq. 'REALPT') then
  947. c
  948. do 60 k=1, ncv
  949. 60 continue
  950. c
  951. else if (type .eq. 'IMAGPT') then
  952. c
  953. do 70 k=1, ncv
  954. 70 continue
  955. c
  956. end if
  957. c
  958. c %-----------------------------------------------------------%
  959. c | * Transform the Ritz values back to the original system. |
  960. c | For TYPE = 'SHIFTI' the transformation is |
  961. c | lambda = 1/theta + sigma |
  962. c | For TYPE = 'REALPT' or 'IMAGPT' the user must from |
  963. c | Rayleigh quotients or a projection. See remark 3 above.|
  964. c | NOTES: |
  965. c | *The Ritz vectors are not affected by the transformation. |
  966. c %-----------------------------------------------------------%
  967. c
  968. if (type .eq. 'SHIFTI') then
  969. c
  970. do 80 k=1, ncv
  971. temp = dlapy2 ( workl(iheigr+k-1),
  972. & workl(iheigi+k-1) )
  973. workl(iheigr+k-1) = workl(iheigr+k-1)/temp/temp
  974. & + sigmar
  975. workl(iheigi+k-1) = -workl(iheigi+k-1)/temp/temp
  976. & + sigmai
  977. 80 continue
  978. c
  979. call dcopy (nconv, workl(iheigr), 1, dr, 1)
  980. call dcopy (nconv, workl(iheigi), 1, di, 1)
  981. c
  982. else if (type .eq. 'REALPT' .or. type .eq. 'IMAGPT') then
  983. c
  984. call dcopy (nconv, workl(iheigr), 1, dr, 1)
  985. call dcopy (nconv, workl(iheigi), 1, di, 1)
  986. c
  987. end if
  988. c
  989. end if
  990. c
  991. if (type .eq. 'SHIFTI' .and. msglvl .gt. 1) then
  992. call dvout (logfil, nconv, dr, ndigit,
  993. & '_neupd: Untransformed real part of the Ritz valuess.')
  994. call dvout (logfil, nconv, di, ndigit,
  995. & '_neupd: Untransformed imag part of the Ritz valuess.')
  996. call dvout (logfil, nconv, workl(ihbds), ndigit,
  997. & '_neupd: Ritz estimates of untransformed Ritz values.')
  998. else if (type .eq. 'REGULR' .and. msglvl .gt. 1) then
  999. call dvout (logfil, nconv, dr, ndigit,
  1000. & '_neupd: Real parts of converged Ritz values.')
  1001. call dvout (logfil, nconv, di, ndigit,
  1002. & '_neupd: Imag parts of converged Ritz values.')
  1003. call dvout (logfil, nconv, workl(ihbds), ndigit,
  1004. & '_neupd: Associated Ritz estimates.')
  1005. end if
  1006. c
  1007. c %-------------------------------------------------%
  1008. c | Eigenvector Purification step. Formally perform |
  1009. c | one of inverse subspace iteration. Only used |
  1010. c | for MODE = 2. |
  1011. c %-------------------------------------------------%
  1012. c
  1013. if (rvec .and. howmny .eq. 'A' .and. type .eq. 'SHIFTI') then
  1014. c
  1015. c %------------------------------------------------%
  1016. c | Purify the computed Ritz vectors by adding a |
  1017. c | little bit of the residual vector: |
  1018. c | T |
  1019. c | resid(:)*( e s ) / theta |
  1020. c | NCV |
  1021. c | where H s = s theta. Remember that when theta |
  1022. c | has nonzero imaginary part, the corresponding |
  1023. c | Ritz vector is stored across two columns of Z. |
  1024. c %------------------------------------------------%
  1025. c
  1026. iconj = 0
  1027. do 110 j=1, nconv
  1028. if (workl(iheigi+j-1) .eq. zero) then
  1029. workev(j) = workl(invsub+(j-1)*ldq+ncv-1) /
  1030. & workl(iheigr+j-1)
  1031. else if (iconj .eq. 0) then
  1032. temp = dlapy2 ( workl(iheigr+j-1), workl(iheigi+j-1) )
  1033. workev(j) = ( workl(invsub+(j-1)*ldq+ncv-1) *
  1034. & workl(iheigr+j-1) +
  1035. & workl(invsub+j*ldq+ncv-1) *
  1036. & workl(iheigi+j-1) ) / temp / temp
  1037. workev(j+1) = ( workl(invsub+j*ldq+ncv-1) *
  1038. & workl(iheigr+j-1) -
  1039. & workl(invsub+(j-1)*ldq+ncv-1) *
  1040. & workl(iheigi+j-1) ) / temp / temp
  1041. iconj = 1
  1042. else
  1043. iconj = 0
  1044. end if
  1045. 110 continue
  1046. c
  1047. c %---------------------------------------%
  1048. c | Perform a rank one update to Z and |
  1049. c | purify all the Ritz vectors together. |
  1050. c %---------------------------------------%
  1051. c
  1052. call dger (n, nconv, one, resid, 1, workev, 1, z, ldz)
  1053. c
  1054. end if
  1055. c
  1056. 9000 continue
  1057. c
  1058. return
  1059. c
  1060. c %---------------%
  1061. c | End of DNEUPD |
  1062. c %---------------%
  1063. c
  1064. end
  1065.  
  1066.  

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