Debian Codegraph @

debian/external_deps/fetk/punc/src/arpack/src_f77/sseupd.f

raw
1 c\BeginDoc
2 c
3 c\Name: sseupd
4 c
5 c\Description:
6 c
7 c This subroutine returns the converged approximations to eigenvalues
8 c of A*z = lambda*B*z and (optionally):
9 c
10 c (1) the corresponding approximate eigenvectors,
11 c
12 c (2) an orthonormal (Lanczos) basis for the associated approximate
13 c invariant subspace,
14 c
15 c (3) Both.
16 c
17 c There is negligible additional cost to obtain eigenvectors. An orthonormal
18 c (Lanczos) basis is always computed. There is an additional storage cost
19 c of n*nev if both are requested (in this case a separate array Z must be
20 c supplied).
21 c
22 c These quantities are obtained from the Lanczos factorization computed
23 c by SSAUPD for the linear operator OP prescribed by the MODE selection
24 c (see IPARAM(7) in SSAUPD documentation.) SSAUPD must be called before
25 c this routine is called. These approximate eigenvalues and vectors are
26 c commonly called Ritz values and Ritz vectors respectively. They are
27 c referred to as such in the comments that follow. The computed orthonormal
28 c basis for the invariant subspace corresponding to these Ritz values is
29 c referred to as a Lanczos basis.
30 c
31 c See documentation in the header of the subroutine SSAUPD for a definition
32 c of OP as well as other terms and the relation of computed Ritz values
33 c and vectors of OP with respect to the given problem A*z = lambda*B*z.
34 c
35 c The approximate eigenvalues of the original problem are returned in
36 c ascending algebraic order. The user may elect to call this routine
37 c once for each desired Ritz vector and store it peripherally if desired.
38 c There is also the option of computing a selected set of these vectors
39 c with a single call.
40 c
41 c\Usage:
42 c call sseupd
43 c ( RVEC, HOWMNY, SELECT, D, Z, LDZ, SIGMA, BMAT, N, WHICH, NEV, TOL,
44 c RESID, NCV, V, LDV, IPARAM, IPNTR, WORKD, WORKL, LWORKL, INFO )
45 c
46 c RVEC LOGICAL (INPUT)
47 c Specifies whether Ritz vectors corresponding to the Ritz value
48 c approximations to the eigenproblem A*z = lambda*B*z are computed.
49 c
50 c RVEC = .FALSE. Compute Ritz values only.
51 c
52 c RVEC = .TRUE. Compute Ritz vectors.
53 c
54 c HOWMNY Character*1 (INPUT)
55 c Specifies how many Ritz vectors are wanted and the form of Z
56 c the matrix of Ritz vectors. See remark 1 below.
57 c = 'A': compute NEV Ritz vectors;
58 c = 'S': compute some of the Ritz vectors, specified
59 c by the logical array SELECT.
60 c
61 c SELECT Logical array of dimension NCV. (INPUT/WORKSPACE)
62 c If HOWMNY = 'S', SELECT specifies the Ritz vectors to be
63 c computed. To select the Ritz vector corresponding to a
64 c Ritz value D(j), SELECT(j) must be set to .TRUE..
65 c If HOWMNY = 'A' , SELECT is used as a workspace for
66 c reordering the Ritz values.
67 c
68 c D Real array of dimension NEV. (OUTPUT)
69 c On exit, D contains the Ritz value approximations to the
70 c eigenvalues of A*z = lambda*B*z. The values are returned
71 c in ascending order. If IPARAM(7) = 3,4,5 then D represents
72 c the Ritz values of OP computed by ssaupd transformed to
73 c those of the original eigensystem A*z = lambda*B*z. If
74 c IPARAM(7) = 1,2 then the Ritz values of OP are the same
75 c as the those of A*z = lambda*B*z.
76 c
77 c Z Real N by NEV array if HOWMNY = 'A'. (OUTPUT)
78 c On exit, Z contains the B-orthonormal Ritz vectors of the
79 c eigensystem A*z = lambda*B*z corresponding to the Ritz
80 c value approximations.
81 c If RVEC = .FALSE. then Z is not referenced.
82 c NOTE: The array Z may be set equal to first NEV columns of the
83 c Arnoldi/Lanczos basis array V computed by SSAUPD.
84 c
85 c LDZ Integer. (INPUT)
86 c The leading dimension of the array Z. If Ritz vectors are
87 c desired, then LDZ .ge. max( 1, N ). In any case, LDZ .ge. 1.
88 c
89 c SIGMA Real (INPUT)
90 c If IPARAM(7) = 3,4,5 represents the shift. Not referenced if
91 c IPARAM(7) = 1 or 2.
92 c
93 c
94 c **** The remaining arguments MUST be the same as for the ****
95 c **** call to SSAUPD that was just completed. ****
96 c
97 c NOTE: The remaining arguments
98 c
99 c BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR,
100 c WORKD, WORKL, LWORKL, INFO
101 c
102 c must be passed directly to SSEUPD following the last call
103 c to SSAUPD. These arguments MUST NOT BE MODIFIED between
104 c the the last call to SSAUPD and the call to SSEUPD.
105 c
106 c Two of these parameters (WORKL, INFO) are also output parameters:
107 c
108 c WORKL Real work array of length LWORKL. (OUTPUT/WORKSPACE)
109 c WORKL(1:4*ncv) contains information obtained in
110 c ssaupd. They are not changed by sseupd.
111 c WORKL(4*ncv+1:ncv*ncv+8*ncv) holds the
112 c untransformed Ritz values, the computed error estimates,
113 c and the associated eigenvector matrix of H.
114 c
115 c Note: IPNTR(8:10) contains the pointer into WORKL for addresses
116 c of the above information computed by sseupd.
117 c -------------------------------------------------------------
118 c IPNTR(8): pointer to the NCV RITZ values of the original system.
119 c IPNTR(9): pointer to the NCV corresponding error bounds.
120 c IPNTR(10): pointer to the NCV by NCV matrix of eigenvectors
121 c of the tridiagonal matrix T. Only referenced by
122 c sseupd if RVEC = .TRUE. See Remarks.
123 c -------------------------------------------------------------
124 c
125 c INFO Integer. (OUTPUT)
126 c Error flag on output.
127 c = 0: Normal exit.
128 c = -1: N must be positive.
129 c = -2: NEV must be positive.
130 c = -3: NCV must be greater than NEV and less than or equal to N.
131 c = -5: WHICH must be one of 'LM', 'SM', 'LA', 'SA' or 'BE'.
132 c = -6: BMAT must be one of 'I' or 'G'.
133 c = -7: Length of private work WORKL array is not sufficient.
134 c = -8: Error return from trid. eigenvalue calculation;
135 c Information error from LAPACK routine ssteqr.
136 c = -9: Starting vector is zero.
137 c = -10: IPARAM(7) must be 1,2,3,4,5.
138 c = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatible.
139 c = -12: NEV and WHICH = 'BE' are incompatible.
140 c = -14: SSAUPD did not find any eigenvalues to sufficient
141 c accuracy.
142 c = -15: HOWMNY must be one of 'A' or 'S' if RVEC = .true.
143 c = -16: HOWMNY = 'S' not yet implemented
144 c = -17: SSEUPD got a different count of the number of converged
145 c Ritz values than SSAUPD got. This indicates the user
146 c probably made an error in passing data from SSAUPD to
147 c SSEUPD or that the data was modified before entering
148 c SSEUPD.
149 c
150 c\BeginLib
151 c
152 c\References:
153 c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
154 c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
155 c pp 357-385.
156 c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
157 c Restarted Arnoldi Iteration", Rice University Technical Report
158 c TR95-13, Department of Computational and Applied Mathematics.
159 c 3. B.N. Parlett, "The Symmetric Eigenvalue Problem". Prentice-Hall,
160 c 1980.
161 c 4. B.N. Parlett, B. Nour-Omid, "Towards a Black Box Lanczos Program",
162 c Computer Physics Communications, 53 (1989), pp 169-179.
163 c 5. B. Nour-Omid, B.N. Parlett, T. Ericson, P.S. Jensen, "How to
164 c Implement the Spectral Transformation", Math. Comp., 48 (1987),
165 c pp 663-673.
166 c 6. R.G. Grimes, J.G. Lewis and H.D. Simon, "A Shifted Block Lanczos
167 c Algorithm for Solving Sparse Symmetric Generalized Eigenproblems",
168 c SIAM J. Matr. Anal. Apps., January (1993).
169 c 7. L. Reichel, W.B. Gragg, "Algorithm 686: FORTRAN Subroutines
170 c for Updating the QR decomposition", ACM TOMS, December 1990,
171 c Volume 16 Number 4, pp 369-377.
172 c
173 c\Remarks
174 c 1. The converged Ritz values are always returned in increasing
175 c (algebraic) order.
176 c
177 c 2. Currently only HOWMNY = 'A' is implemented. It is included at this
178 c stage for the user who wants to incorporate it.
179 c
180 c\Routines called:
181 c ssesrt ARPACK routine that sorts an array X, and applies the
182 c corresponding permutation to a matrix A.
183 c ssortr ssortr ARPACK sorting routine.
184 c ivout ARPACK utility routine that prints integers.
185 c svout ARPACK utility routine that prints vectors.
186 c sgeqr2 LAPACK routine that computes the QR factorization of
187 c a matrix.
188 c slacpy LAPACK matrix copy routine.
189 c slamch LAPACK routine that determines machine constants.
190 c sorm2r LAPACK routine that applies an orthogonal matrix in
191 c factored form.
192 c ssteqr LAPACK routine that computes eigenvalues and eigenvectors
193 c of a tridiagonal matrix.
194 c sger Level 2 BLAS rank one update to a matrix.
195 c scopy Level 1 BLAS that copies one vector to another .
196 c snrm2 Level 1 BLAS that computes the norm of a vector.
197 c sscal Level 1 BLAS that scales a vector.
198 c sswap Level 1 BLAS that swaps the contents of two vectors.
199
200 c\Authors
201 c Danny Sorensen Phuong Vu
202 c Richard Lehoucq CRPC / Rice University
203 c Chao Yang Houston, Texas
204 c Dept. of Computational &
205 c Applied Mathematics
206 c Rice University
207 c Houston, Texas
208 c
209 c\Revision history:
210 c 12/15/93: Version ' 2.1'
211 c
212 c\SCCS Information: @(#)
213 c FILE: seupd.F SID: 2.11 DATE OF SID: 04/10/01 RELEASE: 2
214 c
215 c\EndLib
216 c
217 c-----------------------------------------------------------------------
218 subroutine sseupd(rvec , howmny, select, d ,
219 & z , ldz , sigma , bmat ,
220 & n , which , nev , tol ,
221 & resid , ncv , v , ldv ,
222 & iparam, ipntr , workd , workl,
223 & lworkl, info )
224 c
225 c %----------------------------------------------------%
226 c | Include files for debugging and timing information |
227 c %----------------------------------------------------%
228 c
229 include 'debug.h'
230 include 'stat.h'
231 c
232 c %------------------%
233 c | Scalar Arguments |
234 c %------------------%
235 c
236 character bmat, howmny, which*2
237 logical rvec
238 integer info, ldz, ldv, lworkl, n, ncv, nev
239 Real
240 & sigma, tol
241 c
242 c %-----------------%
243 c | Array Arguments |
244 c %-----------------%
245 c
246 integer iparam(7), ipntr(11)
247 logical select(ncv)
248 Real
249 & d(nev) , resid(n) , v(ldv,ncv),
250 & z(ldz, nev), workd(2*n), workl(lworkl)
251 c
252 c %------------%
253 c | Parameters |
254 c %------------%
255 c
256 Real
257 & one, zero
258 parameter (one = 1.0E+0 , zero = 0.0E+0 )
259 c
260 c %---------------%
261 c | Local Scalars |
262 c %---------------%
263 c
264 character type*6
265 integer bounds , ierr , ih , ihb , ihd ,
266 & iq , iw , j , k , ldh ,
267 & ldq , mode , msglvl, nconv , next ,
268 & ritz , irz , ibd , np , ishift,
269 & leftptr, rghtptr, numcnv, jj
270 Real
271 & bnorm2 , rnorm, temp, temp1, eps23
272 logical reord
273 c
274 c %----------------------%
275 c | External Subroutines |
276 c %----------------------%
277 c
278 external scopy , sger , sgeqr2, slacpy, sorm2r, sscal,
279 & ssesrt, ssteqr, sswap , svout , ivout , ssortr
280 c
281 c %--------------------%
282 c | External Functions |
283 c %--------------------%
284 c
285 Real
286 & snrm2, slamch
287 external snrm2, slamch
288 c
289 c %---------------------%
290 c | Intrinsic Functions |
291 c %---------------------%
292 c
293 intrinsic min
294 c
295 c %-----------------------%
296 c | Executable Statements |
297 c %-----------------------%
298 c
299 c %------------------------%
300 c | Set default parameters |
301 c %------------------------%
302 c
303 msglvl = mseupd
304 mode = iparam(7)
305 nconv = iparam(5)
306 info = 0
307 c
308 c %--------------%
309 c | Quick return |
310 c %--------------%
311 c
312 if (nconv .eq. 0) go to 9000
313 ierr = 0
314 c
315 if (nconv .le. 0) ierr = -14
316 if (n .le. 0) ierr = -1
317 if (nev .le. 0) ierr = -2
318 if (ncv .le. nev .or. ncv .gt. n) ierr = -3
319 if (which .ne. 'LM' .and.
320 & which .ne. 'SM' .and.
321 & which .ne. 'LA' .and.
322 & which .ne. 'SA' .and.
323 & which .ne. 'BE') ierr = -5
324 if (bmat .ne. 'I' .and. bmat .ne. 'G') ierr = -6
325 if ( (howmny .ne. 'A' .and.
326 & howmny .ne. 'P' .and.
327 & howmny .ne. 'S') .and. rvec )
328 & ierr = -15
329 if (rvec .and. howmny .eq. 'S') ierr = -16
330 c
331 if (rvec .and. lworkl .lt. ncv**2+8*ncv) ierr = -7
332 c
333 if (mode .eq. 1 .or. mode .eq. 2) then
334 type = 'REGULR'
335 else if (mode .eq. 3 ) then
336 type = 'SHIFTI'
337 else if (mode .eq. 4 ) then
338 type = 'BUCKLE'
339 else if (mode .eq. 5 ) then
340 type = 'CAYLEY'
341 else
342 ierr = -10
343 end if
344 if (mode .eq. 1 .and. bmat .eq. 'G') ierr = -11
345 if (nev .eq. 1 .and. which .eq. 'BE') ierr = -12
346 c
347 c %------------%
348 c | Error Exit |
349 c %------------%
350 c
351 if (ierr .ne. 0) then
352 info = ierr
353 go to 9000
354 end if
355 c
356 c %-------------------------------------------------------%
357 c | Pointer into WORKL for address of H, RITZ, BOUNDS, Q |
358 c | etc... and the remaining workspace. |
359 c | Also update pointer to be used on output. |
360 c | Memory is laid out as follows: |
361 c | workl(1:2*ncv) := generated tridiagonal matrix H |
362 c | The subdiagonal is stored in workl(2:ncv). |
363 c | The dead spot is workl(1) but upon exiting |
364 c | ssaupd stores the B-norm of the last residual |
365 c | vector in workl(1). We use this !!! |
366 c | workl(2*ncv+1:2*ncv+ncv) := ritz values |
367 c | The wanted values are in the first NCONV spots. |
368 c | workl(3*ncv+1:3*ncv+ncv) := computed Ritz estimates |
369 c | The wanted values are in the first NCONV spots. |
370 c | NOTE: workl(1:4*ncv) is set by ssaupd and is not |
371 c | modified by sseupd. |
372 c %-------------------------------------------------------%
373 c
374 c %-------------------------------------------------------%
375 c | The following is used and set by sseupd. |
376 c | workl(4*ncv+1:4*ncv+ncv) := used as workspace during |
377 c | computation of the eigenvectors of H. Stores |
378 c | the diagonal of H. Upon EXIT contains the NCV |
379 c | Ritz values of the original system. The first |
380 c | NCONV spots have the wanted values. If MODE = |
381 c | 1 or 2 then will equal workl(2*ncv+1:3*ncv). |
382 c | workl(5*ncv+1:5*ncv+ncv) := used as workspace during |
383 c | computation of the eigenvectors of H. Stores |
384 c | the subdiagonal of H. Upon EXIT contains the |
385 c | NCV corresponding Ritz estimates of the |
386 c | original system. The first NCONV spots have the |
387 c | wanted values. If MODE = 1,2 then will equal |
388 c | workl(3*ncv+1:4*ncv). |
389 c | workl(6*ncv+1:6*ncv+ncv*ncv) := orthogonal Q that is |
390 c | the eigenvector matrix for H as returned by |
391 c | ssteqr. Not referenced if RVEC = .False. |
392 c | Ordering follows that of workl(4*ncv+1:5*ncv) |
393 c | workl(6*ncv+ncv*ncv+1:6*ncv+ncv*ncv+2*ncv) := |
394 c | Workspace. Needed by ssteqr and by sseupd. |
395 c | GRAND total of NCV*(NCV+8) locations. |
396 c %-------------------------------------------------------%
397 c
398 c
399 ih = ipntr(5)
400 ritz = ipntr(6)
401 bounds = ipntr(7)
402 ldh = ncv
403 ldq = ncv
404 ihd = bounds + ldh
405 ihb = ihd + ldh
406 iq = ihb + ldh
407 iw = iq + ldh*ncv
408 next = iw + 2*ncv
409 ipntr(4) = next
410 ipntr(8) = ihd
411 ipntr(9) = ihb
412 ipntr(10) = iq
413 c
414 c %----------------------------------------%
415 c | irz points to the Ritz values computed |
416 c | by _seigt before exiting _saup2. |
417 c | ibd points to the Ritz estimates |
418 c | computed by _seigt before exiting |
419 c | _saup2. |
420 c %----------------------------------------%
421 c
422 irz = ipntr(11)+ncv
423 ibd = irz+ncv
424 c
425 c
426 c %---------------------------------%
427 c | Set machine dependent constant. |
428 c %---------------------------------%
429 c
430 eps23 = slamch('Epsilon-Machine')
431 eps23 = eps23**(2.0E+0 / 3.0E+0 )
432 c
433 c %---------------------------------------%
434 c | RNORM is B-norm of the RESID(1:N). |
435 c | BNORM2 is the 2 norm of B*RESID(1:N). |
436 c | Upon exit of ssaupd WORKD(1:N) has |
437 c | B*RESID(1:N). |
438 c %---------------------------------------%
439 c
440 rnorm = workl(ih)
441 if (bmat .eq. 'I') then
442 bnorm2 = rnorm
443 else if (bmat .eq. 'G') then
444 bnorm2 = snrm2(n, workd, 1)
445 end if
446 c
447 if (msglvl .gt. 2) then
448 call svout(logfil, ncv, workl(irz), ndigit,
449 & '_seupd: Ritz values passed in from _SAUPD.')
450 call svout(logfil, ncv, workl(ibd), ndigit,
451 & '_seupd: Ritz estimates passed in from _SAUPD.')
452 end if
453 c
454 if (rvec) then
455 c
456 reord = .false.
457 c
458 c %---------------------------------------------------%
459 c | Use the temporary bounds array to store indices |
460 c | These will be used to mark the select array later |
461 c %---------------------------------------------------%
462 c
463 do 10 j = 1,ncv
464 workl(bounds+j-1) = j
465 select(j) = .false.
466 10 continue
467 c
468 c %-------------------------------------%
469 c | Select the wanted Ritz values. |
470 c | Sort the Ritz values so that the |
471 c | wanted ones appear at the tailing |
472 c | NEV positions of workl(irr) and |
473 c | workl(iri). Move the corresponding |
474 c | error estimates in workl(bound) |
475 c | accordingly. |
476 c %-------------------------------------%
477 c
478 np = ncv - nev
479 ishift = 0
480 call ssgets(ishift, which , nev ,
481 & np , workl(irz) , workl(bounds),
482 & workl)
483 c
484 if (msglvl .gt. 2) then
485 call svout(logfil, ncv, workl(irz), ndigit,
486 & '_seupd: Ritz values after calling _SGETS.')
487 call svout(logfil, ncv, workl(bounds), ndigit,
488 & '_seupd: Ritz value indices after calling _SGETS.')
489 end if
490 c
491 c %-----------------------------------------------------%
492 c | Record indices of the converged wanted Ritz values |
493 c | Mark the select array for possible reordering |
494 c %-----------------------------------------------------%
495 c
496 numcnv = 0
497 do 11 j = 1,ncv
498 temp1 = max(eps23, abs(workl(irz+ncv-j)) )
499 jj = workl(bounds + ncv - j)
500 if (numcnv .lt. nconv .and.
501 & workl(ibd+jj-1) .le. tol*temp1) then
502 select(jj) = .true.
503 numcnv = numcnv + 1
504 if (jj .gt. nev) reord = .true.
505 endif
506 11 continue
507 c
508 c %-----------------------------------------------------------%
509 c | Check the count (numcnv) of converged Ritz values with |
510 c | the number (nconv) reported by _saupd. If these two |
511 c | are different then there has probably been an error |
512 c | caused by incorrect passing of the _saupd data. |
513 c %-----------------------------------------------------------%
514 c
515 if (msglvl .gt. 2) then
516 call ivout(logfil, 1, numcnv, ndigit,
517 & '_seupd: Number of specified eigenvalues')
518 call ivout(logfil, 1, nconv, ndigit,
519 & '_seupd: Number of "converged" eigenvalues')
520 end if
521 c
522 if (numcnv .ne. nconv) then
523 info = -17
524 go to 9000
525 end if
526 c
527 c %-----------------------------------------------------------%
528 c | Call LAPACK routine _steqr to compute the eigenvalues and |
529 c | eigenvectors of the final symmetric tridiagonal matrix H. |
530 c | Initialize the eigenvector matrix Q to the identity. |
531 c %-----------------------------------------------------------%
532 c
533 call scopy(ncv-1, workl(ih+1), 1, workl(ihb), 1)
534 call scopy(ncv, workl(ih+ldh), 1, workl(ihd), 1)
535 c
536 call ssteqr('Identity', ncv, workl(ihd), workl(ihb),
537 & workl(iq) , ldq, workl(iw), ierr)
538 c
539 if (ierr .ne. 0) then
540 info = -8
541 go to 9000
542 end if
543 c
544 if (msglvl .gt. 1) then
545 call scopy(ncv, workl(iq+ncv-1), ldq, workl(iw), 1)
546 call svout(logfil, ncv, workl(ihd), ndigit,
547 & '_seupd: NCV Ritz values of the final H matrix')
548 call svout(logfil, ncv, workl(iw), ndigit,
549 & '_seupd: last row of the eigenvector matrix for H')
550 end if
551 c
552 if (reord) then
553 c
554 c %---------------------------------------------%
555 c | Reordered the eigenvalues and eigenvectors |
556 c | computed by _steqr so that the "converged" |
557 c | eigenvalues appear in the first NCONV |
558 c | positions of workl(ihd), and the associated |
559 c | eigenvectors appear in the first NCONV |
560 c | columns. |
561 c %---------------------------------------------%
562 c
563 leftptr = 1
564 rghtptr = ncv
565 c
566 if (ncv .eq. 1) go to 30
567 c
568 20 if (select(leftptr)) then
569 c
570 c %-------------------------------------------%
571 c | Search, from the left, for the first Ritz |
572 c | value that has not converged. |
573 c %-------------------------------------------%
574 c
575 leftptr = leftptr + 1
576 c
577 else if ( .not. select(rghtptr)) then
578 c
579 c %----------------------------------------------%
580 c | Search, from the right, the first Ritz value |
581 c | that has converged. |
582 c %----------------------------------------------%
583 c
584 rghtptr = rghtptr - 1
585 c
586 else
587 c
588 c %----------------------------------------------%
589 c | Swap the Ritz value on the left that has not |
590 c | converged with the Ritz value on the right |
591 c | that has converged. Swap the associated |
592 c | eigenvector of the tridiagonal matrix H as |
593 c | well. |
594 c %----------------------------------------------%
595 c
596 temp = workl(ihd+leftptr-1)
597 workl(ihd+leftptr-1) = workl(ihd+rghtptr-1)
598 workl(ihd+rghtptr-1) = temp
599 call scopy(ncv, workl(iq+ncv*(leftptr-1)), 1,
600 & workl(iw), 1)
601 call scopy(ncv, workl(iq+ncv*(rghtptr-1)), 1,
602 & workl(iq+ncv*(leftptr-1)), 1)
603 call scopy(ncv, workl(iw), 1,
604 & workl(iq+ncv*(rghtptr-1)), 1)
605 leftptr = leftptr + 1
606 rghtptr = rghtptr - 1
607 c
608 end if
609 c
610 if (leftptr .lt. rghtptr) go to 20
611 c
612 30 end if
613 c
614 if (msglvl .gt. 2) then
615 call svout (logfil, ncv, workl(ihd), ndigit,
616 & '_seupd: The eigenvalues of H--reordered')
617 end if
618 c
619 c %----------------------------------------%
620 c | Load the converged Ritz values into D. |
621 c %----------------------------------------%
622 c
623 call scopy(nconv, workl(ihd), 1, d, 1)
624 c
625 else
626 c
627 c %-----------------------------------------------------%
628 c | Ritz vectors not required. Load Ritz values into D. |
629 c %-----------------------------------------------------%
630 c
631 call scopy(nconv, workl(ritz), 1, d, 1)
632 call scopy(ncv, workl(ritz), 1, workl(ihd), 1)
633 c
634 end if
635 c
636 c %------------------------------------------------------------------%
637 c | Transform the Ritz values and possibly vectors and corresponding |
638 c | Ritz estimates of OP to those of A*x=lambda*B*x. The Ritz values |
639 c | (and corresponding data) are returned in ascending order. |
640 c %------------------------------------------------------------------%
641 c
642 if (type .eq. 'REGULR') then
643 c
644 c %---------------------------------------------------------%
645 c | Ascending sort of wanted Ritz values, vectors and error |
646 c | bounds. Not necessary if only Ritz values are desired. |
647 c %---------------------------------------------------------%
648 c
649 if (rvec) then
650 call ssesrt('LA', rvec , nconv, d, ncv, workl(iq), ldq)
651 else
652 call scopy(ncv, workl(bounds), 1, workl(ihb), 1)
653 end if
654 c
655 else
656 c
657 c %-------------------------------------------------------------%
658 c | * Make a copy of all the Ritz values. |
659 c | * Transform the Ritz values back to the original system. |
660 c | For TYPE = 'SHIFTI' the transformation is |
661 c | lambda = 1/theta + sigma |
662 c | For TYPE = 'BUCKLE' the transformation is |
663 c | lambda = sigma * theta / ( theta - 1 ) |
664 c | For TYPE = 'CAYLEY' the transformation is |
665 c | lambda = sigma * (theta + 1) / (theta - 1 ) |
666 c | where the theta are the Ritz values returned by ssaupd. |
667 c | NOTES: |
668 c | *The Ritz vectors are not affected by the transformation. |
669 c | They are only reordered. |
670 c %-------------------------------------------------------------%
671 c
672 call scopy (ncv, workl(ihd), 1, workl(iw), 1)
673 if (type .eq. 'SHIFTI') then
674 do 40 k=1, ncv
675 workl(ihd+k-1) = one / workl(ihd+k-1) + sigma
676 40 continue
677 else if (type .eq. 'BUCKLE') then
678 do 50 k=1, ncv
679 workl(ihd+k-1) = sigma * workl(ihd+k-1) /
680 & (workl(ihd+k-1) - one)
681 50 continue
682 else if (type .eq. 'CAYLEY') then
683 do 60 k=1, ncv
684 workl(ihd+k-1) = sigma * (workl(ihd+k-1) + one) /
685 & (workl(ihd+k-1) - one)
686 60 continue
687 end if
688 c
689 c %-------------------------------------------------------------%
690 c | * Store the wanted NCONV lambda values into D. |
691 c | * Sort the NCONV wanted lambda in WORKL(IHD:IHD+NCONV-1) |
692 c | into ascending order and apply sort to the NCONV theta |
693 c | values in the transformed system. We will need this to |
694 c | compute Ritz estimates in the original system. |
695 c | * Finally sort the lambda`s into ascending order and apply |
696 c | to Ritz vectors if wanted. Else just sort lambda`s into |
697 c | ascending order. |
698 c | NOTES: |
699 c | *workl(iw:iw+ncv-1) contain the theta ordered so that they |
700 c | match the ordering of the lambda. We`ll use them again for |
701 c | Ritz vector purification. |
702 c %-------------------------------------------------------------%
703 c
704 call scopy(nconv, workl(ihd), 1, d, 1)
705 call ssortr('LA', .true., nconv, workl(ihd), workl(iw))
706 if (rvec) then
707 call ssesrt('LA', rvec , nconv, d, ncv, workl(iq), ldq)
708 else
709 call scopy(ncv, workl(bounds), 1, workl(ihb), 1)
710 call sscal(ncv, bnorm2/rnorm, workl(ihb), 1)
711 call ssortr('LA', .true., nconv, d, workl(ihb))
712 end if
713 c
714 end if
715 c
716 c %------------------------------------------------%
717 c | Compute the Ritz vectors. Transform the wanted |
718 c | eigenvectors of the symmetric tridiagonal H by |
719 c | the Lanczos basis matrix V. |
720 c %------------------------------------------------%
721 c
722 if (rvec .and. howmny .eq. 'A') then
723 c
724 c %----------------------------------------------------------%
725 c | Compute the QR factorization of the matrix representing |
726 c | the wanted invariant subspace located in the first NCONV |
727 c | columns of workl(iq,ldq). |
728 c %----------------------------------------------------------%
729 c
730 call sgeqr2(ncv, nconv , workl(iq) ,
731 & ldq, workl(iw+ncv), workl(ihb),
732 & ierr)
733 c
734 c %--------------------------------------------------------%
735 c | * Postmultiply V by Q. |
736 c | * Copy the first NCONV columns of VQ into Z. |
737 c | The N by NCONV matrix Z is now a matrix representation |
738 c | of the approximate invariant subspace associated with |
739 c | the Ritz values in workl(ihd). |
740 c %--------------------------------------------------------%
741 c
742 call sorm2r('Right', 'Notranspose', n ,
743 & ncv , nconv , workl(iq),
744 & ldq , workl(iw+ncv), v ,
745 & ldv , workd(n+1) , ierr)
746 call slacpy('All', n, nconv, v, ldv, z, ldz)
747 c
748 c %-----------------------------------------------------%
749 c | In order to compute the Ritz estimates for the Ritz |
750 c | values in both systems, need the last row of the |
751 c | eigenvector matrix. Remember, it`s in factored form |
752 c %-----------------------------------------------------%
753 c
754 do 65 j = 1, ncv-1
755 workl(ihb+j-1) = zero
756 65 continue
757 workl(ihb+ncv-1) = one
758 call sorm2r('Left', 'Transpose' , ncv ,
759 & 1 , nconv , workl(iq) ,
760 & ldq , workl(iw+ncv), workl(ihb),
761 & ncv , temp , ierr)
762 c
763 else if (rvec .and. howmny .eq. 'S') then
764 c
765 c Not yet implemented. See remark 2 above.
766 c
767 end if
768 c
769 if (type .eq. 'REGULR' .and. rvec) then
770 c
771 do 70 j=1, ncv
772 workl(ihb+j-1) = rnorm * abs( workl(ihb+j-1) )
773 70 continue
774 c
775 else if (type .ne. 'REGULR' .and. rvec) then
776 c
777 c %-------------------------------------------------%
778 c | * Determine Ritz estimates of the theta. |
779 c | If RVEC = .true. then compute Ritz estimates |
780 c | of the theta. |
781 c | If RVEC = .false. then copy Ritz estimates |
782 c | as computed by ssaupd. |
783 c | * Determine Ritz estimates of the lambda. |
784 c %-------------------------------------------------%
785 c
786 call sscal (ncv, bnorm2, workl(ihb), 1)
787 if (type .eq. 'SHIFTI') then
788 c
789 do 80 k=1, ncv
790 workl(ihb+k-1) = abs( workl(ihb+k-1) )
791 & / workl(iw+k-1)**2
792 80 continue
793 c
794 else if (type .eq. 'BUCKLE') then
795 c
796 do 90 k=1, ncv
797 workl(ihb+k-1) = sigma * abs( workl(ihb+k-1) )
798 & / (workl(iw+k-1)-one )**2
799 90 continue
800 c
801 else if (type .eq. 'CAYLEY') then
802 c
803 do 100 k=1, ncv
804 workl(ihb+k-1) = abs( workl(ihb+k-1)
805 & / workl(iw+k-1)*(workl(iw+k-1)-one) )
806 100 continue
807 c
808 end if
809 c
810 end if
811 c
812 if (type .ne. 'REGULR' .and. msglvl .gt. 1) then
813 call svout(logfil, nconv, d, ndigit,
814 & '_seupd: Untransformed converged Ritz values')
815 call svout(logfil, nconv, workl(ihb), ndigit,
816 & '_seupd: Ritz estimates of the untransformed Ritz values')
817 else if (msglvl .gt. 1) then
818 call svout(logfil, nconv, d, ndigit,
819 & '_seupd: Converged Ritz values')
820 call svout(logfil, nconv, workl(ihb), ndigit,
821 & '_seupd: Associated Ritz estimates')
822 end if
823 c
824 c %-------------------------------------------------%
825 c | Ritz vector purification step. Formally perform |
826 c | one of inverse subspace iteration. Only used |
827 c | for MODE = 3,4,5. See reference 7 |
828 c %-------------------------------------------------%
829 c
830 if (rvec .and. (type .eq. 'SHIFTI' .or. type .eq. 'CAYLEY')) then
831 c
832 do 110 k=0, nconv-1
833 workl(iw+k) = workl(iq+k*ldq+ncv-1)
834 & / workl(iw+k)
835 110 continue
836 c
837 else if (rvec .and. type .eq. 'BUCKLE') then
838 c
839 do 120 k=0, nconv-1
840 workl(iw+k) = workl(iq+k*ldq+ncv-1)
841 & / (workl(iw+k)-one)
842 120 continue
843 c
844 end if
845 c
846 if (type .ne. 'REGULR')
847 & call sger (n, nconv, one, resid, 1, workl(iw), 1, z, ldz)
848 c
849 9000 continue
850 c
851 return
852 c
853 c %---------------%
854 c | End of sseupd|
855 c %---------------%
856 c
857 end