Debian Codegraph @

debian/external_deps/fetk/punc/src/arpack/sseupd.c

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