Télécharger dsaitr.eso

Retour à la liste

Numérotation des lignes :

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

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