Debian Codegraph @

Modules/ThirdParty/VNL/src/vxl/v3p/netlib/arpack/dseupd.f

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