Télécharger dsaitr.eso

Retour à la liste

Numérotation des lignes :

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

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