Télécharger dnaitr.eso

Retour à la liste

Numérotation des lignes :

  1. C DNAITR SOURCE BP208322 15/12/17 21:15:08 8750
  2. c-----------------------------------------------------------------------
  3. c\BeginDoc
  4. c
  5. c\Name: dnaitr
  6. c
  7. c\Description:
  8. c Reverse communication interface for applying NP additional steps to
  9. c a K step nonsymmetric Arnoldi factorization.
  10. c
  11. c Input: OP*V_{k} - V_{k}*H = r_{k}*e_{k}^T
  12. c
  13. c with (V_{k}^T)*B*V_{k} = I, (V_{k}^T)*B*r_{k} = 0.
  14. c
  15. c Output: OP*V_{k+p} - V_{k+p}*H = r_{k+p}*e_{k+p}^T
  16. c
  17. c with (V_{k+p}^T)*B*V_{k+p} = I, (V_{k+p}^T)*B*r_{k+p} = 0.
  18. c
  19. c where OP and B are as in dnaupd. The B-norm of r_{k+p} is also
  20. c computed and returned.
  21. c
  22. c\Usage:
  23. c call dnaitr
  24. c ( IDO, BMAT, N, K, NP, NB, RESID, RNORM, V, LDV, H, LDH,
  25. c IPNTR, WORKD, INFO )
  26. c
  27. c\Arguments
  28. c IDO Integer. (INPUT/OUTPUT)
  29. c Reverse communication flag.
  30. c -------------------------------------------------------------
  31. c IDO = 0: first call to the reverse communication interface
  32. c IDO = -1: compute Y = OP * X where
  33. c IPNTR(1) is the pointer into WORK for X,
  34. c IPNTR(2) is the pointer into WORK for Y.
  35. c This is for the restart phase to force the new
  36. c starting vector into the range of OP.
  37. c IDO = 1: compute Y = OP * X where
  38. c IPNTR(1) is the pointer into WORK for X,
  39. c IPNTR(2) is the pointer into WORK for Y,
  40. c IPNTR(3) is the pointer into WORK for B * X.
  41. c IDO = 2: compute Y = B * X where
  42. c IPNTR(1) is the pointer into WORK for X,
  43. c IPNTR(2) is the pointer into WORK for Y.
  44. c IDO = 99: done
  45. c -------------------------------------------------------------
  46. c When the routine is used in the "shift-and-invert" mode, the
  47. c vector B * Q is already available and do not need to be
  48. c recompute in forming OP * Q.
  49. c
  50. c BMAT Character*1. (INPUT)
  51. c BMAT specifies the type of the matrix B that defines the
  52. c semi-inner product for the operator OP. See dnaupd.
  53. c B = 'I' -> standard eigenvalue problem A*x = lambda*x
  54. c B = 'G' -> generalized eigenvalue problem A*x = lambda*M**x
  55. c
  56. c N Integer. (INPUT)
  57. c Dimension of the eigenproblem.
  58. c
  59. c K Integer. (INPUT)
  60. c Current size of V and H.
  61. c
  62. c NP Integer. (INPUT)
  63. c Number of additional Arnoldi steps to take.
  64. c
  65. c NB Integer. (INPUT)
  66. c Blocksize to be used in the recurrence.
  67. c Only work for NB = 1 right now. The goal is to have a
  68. c program that implement both the block and non-block method.
  69. c
  70. c RESID Double precision array of length N. (INPUT/OUTPUT)
  71. c On INPUT: RESID contains the residual vector r_{k}.
  72. c On OUTPUT: RESID contains the residual vector r_{k+p}.
  73. c
  74. c RNORM Double precision scalar. (INPUT/OUTPUT)
  75. c B-norm of the starting residual on input.
  76. c B-norm of the updated residual r_{k+p} on output.
  77. c
  78. c V REAL*8 N by K+NP array. (INPUT/OUTPUT)
  79. c On INPUT: V contains the Arnoldi vectors in the first K
  80. c columns.
  81. c On OUTPUT: V contains the new NP Arnoldi vectors in the next
  82. c NP columns. The first K columns are unchanged.
  83. c
  84. c LDV Integer. (INPUT)
  85. c Leading dimension of V exactly as declared in the calling
  86. c program.
  87. c
  88. c H REAL*8 (K+NP) by (K+NP) array. (INPUT/OUTPUT)
  89. c H is used to store the generated upper Hessenberg matrix.
  90. c
  91. c LDH Integer. (INPUT)
  92. c Leading dimension of H exactly as declared in the calling
  93. c program.
  94. c
  95. c IPNTR Integer array of length 3. (OUTPUT)
  96. c Pointer to mark the starting locations in the WORK for
  97. c vectors used by the Arnoldi iteration.
  98. c -------------------------------------------------------------
  99. c IPNTR(1): pointer to the current operand vector X.
  100. c IPNTR(2): pointer to the current result vector Y.
  101. c IPNTR(3): pointer to the vector B * X when used in the
  102. c shift-and-invert mode. X is the current operand.
  103. c -------------------------------------------------------------
  104. c
  105. c WORKD Double precision work array of length 3*N. (REVERSE COMMUNICATION)
  106. c Distributed array to be used in the basic Arnoldi iteration
  107. c for reverse communication. The calling program should not
  108. c use WORKD as temporary workspace during the iteration !!!!!!
  109. c On input, WORKD(1:N) = B*RESID and is used to save some
  110. c computation at the first step.
  111. c
  112. c INFO Integer. (OUTPUT)
  113. c = 0: Normal exit.
  114. c > 0: Size of the spanning invariant subspace of OP found.
  115. c
  116. c\EndDoc
  117. c
  118. c-----------------------------------------------------------------------
  119. c
  120. c\BeginLib
  121. c
  122. c\Local variables:
  123. c xxxxxx real
  124. c
  125. c\References:
  126. c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
  127. c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
  128. c pp 357-385.
  129. c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
  130. c Restarted Arnoldi Iteration", Rice University Technical Report
  131. c TR95-13, Department of Computational and Applied Mathematics.
  132. c
  133. c\Routines called:
  134. c dgetv0 ARPACK routine to generate the initial vector.
  135. c ivout ARPACK utility routine that prints integers.
  136. c arscnd ARPACK utility routine for timing.
  137. c dmout ARPACK utility routine that prints matrices
  138. c dvout ARPACK utility routine that prints vectors.
  139. c dlabad LAPACK routine that computes machine constants.
  140. c dlamch LAPACK routine that determines machine constants.
  141. c dlascl LAPACK routine for careful scaling of a matrix.
  142. c dlanhs LAPACK routine that computes various norms of a matrix.
  143. c dgemv Level 2 BLAS routine for matrix vector multiplication.
  144. c daxpy Level 1 BLAS that computes a vector triad.
  145. c dscal Level 1 BLAS that scales a vector.
  146. c dcopy Level 1 BLAS that copies one vector to another .
  147. c ddot Level 1 BLAS that computes the scalar product of two vectors.
  148. c dnrm2 Level 1 BLAS that computes the norm of a vector.
  149. c
  150. c\Author
  151. c Danny Sorensen Phuong Vu
  152. c Richard Lehoucq CRPC / Rice University
  153. c Dept. of Computational & Houston, Texas
  154. c Applied Mathematics
  155. c Rice University
  156. c Houston, Texas
  157. c
  158. c\Revision history:
  159. c xx/xx/92: Version ' 2.4'
  160. c
  161. c\SCCS Information: @(#)
  162. c FILE: naitr.F SID: 2.4 DATE OF SID: 8/27/96 RELEASE: 2
  163. c
  164. c\Remarks
  165. c The algorithm implemented is:
  166. c
  167. c restart = .false.
  168. c Given V_{k} = [v_{1}, ..., v_{k}], r_{k};
  169. c r_{k} contains the initial residual vector even for k = 0;
  170. c Also assume that rnorm = || B*r_{k} || and B*r_{k} are already
  171. c computed by the calling program.
  172. c
  173. c betaj = rnorm ; p_{k+1} = B*r_{k} ;
  174. c For j = k+1, ..., k+np Do
  175. c 1) if ( betaj < tol ) stop or restart depending on j.
  176. c ( At present tol is zero )
  177. c if ( restart ) generate a new starting vector.
  178. c 2) v_{j} = r(j-1)/betaj; V_{j} = [V_{j-1}, v_{j}];
  179. c p_{j} = p_{j}/betaj
  180. c 3) r_{j} = OP*v_{j} where OP is defined as in dnaupd
  181. c For shift-invert mode p_{j} = B*v_{j} is already available.
  182. c wnorm = || OP*v_{j} ||
  183. c 4) Compute the j-th step residual vector.
  184. c w_{j} = V_{j}^T * B * OP * v_{j}
  185. c r_{j} = OP*v_{j} - V_{j} * w_{j}
  186. c H(:,j) = w_{j};
  187. c H(j,j-1) = rnorm
  188. c rnorm = || r_(j) ||
  189. c If (rnorm > 0.717*wnorm) accept step and go back to 1)
  190. c 5) Re-orthogonalization step:
  191. c s = V_{j}'*B*r_{j}
  192. c r_{j} = r_{j} - V_{j}*s; rnorm1 = || r_{j} ||
  193. c alphaj = alphaj + s_{j};
  194. c 6) Iterative refinement step:
  195. c If (rnorm1 > 0.717*rnorm) then
  196. c rnorm = rnorm1
  197. c accept step and go back to 1)
  198. c Else
  199. c rnorm = rnorm1
  200. c If this is the first time in step 6), go to 5)
  201. c Else r_{j} lies in the span of V_{j} numerically.
  202. c Set r_{j} = 0 and rnorm = 0; go to 1)
  203. c EndIf
  204. c End Do
  205. c
  206. c\EndLib
  207. c
  208. c-----------------------------------------------------------------------
  209. c
  210. subroutine dnaitr
  211. & (ido, bmat, n, k, np, nb, resid, rnorm, v, ldv, h, ldh,
  212. & ipntr, workd, info)
  213. c
  214. c %----------------------------------------------------%
  215. c | Include files for debugging and timing information |
  216. -INC TARTRAK
  217. c %----------------------------------------------------%
  218. c
  219. c
  220. c %------------------%
  221. c | Scalar Arguments |
  222. c %------------------%
  223. c
  224. character bmat*1
  225. integer ido, info, k, ldh, ldv, n, nb, np
  226. REAL*8
  227. & rnorm
  228. c
  229. c %-----------------%
  230. c | Array Arguments |
  231. c %-----------------%
  232. c
  233. integer ipntr(3)
  234. REAL*8
  235. & h(ldh,k+np), resid(n), v(ldv,k+np), workd(3*n)
  236. c
  237. c %------------%
  238. c | Parameters |
  239. c %------------%
  240. c
  241. REAL*8
  242. & one, zero
  243. parameter (one = 1.0D+0, zero = 0.0D+0)
  244. c
  245. c %---------------%
  246. c | Local Scalars |
  247. c %---------------%
  248. c
  249. logical first, orth1, orth2, rstart, step3, step4
  250. integer ierr, i, infol, ipj, irj, ivj, iter, itry, j, msglvl,
  251. & jj
  252. REAL*8
  253. & betaj, ovfl, temp1, rnorm1, smlnum, tst1, ulp, unfl,
  254. & wnorm
  255. save first, orth1, orth2, rstart, step3, step4,
  256. & ierr, ipj, irj, ivj, iter, itry, j, msglvl, ovfl,
  257. & betaj, rnorm1, smlnum, ulp, unfl, wnorm
  258. c
  259. c %-----------------------%
  260. c | Local Array Arguments |
  261. c %-----------------------%
  262. c
  263. REAL*8
  264. & xtemp(2)
  265. c
  266. c %----------------------%
  267. c | External Subroutines |
  268. c %----------------------%
  269. c
  270. & dvout, dmout, ivout, arscnd
  271. c
  272. c %--------------------%
  273. c | External Functions |
  274. c %--------------------%
  275. c
  276. REAL*8
  277. external ddot, dnrm2, dlanhs, dlamch
  278. c
  279. c %---------------------%
  280. **c | Intrinsic Functions |
  281. **c %---------------------%
  282. **c
  283. ** intrinsic abs, sqrt
  284. **c
  285. **c %-----------------%
  286. **c | Data statements |
  287. **c %-----------------%
  288. **c
  289. data first / .true. /
  290. **c
  291. **c %-----------------------%
  292. **c | Executable Statements |
  293. c %-----------------------%
  294. c
  295. if (first) then
  296. c
  297. c %-----------------------------------------%
  298. c | Set machine-dependent constants for the |
  299. c | the splitting and deflation criterion. |
  300. c | If norm(H) <= sqrt(OVFL), |
  301. c | overflow should not occur. |
  302. c | REFERENCE: LAPACK subroutine dlahqr |
  303. c %-----------------------------------------%
  304. c
  305. unfl = dlamch( 'safe minimum' )
  306. ovfl = one / unfl
  307. call dlabad( unfl, ovfl )
  308. ulp = dlamch( 'precision' )
  309. smlnum = unfl*( n / ulp )
  310. first = .false.
  311. end if
  312. c
  313. if (ido .eq. 0) then
  314. c
  315. c %-------------------------------%
  316. c | Initialize timing statistics |
  317. c | & message level for debugging |
  318. c %-------------------------------%
  319. c
  320. * call arscnd (t0)
  321. msglvl = mnaitr
  322. c
  323. c %------------------------------%
  324. c | Initial call to this routine |
  325. c %------------------------------%
  326. c
  327. info = 0
  328. step3 = .false.
  329. step4 = .false.
  330. rstart = .false.
  331. orth1 = .false.
  332. orth2 = .false.
  333. j = k + 1
  334. ipj = 1
  335. irj = ipj + n
  336. ivj = irj + n
  337. end if
  338. c
  339. c %-------------------------------------------------%
  340. c | When in reverse communication mode one of: |
  341. c | STEP3, STEP4, ORTH1, ORTH2, RSTART |
  342. c | will be .true. when .... |
  343. c | STEP3: return from computing OP*v_{j}. |
  344. c | STEP4: return from computing B-norm of OP*v_{j} |
  345. c | ORTH1: return from computing B-norm of r_{j+1} |
  346. c | ORTH2: return from computing B-norm of |
  347. c | correction to the residual vector. |
  348. c | RSTART: return from OP computations needed by |
  349. c | dgetv0. |
  350. c %-------------------------------------------------%
  351. c
  352. if (step3) go to 50
  353. if (step4) go to 60
  354. if (orth1) go to 70
  355. if (orth2) go to 90
  356. if (rstart) go to 30
  357. c
  358. c %-----------------------------%
  359. c | Else this is the first step |
  360. c %-----------------------------%
  361. c
  362. c %--------------------------------------------------------------%
  363. c | |
  364. c | A R N O L D I I T E R A T I O N L O O P |
  365. c | |
  366. c | Note: B*r_{j-1} is already in WORKD(1:N)=WORKD(IPJ:IPJ+N-1) |
  367. c %--------------------------------------------------------------%
  368.  
  369. 1000 continue
  370. c
  371. if (msglvl .gt. 1) then
  372. call ivout (logfil, 1, j, ndigit,
  373. & '_naitr: generating Arnoldi vector number')
  374. c call dvout (logfil, 1, rnorm, ndigit,
  375. c & '_naitr: B-norm of the current residual is')
  376. end if
  377. c
  378. c %---------------------------------------------------%
  379. c | STEP 1: Check if the B norm of j-th residual |
  380. c | vector is zero. Equivalent to determing whether |
  381. c | an exact j-step Arnoldi factorization is present. |
  382. c %---------------------------------------------------%
  383. c
  384. betaj = rnorm
  385. if (rnorm .gt. zero) go to 40
  386. c
  387. c %---------------------------------------------------%
  388. c | Invariant subspace found, generate a new starting |
  389. c | vector which is orthogonal to the current Arnoldi |
  390. c | basis and continue the iteration. |
  391. c %---------------------------------------------------%
  392. c
  393. if (msglvl .gt. 0) then
  394. call ivout (logfil, 1, j, ndigit,
  395. & '_naitr: ****** RESTART AT STEP ******')
  396. end if
  397. c
  398. c %---------------------------------------------%
  399. c | ITRY is the loop variable that controls the |
  400. c | maximum amount of times that a restart is |
  401. c %---------------------------------------------%
  402. c
  403. betaj = zero
  404. nrstrt = nrstrt + 1
  405. itry = 1
  406. 20 continue
  407. rstart = .true.
  408. ido = 0
  409. 30 continue
  410. c
  411. c %--------------------------------------%
  412. c | If in reverse communication mode and |
  413. c | RSTART = .true. flow returns here. |
  414. c %--------------------------------------%
  415. c
  416. call dgetv0 (ido, bmat, itry, .false., n, j, v, ldv,
  417. & resid, rnorm, ipntr, workd, ierr)
  418. if (ido .ne. 99) go to 9000
  419. if (ierr .lt. 0) then
  420. itry = itry + 1
  421. if (itry .le. 3) go to 20
  422. c
  423. c %------------------------------------------------%
  424. c | Give up after several restart attempts. |
  425. c | Set INFO to the size of the invariant subspace |
  426. c | which spans OP and exit. |
  427. c %------------------------------------------------%
  428. c
  429. info = j - 1
  430. * call arscnd (t1)
  431. tnaitr = tnaitr + (t1 - t0)
  432. ido = 99
  433. go to 9000
  434. end if
  435. c
  436. 40 continue
  437. c
  438. c %---------------------------------------------------------%
  439. c | STEP 2: v_{j} = r_{j-1}/rnorm and p_{j} = p_{j}/rnorm |
  440. c | Note that p_{j} = B*r_{j-1}. In order to avoid overflow |
  441. c | when reciprocating a small RNORM, test against lower |
  442. c | machine bound. |
  443. c %---------------------------------------------------------%
  444. c
  445. call dcopy (n, resid, 1, v(1,j), 1)
  446. if (rnorm .ge. unfl) then
  447. temp1 = one / rnorm
  448. call dscal (n, temp1, v(1,j), 1)
  449. call dscal (n, temp1, workd(ipj), 1)
  450. else
  451. c
  452. c %-----------------------------------------%
  453. c | To scale both v_{j} and p_{j} carefully |
  454. c | use LAPACK routine SLASCL |
  455. c %-----------------------------------------%
  456. c
  457. call dlascl ('General', i, i, rnorm, one, n, 1,
  458. & v(1,j), n, infol)
  459. call dlascl ('General', i, i, rnorm, one, n, 1,
  460. & workd(ipj), n, infol)
  461. end if
  462. c
  463. c %------------------------------------------------------%
  464. c | STEP 3: r_{j} = OP*v_{j}; Note that p_{j} = B*v_{j} |
  465. c | Note that this is not quite yet r_{j}. See STEP 4 |
  466. c %------------------------------------------------------%
  467. c
  468. step3 = .true.
  469. nopx = nopx + 1
  470. * call arscnd (t2)
  471. call dcopy (n, v(1,j), 1, workd(ivj), 1)
  472. ipntr(1) = ivj
  473. ipntr(2) = irj
  474. ipntr(3) = ipj
  475. ido = 1
  476. c
  477. c %-----------------------------------%
  478. c | Exit in order to compute OP*v_{j} |
  479. c %-----------------------------------%
  480. c
  481. go to 9000
  482. 50 continue
  483. c
  484. c %----------------------------------%
  485. c | Back from reverse communication; |
  486. c | WORKD(IRJ:IRJ+N-1) := OP*v_{j} |
  487. c | if step3 = .true. |
  488. c %----------------------------------%
  489. c
  490. * call arscnd (t3)
  491. tmvopx = tmvopx + (t3 - t2)
  492.  
  493. step3 = .false.
  494. c
  495. c %------------------------------------------%
  496. c | Put another copy of OP*v_{j} into RESID. |
  497. c %------------------------------------------%
  498. c
  499. call dcopy (n, workd(irj), 1, resid, 1)
  500. c
  501. c %---------------------------------------%
  502. c | STEP 4: Finish extending the Arnoldi |
  503. c | factorization to length j. |
  504. c %---------------------------------------%
  505. c
  506. * call arscnd (t2)
  507. if (bmat .eq. 'G') then
  508. nbx = nbx + 1
  509. step4 = .true.
  510. ipntr(1) = irj
  511. ipntr(2) = ipj
  512. ido = 2
  513. c
  514. c %-------------------------------------%
  515. c | Exit in order to compute B*OP*v_{j} |
  516. c %-------------------------------------%
  517. c
  518. go to 9000
  519. else if (bmat .eq. 'I') then
  520. call dcopy (n, resid, 1, workd(ipj), 1)
  521. end if
  522. 60 continue
  523. c
  524. c %----------------------------------%
  525. c | Back from reverse communication; |
  526. c | WORKD(IPJ:IPJ+N-1) := B*OP*v_{j} |
  527. c | if step4 = .true. |
  528. c %----------------------------------%
  529. c
  530. if (bmat .eq. 'G') then
  531. * call arscnd (t3)
  532. tmvbx = tmvbx + (t3 - t2)
  533. end if
  534. c
  535. step4 = .false.
  536. c
  537. c %-------------------------------------%
  538. c | The following is needed for STEP 5. |
  539. c | Compute the B-norm of OP*v_{j}. |
  540. c %-------------------------------------%
  541. c
  542. if (bmat .eq. 'G') then
  543. wnorm = ddot (n, resid, 1, workd(ipj), 1)
  544. wnorm = sqrt(abs(wnorm))
  545. else if (bmat .eq. 'I') then
  546. wnorm = dnrm2(n, resid, 1)
  547. end if
  548. c
  549. c %-----------------------------------------%
  550. c | Compute the j-th residual corresponding |
  551. c | to the j step factorization. |
  552. c | Use Classical Gram Schmidt and compute: |
  553. c | w_{j} <- V_{j}^T * B * OP * v_{j} |
  554. c | r_{j} <- OP*v_{j} - V_{j} * w_{j} |
  555. c %-----------------------------------------%
  556. c
  557. c
  558. c %------------------------------------------%
  559. c | Compute the j Fourier coefficients w_{j} |
  560. c | WORKD(IPJ:IPJ+N-1) contains B*OP*v_{j}. |
  561. c %------------------------------------------%
  562. c
  563. call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1,
  564. & zero, h(1,j), 1)
  565. c
  566. c %--------------------------------------%
  567. c | Orthogonalize r_{j} against V_{j}. |
  568. c | RESID contains OP*v_{j}. See STEP 3. |
  569. c %--------------------------------------%
  570. c
  571. call dgemv ('N', n, j, -one, v, ldv, h(1,j), 1,
  572. & one, resid, 1)
  573. c
  574. if (j .gt. 1) h(j,j-1) = betaj
  575. c
  576. * call arscnd (t4)
  577. c
  578. orth1 = .true.
  579. c
  580. * call arscnd (t2)
  581. if (bmat .eq. 'G') then
  582. nbx = nbx + 1
  583. call dcopy (n, resid, 1, workd(irj), 1)
  584. ipntr(1) = irj
  585. ipntr(2) = ipj
  586. ido = 2
  587. c
  588. c %----------------------------------%
  589. c | Exit in order to compute B*r_{j} |
  590. c %----------------------------------%
  591. c
  592. go to 9000
  593. else if (bmat .eq. 'I') then
  594. call dcopy (n, resid, 1, workd(ipj), 1)
  595. end if
  596. 70 continue
  597. c
  598. c %---------------------------------------------------%
  599. c | Back from reverse communication if ORTH1 = .true. |
  600. c | WORKD(IPJ:IPJ+N-1) := B*r_{j}. |
  601. c %---------------------------------------------------%
  602. c
  603. if (bmat .eq. 'G') then
  604. * call arscnd (t3)
  605. tmvbx = tmvbx + (t3 - t2)
  606. end if
  607. c
  608. orth1 = .false.
  609. c
  610. c %------------------------------%
  611. c | Compute the B-norm of r_{j}. |
  612. c %------------------------------%
  613. c
  614. if (bmat .eq. 'G') then
  615. rnorm = ddot (n, resid, 1, workd(ipj), 1)
  616. rnorm = sqrt(abs(rnorm))
  617. else if (bmat .eq. 'I') then
  618. rnorm = dnrm2(n, resid, 1)
  619. end if
  620. c
  621. c %-----------------------------------------------------------%
  622. c | STEP 5: Re-orthogonalization / Iterative refinement phase |
  623. c | Maximum NITER_ITREF tries. |
  624. c | |
  625. c | s = V_{j}^T * B * r_{j} |
  626. c | r_{j} = r_{j} - V_{j}*s |
  627. c | alphaj = alphaj + s_{j} |
  628. c | |
  629. c | The stopping criteria used for iterative refinement is |
  630. c | discussed in Parlett's book SEP, page 107 and in Gragg & |
  631. c | Reichel ACM TOMS paper; Algorithm 686, Dec. 1990. |
  632. c | Determine if we need to correct the residual. The goal is |
  633. c | to enforce ||v(:,1:j)^T * r_{j}|| .le. eps * || r_{j} || |
  634. c | The following test determines whether the sine of the |
  635. c | angle between OP*x and the computed residual is less |
  636. c | than or equal to 0.717. |
  637. c %-----------------------------------------------------------%
  638. c
  639. if (rnorm .gt. 0.717*wnorm) go to 100
  640. iter = 0
  641. nrorth = nrorth + 1
  642. c
  643. c %---------------------------------------------------%
  644. c | Enter the Iterative refinement phase. If further |
  645. c | refinement is necessary, loop back here. The loop |
  646. c | variable is ITER. Perform a step of Classical |
  647. c | Gram-Schmidt using all the Arnoldi vectors V_{j} |
  648. c %---------------------------------------------------%
  649. c
  650. 80 continue
  651. c
  652. if (msglvl .gt. 2) then
  653. xtemp(1) = wnorm
  654. xtemp(2) = rnorm
  655. c call dvout (logfil, 2, xtemp, ndigit,
  656. c & '_naitr: re-orthonalization; wnorm and rnorm are')
  657. c call dvout (logfil, j, h(1,j), ndigit,
  658. c & '_naitr: j-th column of H')
  659. end if
  660. c
  661. c %----------------------------------------------------%
  662. c | Compute V_{j}^T * B * r_{j}. |
  663. c | WORKD(IRJ:IRJ+J-1) = v(:,1:J)'*WORKD(IPJ:IPJ+N-1). |
  664. c %----------------------------------------------------%
  665. c
  666. call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1,
  667. & zero, workd(irj), 1)
  668. c
  669. c %---------------------------------------------%
  670. c | Compute the correction to the residual: |
  671. c | r_{j} = r_{j} - V_{j} * WORKD(IRJ:IRJ+J-1). |
  672. c | The correction to H is v(:,1:J)*H(1:J,1:J) |
  673. c | + v(:,1:J)*WORKD(IRJ:IRJ+J-1)*e'_j. |
  674. c %---------------------------------------------%
  675. c
  676. call dgemv ('N', n, j, -one, v, ldv, workd(irj), 1,
  677. & one, resid, 1)
  678. call daxpy (j, one, workd(irj), 1, h(1,j), 1)
  679. c
  680. orth2 = .true.
  681. * call arscnd (t2)
  682. if (bmat .eq. 'G') then
  683. nbx = nbx + 1
  684. call dcopy (n, resid, 1, workd(irj), 1)
  685. ipntr(1) = irj
  686. ipntr(2) = ipj
  687. ido = 2
  688. c
  689. c %-----------------------------------%
  690. c | Exit in order to compute B*r_{j}. |
  691. c | r_{j} is the corrected residual. |
  692. c %-----------------------------------%
  693. c
  694. go to 9000
  695. else if (bmat .eq. 'I') then
  696. call dcopy (n, resid, 1, workd(ipj), 1)
  697. end if
  698. 90 continue
  699. c
  700. c %---------------------------------------------------%
  701. c | Back from reverse communication if ORTH2 = .true. |
  702. c %---------------------------------------------------%
  703. c
  704. if (bmat .eq. 'G') then
  705. * call arscnd (t3)
  706. tmvbx = tmvbx + (t3 - t2)
  707. end if
  708. c
  709. c %-----------------------------------------------------%
  710. c | Compute the B-norm of the corrected residual r_{j}. |
  711. c %-----------------------------------------------------%
  712. c
  713. if (bmat .eq. 'G') then
  714. rnorm1 = ddot (n, resid, 1, workd(ipj), 1)
  715. rnorm1 = sqrt(abs(rnorm1))
  716. else if (bmat .eq. 'I') then
  717. rnorm1 = dnrm2(n, resid, 1)
  718. end if
  719. c
  720. if (msglvl .gt. 0 .and. iter .gt. 0) then
  721. call ivout (logfil, 1, j, ndigit,
  722. & '_naitr: Iterative refinement for Arnoldi residual')
  723. if (msglvl .gt. 2) then
  724. xtemp(1) = rnorm
  725. xtemp(2) = rnorm1
  726. c call dvout (logfil, 2, xtemp, ndigit,
  727. c & '_naitr: iterative refinement ; rnorm and rnorm1 are')
  728. end if
  729. end if
  730. c
  731. c %-----------------------------------------%
  732. c | Determine if we need to perform another |
  733. c | step of re-orthogonalization. |
  734. c %-----------------------------------------%
  735. c
  736. if (rnorm1 .gt. 0.717*rnorm) then
  737. c
  738. c %---------------------------------------%
  739. c | No need for further refinement. |
  740. c | The cosine of the angle between the |
  741. c | corrected residual vector and the old |
  742. c | residual vector is greater than 0.717 |
  743. c | In other words the corrected residual |
  744. c | and the old residual vector share an |
  745. c | angle of less than arcCOS(0.717) |
  746. c %---------------------------------------%
  747. c
  748. rnorm = rnorm1
  749. c
  750. else
  751. c
  752. c %-------------------------------------------%
  753. c | Another step of iterative refinement step |
  754. c %-------------------------------------------%
  755. c
  756. nitref = nitref + 1
  757. rnorm = rnorm1
  758. iter = iter + 1
  759. if (iter .le. 1) go to 80
  760. c
  761. c %-------------------------------------------------%
  762. c | Otherwise RESID is numerically in the span of V |
  763. c %-------------------------------------------------%
  764. c
  765. do 95 jj = 1, n
  766. resid(jj) = zero
  767. 95 continue
  768. rnorm = zero
  769. end if
  770. c
  771. c %----------------------------------------------%
  772. c | Branch here directly if iterative refinement |
  773. c | wasn't necessary or after at most NITER_REF |
  774. c | steps of iterative refinement. |
  775. c %----------------------------------------------%
  776. c
  777. 100 continue
  778. c
  779. rstart = .false.
  780. orth2 = .false.
  781. c
  782. * call arscnd (t5)
  783. titref = titref + (t5 - t4)
  784. c
  785. c %------------------------------------%
  786. c | STEP 6: Update j = j+1; Continue |
  787. c %------------------------------------%
  788. c
  789. j = j + 1
  790. if (j .gt. k+np) then
  791. * call arscnd (t1)
  792. tnaitr = tnaitr + (t1 - t0)
  793. ido = 99
  794. do 110 i = max(1,k), k+np-1
  795. c
  796. c %--------------------------------------------%
  797. c | Check for splitting and deflation. |
  798. c | Use a standard test as in the QR algorithm |
  799. c | REFERENCE: LAPACK subroutine dlahqr |
  800. c %--------------------------------------------%
  801. c
  802. tst1 = abs( h( i, i ) ) + abs( h( i+1, i+1 ) )
  803. if( tst1.eq.zero )
  804. & tst1 = dlanhs( '1', k+np, h, ldh, workd(n+1) )
  805. if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) )
  806. & h(i+1,i) = zero
  807. 110 continue
  808. c
  809. if (msglvl .gt. 2) then
  810. call dmout (logfil, k+np, k+np, h, ldh, ndigit,
  811. & '_naitr: Final upper Hessenberg matrix H of order K+NP')
  812. end if
  813. c
  814. go to 9000
  815. end if
  816. c
  817. c %--------------------------------------------------------%
  818. c | Loop back to extend the factorization by another step. |
  819. c %--------------------------------------------------------%
  820. c
  821. go to 1000
  822. c
  823. c %---------------------------------------------------------------%
  824. c | |
  825. c | E N D O F M A I N I T E R A T I O N L O O P |
  826. c | |
  827. c %---------------------------------------------------------------%
  828. c
  829. 9000 continue
  830. return
  831. c
  832. c %---------------%
  833. c | End of dnaitr |
  834. c %---------------%
  835. c
  836. end
  837.  
  838.  
  839.  

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