Télécharger dnaitr.eso

Retour à la liste

Numérotation des lignes :

  1. C DNAITR SOURCE GF238795 18/02/05 21:15:13 9726
  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. REAL*8 T0,T1,T2,T3,T4,T5
  229. c
  230. c %-----------------%
  231. c | Array Arguments |
  232. c %-----------------%
  233. c
  234. integer ipntr(3)
  235. REAL*8
  236. & h(ldh,k+np), resid(n), v(ldv,k+np), workd(3*n)
  237. c
  238. c %------------%
  239. c | Parameters |
  240. c %------------%
  241. c
  242. REAL*8
  243. & one, zero
  244. parameter (one = 1.0D+0, zero = 0.0D+0)
  245. c
  246. c %---------------%
  247. c | Local Scalars |
  248. c %---------------%
  249. c
  250. logical first, orth1, orth2, rstart, step3, step4
  251. integer ierr, i, infol, ipj, irj, ivj, iter, itry, j, msglvl,
  252. & jj
  253. REAL*8
  254. & betaj, ovfl, temp1, rnorm1, smlnum, tst1, ulp, unfl,
  255. & wnorm
  256. save first, orth1, orth2, rstart, step3, step4,
  257. & ierr, ipj, irj, ivj, iter, itry, j, msglvl, ovfl,
  258. & betaj, rnorm1, smlnum, ulp, unfl, wnorm
  259. c
  260. c %-----------------------%
  261. c | Local Array Arguments |
  262. c %-----------------------%
  263. c
  264. REAL*8
  265. & xtemp(2)
  266. c
  267. c %----------------------%
  268. c | External Subroutines |
  269. c %----------------------%
  270. c
  271. & dvout, dmout, ivout, arscnd
  272. c
  273. c %--------------------%
  274. c | External Functions |
  275. c %--------------------%
  276. c
  277. REAL*8
  278. external ddot, dnrm2, dlanhs, dlamch
  279. c
  280. c %---------------------%
  281. **c | Intrinsic Functions |
  282. **c %---------------------%
  283. **c
  284. ** intrinsic abs, sqrt
  285. **c
  286. **c %-----------------%
  287. **c | Data statements |
  288. **c %-----------------%
  289. **c
  290. data first / .true. /
  291. **c
  292. **c %-----------------------%
  293. **c | Executable Statements |
  294. c %-----------------------%
  295. T0 = 0.D0
  296. T1 = 0.D0
  297. T2 = 0.D0
  298. T3 = 0.D0
  299. T4 = 0.D0
  300. T5 = 0.D0
  301. c
  302. if (first) then
  303. c
  304. c %-----------------------------------------%
  305. c | Set machine-dependent constants for the |
  306. c | the splitting and deflation criterion. |
  307. c | If norm(H) <= sqrt(OVFL), |
  308. c | overflow should not occur. |
  309. c | REFERENCE: LAPACK subroutine dlahqr |
  310. c %-----------------------------------------%
  311. c
  312. unfl = dlamch( 'safe minimum' )
  313. ovfl = one / unfl
  314. call dlabad( unfl, ovfl )
  315. ulp = dlamch( 'precision' )
  316. smlnum = unfl*( n / ulp )
  317. first = .false.
  318. end if
  319. c
  320. if (ido .eq. 0) then
  321. c
  322. c %-------------------------------%
  323. c | Initialize timing statistics |
  324. c | & message level for debugging |
  325. c %-------------------------------%
  326. c
  327. * call arscnd (t0)
  328. msglvl = mnaitr
  329. c
  330. c %------------------------------%
  331. c | Initial call to this routine |
  332. c %------------------------------%
  333. c
  334. info = 0
  335. step3 = .false.
  336. step4 = .false.
  337. rstart = .false.
  338. orth1 = .false.
  339. orth2 = .false.
  340. j = k + 1
  341. ipj = 1
  342. irj = ipj + n
  343. ivj = irj + n
  344. end if
  345. c
  346. c %-------------------------------------------------%
  347. c | When in reverse communication mode one of: |
  348. c | STEP3, STEP4, ORTH1, ORTH2, RSTART |
  349. c | will be .true. when .... |
  350. c | STEP3: return from computing OP*v_{j}. |
  351. c | STEP4: return from computing B-norm of OP*v_{j} |
  352. c | ORTH1: return from computing B-norm of r_{j+1} |
  353. c | ORTH2: return from computing B-norm of |
  354. c | correction to the residual vector. |
  355. c | RSTART: return from OP computations needed by |
  356. c | dgetv0. |
  357. c %-------------------------------------------------%
  358. c
  359. if (step3) go to 50
  360. if (step4) go to 60
  361. if (orth1) go to 70
  362. if (orth2) go to 90
  363. if (rstart) go to 30
  364. c
  365. c %-----------------------------%
  366. c | Else this is the first step |
  367. c %-----------------------------%
  368. c
  369. c %--------------------------------------------------------------%
  370. c | |
  371. c | A R N O L D I I T E R A T I O N L O O P |
  372. c | |
  373. c | Note: B*r_{j-1} is already in WORKD(1:N)=WORKD(IPJ:IPJ+N-1) |
  374. c %--------------------------------------------------------------%
  375.  
  376. 1000 continue
  377. c
  378. if (msglvl .gt. 1) then
  379. call ivout (logfil, 1, j, ndigit,
  380. & '_naitr: generating Arnoldi vector number')
  381. c call dvout (logfil, 1, rnorm, ndigit,
  382. c & '_naitr: B-norm of the current residual is')
  383. end if
  384. c
  385. c %---------------------------------------------------%
  386. c | STEP 1: Check if the B norm of j-th residual |
  387. c | vector is zero. Equivalent to determing whether |
  388. c | an exact j-step Arnoldi factorization is present. |
  389. c %---------------------------------------------------%
  390. c
  391. betaj = rnorm
  392. if (rnorm .gt. zero) go to 40
  393. c
  394. c %---------------------------------------------------%
  395. c | Invariant subspace found, generate a new starting |
  396. c | vector which is orthogonal to the current Arnoldi |
  397. c | basis and continue the iteration. |
  398. c %---------------------------------------------------%
  399. c
  400. if (msglvl .gt. 0) then
  401. call ivout (logfil, 1, j, ndigit,
  402. & '_naitr: ****** RESTART AT STEP ******')
  403. end if
  404. c
  405. c %---------------------------------------------%
  406. c | ITRY is the loop variable that controls the |
  407. c | maximum amount of times that a restart is |
  408. c %---------------------------------------------%
  409. c
  410. betaj = zero
  411. nrstrt = nrstrt + 1
  412. itry = 1
  413. 20 continue
  414. rstart = .true.
  415. ido = 0
  416. 30 continue
  417. c
  418. c %--------------------------------------%
  419. c | If in reverse communication mode and |
  420. c | RSTART = .true. flow returns here. |
  421. c %--------------------------------------%
  422. c
  423. call dgetv0 (ido, bmat, itry, .false., n, j, v, ldv,
  424. & resid, rnorm, ipntr, workd, ierr)
  425. if (ido .ne. 99) go to 9000
  426. if (ierr .lt. 0) then
  427. itry = itry + 1
  428. if (itry .le. 3) go to 20
  429. c
  430. c %------------------------------------------------%
  431. c | Give up after several restart attempts. |
  432. c | Set INFO to the size of the invariant subspace |
  433. c | which spans OP and exit. |
  434. c %------------------------------------------------%
  435. c
  436. info = j - 1
  437. * call arscnd (t1)
  438. tnaitr = tnaitr + (t1 - t0)
  439. ido = 99
  440. go to 9000
  441. end if
  442. c
  443. 40 continue
  444. c
  445. c %---------------------------------------------------------%
  446. c | STEP 2: v_{j} = r_{j-1}/rnorm and p_{j} = p_{j}/rnorm |
  447. c | Note that p_{j} = B*r_{j-1}. In order to avoid overflow |
  448. c | when reciprocating a small RNORM, test against lower |
  449. c | machine bound. |
  450. c %---------------------------------------------------------%
  451. c
  452. call dcopy (n, resid, 1, v(1,j), 1)
  453. if (rnorm .ge. unfl) then
  454. temp1 = one / rnorm
  455. call dscal (n, temp1, v(1,j), 1)
  456. call dscal (n, temp1, workd(ipj), 1)
  457. else
  458. c
  459. c %-----------------------------------------%
  460. c | To scale both v_{j} and p_{j} carefully |
  461. c | use LAPACK routine SLASCL |
  462. c %-----------------------------------------%
  463. c
  464. call dlascl ('General', i, i, rnorm, one, n, 1,
  465. & v(1,j), n, infol)
  466. call dlascl ('General', i, i, rnorm, one, n, 1,
  467. & workd(ipj), n, infol)
  468. end if
  469. c
  470. c %------------------------------------------------------%
  471. c | STEP 3: r_{j} = OP*v_{j}; Note that p_{j} = B*v_{j} |
  472. c | Note that this is not quite yet r_{j}. See STEP 4 |
  473. c %------------------------------------------------------%
  474. c
  475. step3 = .true.
  476. nopx = nopx + 1
  477. * call arscnd (t2)
  478. call dcopy (n, v(1,j), 1, workd(ivj), 1)
  479. ipntr(1) = ivj
  480. ipntr(2) = irj
  481. ipntr(3) = ipj
  482. ido = 1
  483. c
  484. c %-----------------------------------%
  485. c | Exit in order to compute OP*v_{j} |
  486. c %-----------------------------------%
  487. c
  488. go to 9000
  489. 50 continue
  490. c
  491. c %----------------------------------%
  492. c | Back from reverse communication; |
  493. c | WORKD(IRJ:IRJ+N-1) := OP*v_{j} |
  494. c | if step3 = .true. |
  495. c %----------------------------------%
  496. c
  497. * call arscnd (t3)
  498. tmvopx = tmvopx + (t3 - t2)
  499.  
  500. step3 = .false.
  501. c
  502. c %------------------------------------------%
  503. c | Put another copy of OP*v_{j} into RESID. |
  504. c %------------------------------------------%
  505. c
  506. call dcopy (n, workd(irj), 1, resid, 1)
  507. c
  508. c %---------------------------------------%
  509. c | STEP 4: Finish extending the Arnoldi |
  510. c | factorization to length j. |
  511. c %---------------------------------------%
  512. c
  513. * call arscnd (t2)
  514. if (bmat .eq. 'G') then
  515. nbx = nbx + 1
  516. step4 = .true.
  517. ipntr(1) = irj
  518. ipntr(2) = ipj
  519. ido = 2
  520. c
  521. c %-------------------------------------%
  522. c | Exit in order to compute B*OP*v_{j} |
  523. c %-------------------------------------%
  524. c
  525. go to 9000
  526. else if (bmat .eq. 'I') then
  527. call dcopy (n, resid, 1, workd(ipj), 1)
  528. end if
  529. 60 continue
  530. c
  531. c %----------------------------------%
  532. c | Back from reverse communication; |
  533. c | WORKD(IPJ:IPJ+N-1) := B*OP*v_{j} |
  534. c | if step4 = .true. |
  535. c %----------------------------------%
  536. c
  537. if (bmat .eq. 'G') then
  538. * call arscnd (t3)
  539. tmvbx = tmvbx + (t3 - t2)
  540. end if
  541. c
  542. step4 = .false.
  543. c
  544. c %-------------------------------------%
  545. c | The following is needed for STEP 5. |
  546. c | Compute the B-norm of OP*v_{j}. |
  547. c %-------------------------------------%
  548. c
  549. if (bmat .eq. 'G') then
  550. wnorm = ddot (n, resid, 1, workd(ipj), 1)
  551. wnorm = sqrt(abs(wnorm))
  552. else if (bmat .eq. 'I') then
  553. wnorm = dnrm2(n, resid, 1)
  554. end if
  555. c
  556. c %-----------------------------------------%
  557. c | Compute the j-th residual corresponding |
  558. c | to the j step factorization. |
  559. c | Use Classical Gram Schmidt and compute: |
  560. c | w_{j} <- V_{j}^T * B * OP * v_{j} |
  561. c | r_{j} <- OP*v_{j} - V_{j} * w_{j} |
  562. c %-----------------------------------------%
  563. c
  564. c
  565. c %------------------------------------------%
  566. c | Compute the j Fourier coefficients w_{j} |
  567. c | WORKD(IPJ:IPJ+N-1) contains B*OP*v_{j}. |
  568. c %------------------------------------------%
  569. c
  570. call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1,
  571. & zero, h(1,j), 1)
  572. c
  573. c %--------------------------------------%
  574. c | Orthogonalize r_{j} against V_{j}. |
  575. c | RESID contains OP*v_{j}. See STEP 3. |
  576. c %--------------------------------------%
  577. c
  578. call dgemv ('N', n, j, -one, v, ldv, h(1,j), 1,
  579. & one, resid, 1)
  580. c
  581. if (j .gt. 1) h(j,j-1) = betaj
  582. c
  583. * call arscnd (t4)
  584. c
  585. orth1 = .true.
  586. c
  587. * call arscnd (t2)
  588. if (bmat .eq. 'G') then
  589. nbx = nbx + 1
  590. call dcopy (n, resid, 1, workd(irj), 1)
  591. ipntr(1) = irj
  592. ipntr(2) = ipj
  593. ido = 2
  594. c
  595. c %----------------------------------%
  596. c | Exit in order to compute B*r_{j} |
  597. c %----------------------------------%
  598. c
  599. go to 9000
  600. else if (bmat .eq. 'I') then
  601. call dcopy (n, resid, 1, workd(ipj), 1)
  602. end if
  603. 70 continue
  604. c
  605. c %---------------------------------------------------%
  606. c | Back from reverse communication if ORTH1 = .true. |
  607. c | WORKD(IPJ:IPJ+N-1) := B*r_{j}. |
  608. c %---------------------------------------------------%
  609. c
  610. if (bmat .eq. 'G') then
  611. * call arscnd (t3)
  612. tmvbx = tmvbx + (t3 - t2)
  613. end if
  614. c
  615. orth1 = .false.
  616. c
  617. c %------------------------------%
  618. c | Compute the B-norm of r_{j}. |
  619. c %------------------------------%
  620. c
  621. if (bmat .eq. 'G') then
  622. rnorm = ddot (n, resid, 1, workd(ipj), 1)
  623. rnorm = sqrt(abs(rnorm))
  624. else if (bmat .eq. 'I') then
  625. rnorm = dnrm2(n, resid, 1)
  626. end if
  627. c
  628. c %-----------------------------------------------------------%
  629. c | STEP 5: Re-orthogonalization / Iterative refinement phase |
  630. c | Maximum NITER_ITREF tries. |
  631. c | |
  632. c | s = V_{j}^T * B * r_{j} |
  633. c | r_{j} = r_{j} - V_{j}*s |
  634. c | alphaj = alphaj + s_{j} |
  635. c | |
  636. c | The stopping criteria used for iterative refinement is |
  637. c | discussed in Parlett's book SEP, page 107 and in Gragg & |
  638. c | Reichel ACM TOMS paper; Algorithm 686, Dec. 1990. |
  639. c | Determine if we need to correct the residual. The goal is |
  640. c | to enforce ||v(:,1:j)^T * r_{j}|| .le. eps * || r_{j} || |
  641. c | The following test determines whether the sine of the |
  642. c | angle between OP*x and the computed residual is less |
  643. c | than or equal to 0.717. |
  644. c %-----------------------------------------------------------%
  645. c
  646. if (rnorm .gt. 0.717*wnorm) go to 100
  647. iter = 0
  648. nrorth = nrorth + 1
  649. c
  650. c %---------------------------------------------------%
  651. c | Enter the Iterative refinement phase. If further |
  652. c | refinement is necessary, loop back here. The loop |
  653. c | variable is ITER. Perform a step of Classical |
  654. c | Gram-Schmidt using all the Arnoldi vectors V_{j} |
  655. c %---------------------------------------------------%
  656. c
  657. 80 continue
  658. c
  659. if (msglvl .gt. 2) then
  660. xtemp(1) = wnorm
  661. xtemp(2) = rnorm
  662. c call dvout (logfil, 2, xtemp, ndigit,
  663. c & '_naitr: re-orthonalization; wnorm and rnorm are')
  664. c call dvout (logfil, j, h(1,j), ndigit,
  665. c & '_naitr: j-th column of H')
  666. end if
  667. c
  668. c %----------------------------------------------------%
  669. c | Compute V_{j}^T * B * r_{j}. |
  670. c | WORKD(IRJ:IRJ+J-1) = v(:,1:J)'*WORKD(IPJ:IPJ+N-1). |
  671. c %----------------------------------------------------%
  672. c
  673. call dgemv ('T', n, j, one, v, ldv, workd(ipj), 1,
  674. & zero, workd(irj), 1)
  675. c
  676. c %---------------------------------------------%
  677. c | Compute the correction to the residual: |
  678. c | r_{j} = r_{j} - V_{j} * WORKD(IRJ:IRJ+J-1). |
  679. c | The correction to H is v(:,1:J)*H(1:J,1:J) |
  680. c | + v(:,1:J)*WORKD(IRJ:IRJ+J-1)*e'_j. |
  681. c %---------------------------------------------%
  682. c
  683. call dgemv ('N', n, j, -one, v, ldv, workd(irj), 1,
  684. & one, resid, 1)
  685. call daxpy (j, one, workd(irj), 1, h(1,j), 1)
  686. c
  687. orth2 = .true.
  688. * call arscnd (t2)
  689. if (bmat .eq. 'G') then
  690. nbx = nbx + 1
  691. call dcopy (n, resid, 1, workd(irj), 1)
  692. ipntr(1) = irj
  693. ipntr(2) = ipj
  694. ido = 2
  695. c
  696. c %-----------------------------------%
  697. c | Exit in order to compute B*r_{j}. |
  698. c | r_{j} is the corrected residual. |
  699. c %-----------------------------------%
  700. c
  701. go to 9000
  702. else if (bmat .eq. 'I') then
  703. call dcopy (n, resid, 1, workd(ipj), 1)
  704. end if
  705. 90 continue
  706. c
  707. c %---------------------------------------------------%
  708. c | Back from reverse communication if ORTH2 = .true. |
  709. c %---------------------------------------------------%
  710. c
  711. if (bmat .eq. 'G') then
  712. * call arscnd (t3)
  713. tmvbx = tmvbx + (t3 - t2)
  714. end if
  715. c
  716. c %-----------------------------------------------------%
  717. c | Compute the B-norm of the corrected residual r_{j}. |
  718. c %-----------------------------------------------------%
  719. c
  720. if (bmat .eq. 'G') then
  721. rnorm1 = ddot (n, resid, 1, workd(ipj), 1)
  722. rnorm1 = sqrt(abs(rnorm1))
  723. else if (bmat .eq. 'I') then
  724. rnorm1 = dnrm2(n, resid, 1)
  725. end if
  726. c
  727. if (msglvl .gt. 0 .and. iter .gt. 0) then
  728. call ivout (logfil, 1, j, ndigit,
  729. & '_naitr: Iterative refinement for Arnoldi residual')
  730. if (msglvl .gt. 2) then
  731. xtemp(1) = rnorm
  732. xtemp(2) = rnorm1
  733. c call dvout (logfil, 2, xtemp, ndigit,
  734. c & '_naitr: iterative refinement ; rnorm and rnorm1 are')
  735. end if
  736. end if
  737. c
  738. c %-----------------------------------------%
  739. c | Determine if we need to perform another |
  740. c | step of re-orthogonalization. |
  741. c %-----------------------------------------%
  742. c
  743. if (rnorm1 .gt. 0.717*rnorm) then
  744. c
  745. c %---------------------------------------%
  746. c | No need for further refinement. |
  747. c | The cosine of the angle between the |
  748. c | corrected residual vector and the old |
  749. c | residual vector is greater than 0.717 |
  750. c | In other words the corrected residual |
  751. c | and the old residual vector share an |
  752. c | angle of less than arcCOS(0.717) |
  753. c %---------------------------------------%
  754. c
  755. rnorm = rnorm1
  756. c
  757. else
  758. c
  759. c %-------------------------------------------%
  760. c | Another step of iterative refinement step |
  761. c %-------------------------------------------%
  762. c
  763. nitref = nitref + 1
  764. rnorm = rnorm1
  765. iter = iter + 1
  766. if (iter .le. 1) go to 80
  767. c
  768. c %-------------------------------------------------%
  769. c | Otherwise RESID is numerically in the span of V |
  770. c %-------------------------------------------------%
  771. c
  772. do 95 jj = 1, n
  773. resid(jj) = zero
  774. 95 continue
  775. rnorm = zero
  776. end if
  777. c
  778. c %----------------------------------------------%
  779. c | Branch here directly if iterative refinement |
  780. c | wasn't necessary or after at most NITER_REF |
  781. c | steps of iterative refinement. |
  782. c %----------------------------------------------%
  783. c
  784. 100 continue
  785. c
  786. rstart = .false.
  787. orth2 = .false.
  788. c
  789. * call arscnd (t5)
  790. titref = titref + (t5 - t4)
  791. c
  792. c %------------------------------------%
  793. c | STEP 6: Update j = j+1; Continue |
  794. c %------------------------------------%
  795. c
  796. j = j + 1
  797. if (j .gt. k+np) then
  798. * call arscnd (t1)
  799. tnaitr = tnaitr + (t1 - t0)
  800. ido = 99
  801. do 110 i = max(1,k), k+np-1
  802. c
  803. c %--------------------------------------------%
  804. c | Check for splitting and deflation. |
  805. c | Use a standard test as in the QR algorithm |
  806. c | REFERENCE: LAPACK subroutine dlahqr |
  807. c %--------------------------------------------%
  808. c
  809. tst1 = abs( h( i, i ) ) + abs( h( i+1, i+1 ) )
  810. if( tst1.eq.zero )
  811. & tst1 = dlanhs( '1', k+np, h, ldh, workd(n+1) )
  812. if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) )
  813. & h(i+1,i) = zero
  814. 110 continue
  815. c
  816. if (msglvl .gt. 2) then
  817. call dmout (logfil, k+np, k+np, h, ldh, ndigit,
  818. & '_naitr: Final upper Hessenberg matrix H of order K+NP')
  819. end if
  820. c
  821. go to 9000
  822. end if
  823. c
  824. c %--------------------------------------------------------%
  825. c | Loop back to extend the factorization by another step. |
  826. c %--------------------------------------------------------%
  827. c
  828. go to 1000
  829. c
  830. c %---------------------------------------------------------------%
  831. c | |
  832. c | E N D O F M A I N I T E R A T I O N L O O P |
  833. c | |
  834. c %---------------------------------------------------------------%
  835. c
  836. 9000 continue
  837. return
  838. c
  839. c %---------------%
  840. c | End of dnaitr |
  841. c %---------------%
  842. c
  843. end
  844.  
  845.  
  846.  
  847.  

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