Debian Codegraph @

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

raw
1 /* ./src_f77/dnaup2.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_DNAUP2;
15
16 #define debug_1 debug_DNAUP2
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_DNAUP2;
25
26 #define timing_1 timing_DNAUP2
27
28 /* Table of constant values */
29
30 static doublereal c_b3 = .66666666666666663;
31 static integer c__1 = 1;
32 static integer c__0 = 0;
33 static integer c__4 = 4;
34 static logical c_true = TRUE_;
35 static integer c__2 = 2;
36
37 /* \BeginDoc */
38
39 /* \Name: dnaup2 */
40
41 /* \Description: */
42 /* Intermediate level interface called by dnaupd. */
43
44 /* \Usage: */
45 /* call dnaup2 */
46 /* ( IDO, BMAT, N, WHICH, NEV, NP, TOL, RESID, MODE, IUPD, */
47 /* ISHIFT, MXITER, V, LDV, H, LDH, RITZR, RITZI, BOUNDS, */
48 /* Q, LDQ, WORKL, IPNTR, WORKD, INFO ) */
49
50 /* \Arguments */
51
52 /* IDO, BMAT, N, WHICH, NEV, TOL, RESID: same as defined in dnaupd. */
53 /* MODE, ISHIFT, MXITER: see the definition of IPARAM in dnaupd. */
54
55 /* NP Integer. (INPUT/OUTPUT) */
56 /* Contains the number of implicit shifts to apply during */
57 /* each Arnoldi iteration. */
58 /* If ISHIFT=1, NP is adjusted dynamically at each iteration */
59 /* to accelerate convergence and prevent stagnation. */
60 /* This is also roughly equal to the number of matrix-vector */
61 /* products (involving the operator OP) per Arnoldi iteration. */
62 /* The logic for adjusting is contained within the current */
63 /* subroutine. */
64 /* If ISHIFT=0, NP is the number of shifts the user needs */
65 /* to provide via reverse comunication. 0 < NP < NCV-NEV. */
66 /* NP may be less than NCV-NEV for two reasons. The first, is */
67 /* to keep complex conjugate pairs of "wanted" Ritz values */
68 /* together. The second, is that a leading block of the current */
69 /* upper Hessenberg matrix has split off and contains "unwanted" */
70 /* Ritz values. */
71 /* Upon termination of the IRA iteration, NP contains the number */
72 /* of "converged" wanted Ritz values. */
73
74 /* IUPD Integer. (INPUT) */
75 /* IUPD .EQ. 0: use explicit restart instead implicit update. */
76 /* IUPD .NE. 0: use implicit update. */
77
78 /* V Double precision N by (NEV+NP) array. (INPUT/OUTPUT) */
79 /* The Arnoldi basis vectors are returned in the first NEV */
80 /* columns of V. */
81
82 /* LDV Integer. (INPUT) */
83 /* Leading dimension of V exactly as declared in the calling */
84 /* program. */
85
86 /* H Double precision (NEV+NP) by (NEV+NP) array. (OUTPUT) */
87 /* H is used to store the generated upper Hessenberg matrix */
88
89 /* LDH Integer. (INPUT) */
90 /* Leading dimension of H exactly as declared in the calling */
91 /* program. */
92
93 /* RITZR, Double precision arrays of length NEV+NP. (OUTPUT) */
94 /* RITZI RITZR(1:NEV) (resp. RITZI(1:NEV)) contains the real (resp. */
95 /* imaginary) part of the computed Ritz values of OP. */
96
97 /* BOUNDS Double precision array of length NEV+NP. (OUTPUT) */
98 /* BOUNDS(1:NEV) contain the error bounds corresponding to */
99 /* the computed Ritz values. */
100
101 /* Q Double precision (NEV+NP) by (NEV+NP) array. (WORKSPACE) */
102 /* Private (replicated) work array used to accumulate the */
103 /* rotation in the shift application step. */
104
105 /* LDQ Integer. (INPUT) */
106 /* Leading dimension of Q exactly as declared in the calling */
107 /* program. */
108
109 /* WORKL Double precision work array of length at least */
110 /* (NEV+NP)**2 + 3*(NEV+NP). (INPUT/WORKSPACE) */
111 /* Private (replicated) array on each PE or array allocated on */
112 /* the front end. It is used in shifts calculation, shifts */
113 /* application and convergence checking. */
114
115 /* On exit, the last 3*(NEV+NP) locations of WORKL contain */
116 /* the Ritz values (real,imaginary) and associated Ritz */
117 /* estimates of the current Hessenberg matrix. They are */
118 /* listed in the same order as returned from dneigh. */
119
120 /* If ISHIFT .EQ. O and IDO .EQ. 3, the first 2*NP locations */
121 /* of WORKL are used in reverse communication to hold the user */
122 /* supplied shifts. */
123
124 /* IPNTR Integer array of length 3. (OUTPUT) */
125 /* Pointer to mark the starting locations in the WORKD for */
126 /* vectors used by the Arnoldi iteration. */
127 /* ------------------------------------------------------------- */
128 /* IPNTR(1): pointer to the current operand vector X. */
129 /* IPNTR(2): pointer to the current result vector Y. */
130 /* IPNTR(3): pointer to the vector B * X when used in the */
131 /* shift-and-invert mode. X is the current operand. */
132 /* ------------------------------------------------------------- */
133
134 /* WORKD Double precision work array of length 3*N. (WORKSPACE) */
135 /* Distributed array to be used in the basic Arnoldi iteration */
136 /* for reverse communication. The user should not use WORKD */
137 /* as temporary workspace during the iteration !!!!!!!!!! */
138 /* See Data Distribution Note in DNAUPD. */
139
140 /* INFO Integer. (INPUT/OUTPUT) */
141 /* If INFO .EQ. 0, a randomly initial residual vector is used. */
142 /* If INFO .NE. 0, RESID contains the initial residual vector, */
143 /* possibly from a previous run. */
144 /* Error flag on output. */
145 /* = 0: Normal return. */
146 /* = 1: Maximum number of iterations taken. */
147 /* All possible eigenvalues of OP has been found. */
148 /* NP returns the number of converged Ritz values. */
149 /* = 2: No shifts could be applied. */
150 /* = -8: Error return from LAPACK eigenvalue calculation; */
151 /* This should never happen. */
152 /* = -9: Starting vector is zero. */
153 /* = -9999: Could not build an Arnoldi factorization. */
154 /* Size that was built in returned in NP. */
155
156 /* \EndDoc */
157
158 /* ----------------------------------------------------------------------- */
159
160 /* \BeginLib */
161
162 /* \Local variables: */
163 /* xxxxxx real */
164
165 /* \References: */
166 /* 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in */
167 /* a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), */
168 /* pp 357-385. */
169 /* 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly */
170 /* Restarted Arnoldi Iteration", Rice University Technical Report */
171 /* TR95-13, Department of Computational and Applied Mathematics. */
172
173 /* \Routines called: */
174 /* dgetv0 ARPACK initial vector generation routine. */
175 /* dnaitr ARPACK Arnoldi factorization routine. */
176 /* dnapps ARPACK application of implicit shifts routine. */
177 /* dnconv ARPACK convergence of Ritz values routine. */
178 /* dneigh ARPACK compute Ritz values and error bounds routine. */
179 /* dngets ARPACK reorder Ritz values and error bounds routine. */
180 /* dsortc ARPACK sorting routine. */
181 /* ivout ARPACK utility routine that prints integers. */
182 /* second ARPACK utility routine for timing. */
183 /* dmout ARPACK utility routine that prints matrices */
184 /* dvout ARPACK utility routine that prints vectors. */
185 /* dlamch LAPACK routine that determines machine constants. */
186 /* dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */
187 /* dcopy Level 1 BLAS that copies one vector to another . */
188 /* ddot Level 1 BLAS that computes the scalar product of two vectors. */
189 /* dnrm2 Level 1 BLAS that computes the norm of a vector. */
190 /* dswap Level 1 BLAS that swaps two vectors. */
191
192 /* \Author */
193 /* Danny Sorensen Phuong Vu */
194 /* Richard Lehoucq CRPC / Rice University */
195 /* Dept. of Computational & Houston, Texas */
196 /* Applied Mathematics */
197 /* Rice University */
198 /* Houston, Texas */
199
200 /* \SCCS Information: @(#) */
201 /* FILE: naup2.F SID: 2.8 DATE OF SID: 10/17/00 RELEASE: 2 */
202
203 /* \Remarks */
204 /* 1. None */
205
206 /* \EndLib */
207
208 /* ----------------------------------------------------------------------- */
209
210 /* Subroutine */ int dnaup2_(integer *ido, char *bmat, integer *n, char *
211 which, integer *nev, integer *np, doublereal *tol, doublereal *resid,
212 integer *mode, integer *iupd, integer *ishift, integer *mxiter,
213 doublereal *v, integer *ldv, doublereal *h__, integer *ldh,
214 doublereal *ritzr, doublereal *ritzi, doublereal *bounds, doublereal *
215 q, integer *ldq, doublereal *workl, integer *ipntr, doublereal *workd,
216 integer *info, ftnlen bmat_len, ftnlen which_len)
217 {
218 /* System generated locals */
219 integer h_dim1, h_offset, q_dim1, q_offset, v_dim1, v_offset, i__1, i__2;
220 doublereal d__1, d__2;
221
222 /* Builtin functions */
223 double pow_dd(doublereal *, doublereal *);
224 integer s_cmp(char *, char *, ftnlen, ftnlen);
225 /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
226 double sqrt(doublereal);
227
228 /* Local variables */
229 static integer j;
230 static real t0, t1, t2, t3;
231 static integer kp[4], np0, nev0;
232 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
233 integer *);
234 static doublereal eps23;
235 static integer ierr, iter;
236 static doublereal temp;
237 extern doublereal dnrm2_(integer *, doublereal *, integer *);
238 static logical getv0, cnorm;
239 extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *,
240 doublereal *, integer *);
241 static integer nconv;
242 extern /* Subroutine */ int dmout_(integer *, integer *, integer *,
243 doublereal *, integer *, integer *, char *, ftnlen);
244 static logical initv;
245 static doublereal rnorm;
246 extern /* Subroutine */ int dvout_(integer *, integer *, doublereal *,
247 integer *, char *, ftnlen), ivout_(integer *, integer *, integer *
248 , integer *, char *, ftnlen), dgetv0_(integer *, char *, integer *
249 , logical *, integer *, integer *, doublereal *, integer *,
250 doublereal *, doublereal *, integer *, doublereal *, integer *,
251 ftnlen);
252 extern doublereal dlapy2_(doublereal *, doublereal *), dlamch_(char *,
253 ftnlen);
254 extern /* Subroutine */ int dneigh_(doublereal *, integer *, doublereal *,
255 integer *, doublereal *, doublereal *, doublereal *, doublereal *
256 , integer *, doublereal *, integer *);
257 static integer nevbef;
258 extern /* Subroutine */ int second_(real *);
259 static logical update;
260 static char wprime[2];
261 static logical ushift;
262 static integer kplusp, msglvl, nptemp, numcnv;
263 extern /* Subroutine */ int dnaitr_(integer *, char *, integer *, integer
264 *, integer *, integer *, doublereal *, doublereal *, doublereal *,
265 integer *, doublereal *, integer *, integer *, doublereal *,
266 integer *, ftnlen), dnconv_(integer *, doublereal *, doublereal *,
267 doublereal *, doublereal *, integer *), dngets_(integer *, char *
268 , integer *, integer *, doublereal *, doublereal *, doublereal *,
269 doublereal *, doublereal *, ftnlen), dnapps_(integer *, integer *,
270 integer *, doublereal *, doublereal *, doublereal *, integer *,
271 doublereal *, integer *, doublereal *, doublereal *, integer *,
272 doublereal *, doublereal *), dsortc_(char *, logical *, integer *,
273 doublereal *, doublereal *, doublereal *, ftnlen);
274
275
276 /* %----------------------------------------------------% */
277 /* | Include files for debugging and timing information | */
278 /* %----------------------------------------------------% */
279
280
281 /* \SCCS Information: @(#) */
282 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
283
284 /* %---------------------------------% */
285 /* | See debug.doc for documentation | */
286 /* %---------------------------------% */
287
288 /* %------------------% */
289 /* | Scalar Arguments | */
290 /* %------------------% */
291
292 /* %--------------------------------% */
293 /* | See stat.doc for documentation | */
294 /* %--------------------------------% */
295
296 /* \SCCS Information: @(#) */
297 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
298
299
300
301 /* %-----------------% */
302 /* | Array Arguments | */
303 /* %-----------------% */
304
305
306 /* %------------% */
307 /* | Parameters | */
308 /* %------------% */
309
310
311 /* %---------------% */
312 /* | Local Scalars | */
313 /* %---------------% */
314
315
316 /* %-----------------------% */
317 /* | Local array arguments | */
318 /* %-----------------------% */
319
320
321 /* %----------------------% */
322 /* | External Subroutines | */
323 /* %----------------------% */
324
325
326 /* %--------------------% */
327 /* | External Functions | */
328 /* %--------------------% */
329
330
331 /* %---------------------% */
332 /* | Intrinsic Functions | */
333 /* %---------------------% */
334
335
336 /* %-----------------------% */
337 /* | Executable Statements | */
338 /* %-----------------------% */
339
340 /* Parameter adjustments */
341 --workd;
342 --resid;
343 --workl;
344 --bounds;
345 --ritzi;
346 --ritzr;
347 v_dim1 = *ldv;
348 v_offset = 1 + v_dim1;
349 v -= v_offset;
350 h_dim1 = *ldh;
351 h_offset = 1 + h_dim1;
352 h__ -= h_offset;
353 q_dim1 = *ldq;
354 q_offset = 1 + q_dim1;
355 q -= q_offset;
356 --ipntr;
357
358 /* Function Body */
359 if (*ido == 0) {
360
361 second_(&t0);
362
363 msglvl = debug_1.mnaup2;
364
365 /* %-------------------------------------% */
366 /* | Get the machine dependent constant. | */
367 /* %-------------------------------------% */
368
369 eps23 = dlamch_("Epsilon-Machine", (ftnlen)15);
370 eps23 = pow_dd(&eps23, &c_b3);
371
372 nev0 = *nev;
373 np0 = *np;
374
375 /* %-------------------------------------% */
376 /* | kplusp is the bound on the largest | */
377 /* | Lanczos factorization built. | */
378 /* | nconv is the current number of | */
379 /* | "converged" eigenvlues. | */
380 /* | iter is the counter on the current | */
381 /* | iteration step. | */
382 /* %-------------------------------------% */
383
384 kplusp = *nev + *np;
385 nconv = 0;
386 iter = 0;
387
388 /* %---------------------------------------% */
389 /* | Set flags for computing the first NEV | */
390 /* | steps of the Arnoldi factorization. | */
391 /* %---------------------------------------% */
392
393 getv0 = TRUE_;
394 update = FALSE_;
395 ushift = FALSE_;
396 cnorm = FALSE_;
397
398 if (*info != 0) {
399
400 /* %--------------------------------------------% */
401 /* | User provides the initial residual vector. | */
402 /* %--------------------------------------------% */
403
404 initv = TRUE_;
405 *info = 0;
406 } else {
407 initv = FALSE_;
408 }
409 }
410
411 /* %---------------------------------------------% */
412 /* | Get a possibly random starting vector and | */
413 /* | force it into the range of the operator OP. | */
414 /* %---------------------------------------------% */
415
416 /* L10: */
417
418 if (getv0) {
419 dgetv0_(ido, bmat, &c__1, &initv, n, &c__1, &v[v_offset], ldv, &resid[
420 1], &rnorm, &ipntr[1], &workd[1], info, (ftnlen)1);
421
422 if (*ido != 99) {
423 goto L9000;
424 }
425
426 if (rnorm == 0.) {
427
428 /* %-----------------------------------------% */
429 /* | The initial vector is zero. Error exit. | */
430 /* %-----------------------------------------% */
431
432 *info = -9;
433 goto L1100;
434 }
435 getv0 = FALSE_;
436 *ido = 0;
437 }
438
439 /* %-----------------------------------% */
440 /* | Back from reverse communication : | */
441 /* | continue with update step | */
442 /* %-----------------------------------% */
443
444 if (update) {
445 goto L20;
446 }
447
448 /* %-------------------------------------------% */
449 /* | Back from computing user specified shifts | */
450 /* %-------------------------------------------% */
451
452 if (ushift) {
453 goto L50;
454 }
455
456 /* %-------------------------------------% */
457 /* | Back from computing residual norm | */
458 /* | at the end of the current iteration | */
459 /* %-------------------------------------% */
460
461 if (cnorm) {
462 goto L100;
463 }
464
465 /* %----------------------------------------------------------% */
466 /* | Compute the first NEV steps of the Arnoldi factorization | */
467 /* %----------------------------------------------------------% */
468
469 dnaitr_(ido, bmat, n, &c__0, nev, mode, &resid[1], &rnorm, &v[v_offset],
470 ldv, &h__[h_offset], ldh, &ipntr[1], &workd[1], info, (ftnlen)1);
471
472 /* %---------------------------------------------------% */
473 /* | ido .ne. 99 implies use of reverse communication | */
474 /* | to compute operations involving OP and possibly B | */
475 /* %---------------------------------------------------% */
476
477 if (*ido != 99) {
478 goto L9000;
479 }
480
481 if (*info > 0) {
482 *np = *info;
483 *mxiter = iter;
484 *info = -9999;
485 goto L1200;
486 }
487
488 /* %--------------------------------------------------------------% */
489 /* | | */
490 /* | M A I N ARNOLDI I T E R A T I O N L O O P | */
491 /* | Each iteration implicitly restarts the Arnoldi | */
492 /* | factorization in place. | */
493 /* | | */
494 /* %--------------------------------------------------------------% */
495
496 L1000:
497
498 ++iter;
499
500 if (msglvl > 0) {
501 ivout_(&debug_1.logfil, &c__1, &iter, &debug_1.ndigit, "_naup2: ****"
502 " Start of major iteration number ****", (ftnlen)49);
503 }
504
505 /* %-----------------------------------------------------------% */
506 /* | Compute NP additional steps of the Arnoldi factorization. | */
507 /* | Adjust NP since NEV might have been updated by last call | */
508 /* | to the shift application routine dnapps. | */
509 /* %-----------------------------------------------------------% */
510
511 *np = kplusp - *nev;
512
513 if (msglvl > 1) {
514 ivout_(&debug_1.logfil, &c__1, nev, &debug_1.ndigit, "_naup2: The le"
515 "ngth of the current Arnoldi factorization", (ftnlen)55);
516 ivout_(&debug_1.logfil, &c__1, np, &debug_1.ndigit, "_naup2: Extend "
517 "the Arnoldi factorization by", (ftnlen)43);
518 }
519
520 /* %-----------------------------------------------------------% */
521 /* | Compute NP additional steps of the Arnoldi factorization. | */
522 /* %-----------------------------------------------------------% */
523
524 *ido = 0;
525 L20:
526 update = TRUE_;
527
528 dnaitr_(ido, bmat, n, nev, np, mode, &resid[1], &rnorm, &v[v_offset], ldv,
529 &h__[h_offset], ldh, &ipntr[1], &workd[1], info, (ftnlen)1);
530
531 /* %---------------------------------------------------% */
532 /* | ido .ne. 99 implies use of reverse communication | */
533 /* | to compute operations involving OP and possibly B | */
534 /* %---------------------------------------------------% */
535
536 if (*ido != 99) {
537 goto L9000;
538 }
539
540 if (*info > 0) {
541 *np = *info;
542 *mxiter = iter;
543 *info = -9999;
544 goto L1200;
545 }
546 update = FALSE_;
547
548 if (msglvl > 1) {
549 dvout_(&debug_1.logfil, &c__1, &rnorm, &debug_1.ndigit, "_naup2: Cor"
550 "responding B-norm of the residual", (ftnlen)44);
551 }
552
553 /* %--------------------------------------------------------% */
554 /* | Compute the eigenvalues and corresponding error bounds | */
555 /* | of the current upper Hessenberg matrix. | */
556 /* %--------------------------------------------------------% */
557
558 dneigh_(&rnorm, &kplusp, &h__[h_offset], ldh, &ritzr[1], &ritzi[1], &
559 bounds[1], &q[q_offset], ldq, &workl[1], &ierr);
560
561 if (ierr != 0) {
562 *info = -8;
563 goto L1200;
564 }
565
566 /* %----------------------------------------------------% */
567 /* | Make a copy of eigenvalues and corresponding error | */
568 /* | bounds obtained from dneigh. | */
569 /* %----------------------------------------------------% */
570
571 /* Computing 2nd power */
572 i__1 = kplusp;
573 dcopy_(&kplusp, &ritzr[1], &c__1, &workl[i__1 * i__1 + 1], &c__1);
574 /* Computing 2nd power */
575 i__1 = kplusp;
576 dcopy_(&kplusp, &ritzi[1], &c__1, &workl[i__1 * i__1 + kplusp + 1], &c__1)
577 ;
578 /* Computing 2nd power */
579 i__1 = kplusp;
580 dcopy_(&kplusp, &bounds[1], &c__1, &workl[i__1 * i__1 + (kplusp << 1) + 1]
581 , &c__1);
582
583 /* %---------------------------------------------------% */
584 /* | Select the wanted Ritz values and their bounds | */
585 /* | to be used in the convergence test. | */
586 /* | The wanted part of the spectrum and corresponding | */
587 /* | error bounds are in the last NEV loc. of RITZR, | */
588 /* | RITZI and BOUNDS respectively. The variables NEV | */
589 /* | and NP may be updated if the NEV-th wanted Ritz | */
590 /* | value has a non zero imaginary part. In this case | */
591 /* | NEV is increased by one and NP decreased by one. | */
592 /* | NOTE: The last two arguments of dngets are no | */
593 /* | longer used as of version 2.1. | */
594 /* %---------------------------------------------------% */
595
596 *nev = nev0;
597 *np = np0;
598 numcnv = *nev;
599 dngets_(ishift, which, nev, np, &ritzr[1], &ritzi[1], &bounds[1], &workl[
600 1], &workl[*np + 1], (ftnlen)2);
601 if (*nev == nev0 + 1) {
602 numcnv = nev0 + 1;
603 }
604
605 /* %-------------------% */
606 /* | Convergence test. | */
607 /* %-------------------% */
608
609 dcopy_(nev, &bounds[*np + 1], &c__1, &workl[(*np << 1) + 1], &c__1);
610 dnconv_(nev, &ritzr[*np + 1], &ritzi[*np + 1], &workl[(*np << 1) + 1],
611 tol, &nconv);
612
613 if (msglvl > 2) {
614 kp[0] = *nev;
615 kp[1] = *np;
616 kp[2] = numcnv;
617 kp[3] = nconv;
618 ivout_(&debug_1.logfil, &c__4, kp, &debug_1.ndigit, "_naup2: NEV, NP"
619 ", NUMCNV, NCONV are", (ftnlen)34);
620 dvout_(&debug_1.logfil, &kplusp, &ritzr[1], &debug_1.ndigit, "_naup2"
621 ": Real part of the eigenvalues of H", (ftnlen)41);
622 dvout_(&debug_1.logfil, &kplusp, &ritzi[1], &debug_1.ndigit, "_naup2"
623 ": Imaginary part of the eigenvalues of H", (ftnlen)46);
624 dvout_(&debug_1.logfil, &kplusp, &bounds[1], &debug_1.ndigit, "_naup"
625 "2: Ritz estimates of the current NCV Ritz values", (ftnlen)53)
626 ;
627 }
628
629 /* %---------------------------------------------------------% */
630 /* | Count the number of unwanted Ritz values that have zero | */
631 /* | Ritz estimates. If any Ritz estimates are equal to zero | */
632 /* | then a leading block of H of order equal to at least | */
633 /* | the number of Ritz values with zero Ritz estimates has | */
634 /* | split off. None of these Ritz values may be removed by | */
635 /* | shifting. Decrease NP the number of shifts to apply. If | */
636 /* | no shifts may be applied, then prepare to exit | */
637 /* %---------------------------------------------------------% */
638
639 nptemp = *np;
640 i__1 = nptemp;
641 for (j = 1; j <= i__1; ++j) {
642 if (bounds[j] == 0.) {
643 --(*np);
644 ++(*nev);
645 }
646 /* L30: */
647 }
648
649 if (nconv >= numcnv || iter > *mxiter || *np == 0) {
650
651 if (msglvl > 4) {
652 /* Computing 2nd power */
653 i__1 = kplusp;
654 dvout_(&debug_1.logfil, &kplusp, &workl[i__1 * i__1 + 1], &
655 debug_1.ndigit, "_naup2: Real part of the eig computed b"
656 "y _neigh:", (ftnlen)48);
657 /* Computing 2nd power */
658 i__1 = kplusp;
659 dvout_(&debug_1.logfil, &kplusp, &workl[i__1 * i__1 + kplusp + 1],
660 &debug_1.ndigit, "_naup2: Imag part of the eig computed"
661 " by _neigh:", (ftnlen)48);
662 /* Computing 2nd power */
663 i__1 = kplusp;
664 dvout_(&debug_1.logfil, &kplusp, &workl[i__1 * i__1 + (kplusp <<
665 1) + 1], &debug_1.ndigit, "_naup2: Ritz eistmates comput"
666 "ed by _neigh:", (ftnlen)42);
667 }
668
669 /* %------------------------------------------------% */
670 /* | Prepare to exit. Put the converged Ritz values | */
671 /* | and corresponding bounds in RITZ(1:NCONV) and | */
672 /* | BOUNDS(1:NCONV) respectively. Then sort. Be | */
673 /* | careful when NCONV > NP | */
674 /* %------------------------------------------------% */
675
676 /* %------------------------------------------% */
677 /* | Use h( 3,1 ) as storage to communicate | */
678 /* | rnorm to _neupd if needed | */
679 /* %------------------------------------------% */
680 h__[h_dim1 + 3] = rnorm;
681
682 /* %----------------------------------------------% */
683 /* | To be consistent with dngets, we first do a | */
684 /* | pre-processing sort in order to keep complex | */
685 /* | conjugate pairs together. This is similar | */
686 /* | to the pre-processing sort used in dngets | */
687 /* | except that the sort is done in the opposite | */
688 /* | order. | */
689 /* %----------------------------------------------% */
690
691 if (s_cmp(which, "LM", (ftnlen)2, (ftnlen)2) == 0) {
692 s_copy(wprime, "SR", (ftnlen)2, (ftnlen)2);
693 }
694 if (s_cmp(which, "SM", (ftnlen)2, (ftnlen)2) == 0) {
695 s_copy(wprime, "LR", (ftnlen)2, (ftnlen)2);
696 }
697 if (s_cmp(which, "LR", (ftnlen)2, (ftnlen)2) == 0) {
698 s_copy(wprime, "SM", (ftnlen)2, (ftnlen)2);
699 }
700 if (s_cmp(which, "SR", (ftnlen)2, (ftnlen)2) == 0) {
701 s_copy(wprime, "LM", (ftnlen)2, (ftnlen)2);
702 }
703 if (s_cmp(which, "LI", (ftnlen)2, (ftnlen)2) == 0) {
704 s_copy(wprime, "SM", (ftnlen)2, (ftnlen)2);
705 }
706 if (s_cmp(which, "SI", (ftnlen)2, (ftnlen)2) == 0) {
707 s_copy(wprime, "LM", (ftnlen)2, (ftnlen)2);
708 }
709
710 dsortc_(wprime, &c_true, &kplusp, &ritzr[1], &ritzi[1], &bounds[1], (
711 ftnlen)2);
712
713 /* %----------------------------------------------% */
714 /* | Now sort Ritz values so that converged Ritz | */
715 /* | values appear within the first NEV locations | */
716 /* | of ritzr, ritzi and bounds, and the most | */
717 /* | desired one appears at the front. | */
718 /* %----------------------------------------------% */
719
720 if (s_cmp(which, "LM", (ftnlen)2, (ftnlen)2) == 0) {
721 s_copy(wprime, "SM", (ftnlen)2, (ftnlen)2);
722 }
723 if (s_cmp(which, "SM", (ftnlen)2, (ftnlen)2) == 0) {
724 s_copy(wprime, "LM", (ftnlen)2, (ftnlen)2);
725 }
726 if (s_cmp(which, "LR", (ftnlen)2, (ftnlen)2) == 0) {
727 s_copy(wprime, "SR", (ftnlen)2, (ftnlen)2);
728 }
729 if (s_cmp(which, "SR", (ftnlen)2, (ftnlen)2) == 0) {
730 s_copy(wprime, "LR", (ftnlen)2, (ftnlen)2);
731 }
732 if (s_cmp(which, "LI", (ftnlen)2, (ftnlen)2) == 0) {
733 s_copy(wprime, "SI", (ftnlen)2, (ftnlen)2);
734 }
735 if (s_cmp(which, "SI", (ftnlen)2, (ftnlen)2) == 0) {
736 s_copy(wprime, "LI", (ftnlen)2, (ftnlen)2);
737 }
738
739 dsortc_(wprime, &c_true, &kplusp, &ritzr[1], &ritzi[1], &bounds[1], (
740 ftnlen)2);
741
742 /* %--------------------------------------------------% */
743 /* | Scale the Ritz estimate of each Ritz value | */
744 /* | by 1 / max(eps23,magnitude of the Ritz value). | */
745 /* %--------------------------------------------------% */
746
747 i__1 = numcnv;
748 for (j = 1; j <= i__1; ++j) {
749 /* Computing MAX */
750 d__1 = eps23, d__2 = dlapy2_(&ritzr[j], &ritzi[j]);
751 temp = max(d__1,d__2);
752 bounds[j] /= temp;
753 /* L35: */
754 }
755
756 /* %----------------------------------------------------% */
757 /* | Sort the Ritz values according to the scaled Ritz | */
758 /* | esitmates. This will push all the converged ones | */
759 /* | towards the front of ritzr, ritzi, bounds | */
760 /* | (in the case when NCONV < NEV.) | */
761 /* %----------------------------------------------------% */
762
763 s_copy(wprime, "LR", (ftnlen)2, (ftnlen)2);
764 dsortc_(wprime, &c_true, &numcnv, &bounds[1], &ritzr[1], &ritzi[1], (
765 ftnlen)2);
766
767 /* %----------------------------------------------% */
768 /* | Scale the Ritz estimate back to its original | */
769 /* | value. | */
770 /* %----------------------------------------------% */
771
772 i__1 = numcnv;
773 for (j = 1; j <= i__1; ++j) {
774 /* Computing MAX */
775 d__1 = eps23, d__2 = dlapy2_(&ritzr[j], &ritzi[j]);
776 temp = max(d__1,d__2);
777 bounds[j] *= temp;
778 /* L40: */
779 }
780
781 /* %------------------------------------------------% */
782 /* | Sort the converged Ritz values again so that | */
783 /* | the "threshold" value appears at the front of | */
784 /* | ritzr, ritzi and bound. | */
785 /* %------------------------------------------------% */
786
787 dsortc_(which, &c_true, &nconv, &ritzr[1], &ritzi[1], &bounds[1], (
788 ftnlen)2);
789
790 if (msglvl > 1) {
791 dvout_(&debug_1.logfil, &kplusp, &ritzr[1], &debug_1.ndigit,
792 "_naup2: Sorted real part of the eigenvalues", (ftnlen)43)
793 ;
794 dvout_(&debug_1.logfil, &kplusp, &ritzi[1], &debug_1.ndigit,
795 "_naup2: Sorted imaginary part of the eigenvalues", (
796 ftnlen)48);
797 dvout_(&debug_1.logfil, &kplusp, &bounds[1], &debug_1.ndigit,
798 "_naup2: Sorted ritz estimates.", (ftnlen)30);
799 }
800
801 /* %------------------------------------% */
802 /* | Max iterations have been exceeded. | */
803 /* %------------------------------------% */
804
805 if (iter > *mxiter && nconv < numcnv) {
806 *info = 1;
807 }
808
809 /* %---------------------% */
810 /* | No shifts to apply. | */
811 /* %---------------------% */
812
813 if (*np == 0 && nconv < numcnv) {
814 *info = 2;
815 }
816
817 *np = nconv;
818 goto L1100;
819
820 } else if (nconv < numcnv && *ishift == 1) {
821
822 /* %-------------------------------------------------% */
823 /* | Do not have all the requested eigenvalues yet. | */
824 /* | To prevent possible stagnation, adjust the size | */
825 /* | of NEV. | */
826 /* %-------------------------------------------------% */
827
828 nevbef = *nev;
829 /* Computing MIN */
830 i__1 = nconv, i__2 = *np / 2;
831 *nev += min(i__1,i__2);
832 if (*nev == 1 && kplusp >= 6) {
833 *nev = kplusp / 2;
834 } else if (*nev == 1 && kplusp > 3) {
835 *nev = 2;
836 }
837 *np = kplusp - *nev;
838
839 /* %---------------------------------------% */
840 /* | If the size of NEV was just increased | */
841 /* | resort the eigenvalues. | */
842 /* %---------------------------------------% */
843
844 if (nevbef < *nev) {
845 dngets_(ishift, which, nev, np, &ritzr[1], &ritzi[1], &bounds[1],
846 &workl[1], &workl[*np + 1], (ftnlen)2);
847 }
848
849 }
850
851 if (msglvl > 0) {
852 ivout_(&debug_1.logfil, &c__1, &nconv, &debug_1.ndigit, "_naup2: no."
853 " of \"converged\" Ritz values at this iter.", (ftnlen)52);
854 if (msglvl > 1) {
855 kp[0] = *nev;
856 kp[1] = *np;
857 ivout_(&debug_1.logfil, &c__2, kp, &debug_1.ndigit, "_naup2: NEV"
858 " and NP are", (ftnlen)22);
859 dvout_(&debug_1.logfil, nev, &ritzr[*np + 1], &debug_1.ndigit,
860 "_naup2: \"wanted\" Ritz values -- real part", (ftnlen)41)
861 ;
862 dvout_(&debug_1.logfil, nev, &ritzi[*np + 1], &debug_1.ndigit,
863 "_naup2: \"wanted\" Ritz values -- imag part", (ftnlen)41)
864 ;
865 dvout_(&debug_1.logfil, nev, &bounds[*np + 1], &debug_1.ndigit,
866 "_naup2: Ritz estimates of the \"wanted\" values ", (
867 ftnlen)46);
868 }
869 }
870
871 if (*ishift == 0) {
872
873 /* %-------------------------------------------------------% */
874 /* | User specified shifts: reverse comminucation to | */
875 /* | compute the shifts. They are returned in the first | */
876 /* | 2*NP locations of WORKL. | */
877 /* %-------------------------------------------------------% */
878
879 ushift = TRUE_;
880 *ido = 3;
881 goto L9000;
882 }
883
884 L50:
885
886 /* %------------------------------------% */
887 /* | Back from reverse communication; | */
888 /* | User specified shifts are returned | */
889 /* | in WORKL(1:2*NP) | */
890 /* %------------------------------------% */
891
892 ushift = FALSE_;
893
894 if (*ishift == 0) {
895
896 /* %----------------------------------% */
897 /* | Move the NP shifts from WORKL to | */
898 /* | RITZR, RITZI to free up WORKL | */
899 /* | for non-exact shift case. | */
900 /* %----------------------------------% */
901
902 dcopy_(np, &workl[1], &c__1, &ritzr[1], &c__1);
903 dcopy_(np, &workl[*np + 1], &c__1, &ritzi[1], &c__1);
904 }
905
906 if (msglvl > 2) {
907 ivout_(&debug_1.logfil, &c__1, np, &debug_1.ndigit, "_naup2: The num"
908 "ber of shifts to apply ", (ftnlen)38);
909 dvout_(&debug_1.logfil, np, &ritzr[1], &debug_1.ndigit, "_naup2: Rea"
910 "l part of the shifts", (ftnlen)31);
911 dvout_(&debug_1.logfil, np, &ritzi[1], &debug_1.ndigit, "_naup2: Ima"
912 "ginary part of the shifts", (ftnlen)36);
913 if (*ishift == 1) {
914 dvout_(&debug_1.logfil, np, &bounds[1], &debug_1.ndigit, "_naup2"
915 ": Ritz estimates of the shifts", (ftnlen)36);
916 }
917 }
918
919 /* %---------------------------------------------------------% */
920 /* | Apply the NP implicit shifts by QR bulge chasing. | */
921 /* | Each shift is applied to the whole upper Hessenberg | */
922 /* | matrix H. | */
923 /* | The first 2*N locations of WORKD are used as workspace. | */
924 /* %---------------------------------------------------------% */
925
926 dnapps_(n, nev, np, &ritzr[1], &ritzi[1], &v[v_offset], ldv, &h__[
927 h_offset], ldh, &resid[1], &q[q_offset], ldq, &workl[1], &workd[1]
928 );
929
930 /* %---------------------------------------------% */
931 /* | Compute the B-norm of the updated residual. | */
932 /* | Keep B*RESID in WORKD(1:N) to be used in | */
933 /* | the first step of the next call to dnaitr. | */
934 /* %---------------------------------------------% */
935
936 cnorm = TRUE_;
937 second_(&t2);
938 if (*(unsigned char *)bmat == 'G') {
939 ++timing_1.nbx;
940 dcopy_(n, &resid[1], &c__1, &workd[*n + 1], &c__1);
941 ipntr[1] = *n + 1;
942 ipntr[2] = 1;
943 *ido = 2;
944
945 /* %----------------------------------% */
946 /* | Exit in order to compute B*RESID | */
947 /* %----------------------------------% */
948
949 goto L9000;
950 } else if (*(unsigned char *)bmat == 'I') {
951 dcopy_(n, &resid[1], &c__1, &workd[1], &c__1);
952 }
953
954 L100:
955
956 /* %----------------------------------% */
957 /* | Back from reverse communication; | */
958 /* | WORKD(1:N) := B*RESID | */
959 /* %----------------------------------% */
960
961 if (*(unsigned char *)bmat == 'G') {
962 second_(&t3);
963 timing_1.tmvbx += t3 - t2;
964 }
965
966 if (*(unsigned char *)bmat == 'G') {
967 rnorm = ddot_(n, &resid[1], &c__1, &workd[1], &c__1);
968 rnorm = sqrt((abs(rnorm)));
969 } else if (*(unsigned char *)bmat == 'I') {
970 rnorm = dnrm2_(n, &resid[1], &c__1);
971 }
972 cnorm = FALSE_;
973
974 if (msglvl > 2) {
975 dvout_(&debug_1.logfil, &c__1, &rnorm, &debug_1.ndigit, "_naup2: B-n"
976 "orm of residual for compressed factorization", (ftnlen)55);
977 dmout_(&debug_1.logfil, nev, nev, &h__[h_offset], ldh, &
978 debug_1.ndigit, "_naup2: Compressed upper Hessenberg matrix H"
979 , (ftnlen)44);
980 }
981
982 goto L1000;
983
984 /* %---------------------------------------------------------------% */
985 /* | | */
986 /* | E N D O F M A I N I T E R A T I O N L O O P | */
987 /* | | */
988 /* %---------------------------------------------------------------% */
989
990 L1100:
991
992 *mxiter = iter;
993 *nev = numcnv;
994
995 L1200:
996 *ido = 99;
997
998 /* %------------% */
999 /* | Error Exit | */
1000 /* %------------% */
1001
1002 second_(&t1);
1003 timing_1.tnaup2 = t1 - t0;
1004
1005 L9000:
1006
1007 /* %---------------% */
1008 /* | End of dnaup2 | */
1009 /* %---------------% */
1010
1011 return 0;
1012 } /* dnaup2_ */
1013