Debian Codegraph @

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

raw
1 /* ./src_f77/znapps.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_ZNAPPS;
15
16 #define debug_1 debug_ZNAPPS
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_ZNAPPS;
25
26 #define timing_1 timing_ZNAPPS
27
28 /* Table of constant values */
29
30 static doublecomplex c_b1 = {1.,0.};
31 static doublecomplex c_b2 = {0.,0.};
32 static integer c__1 = 1;
33
34 /* \BeginDoc */
35
36 /* \Name: znapps */
37
38 /* \Description: */
39 /* Given the Arnoldi factorization */
40
41 /* A*V_{k} - V_{k}*H_{k} = r_{k+p}*e_{k+p}^T, */
42
43 /* apply NP implicit shifts resulting in */
44
45 /* A*(V_{k}*Q) - (V_{k}*Q)*(Q^T* H_{k}*Q) = r_{k+p}*e_{k+p}^T * Q */
46
47 /* where Q is an orthogonal matrix which is the product of rotations */
48 /* and reflections resulting from the NP bulge change sweeps. */
49 /* The updated Arnoldi factorization becomes: */
50
51 /* A*VNEW_{k} - VNEW_{k}*HNEW_{k} = rnew_{k}*e_{k}^T. */
52
53 /* \Usage: */
54 /* call znapps */
55 /* ( N, KEV, NP, SHIFT, V, LDV, H, LDH, RESID, Q, LDQ, */
56 /* WORKL, WORKD ) */
57
58 /* \Arguments */
59 /* N Integer. (INPUT) */
60 /* Problem size, i.e. size of matrix A. */
61
62 /* KEV Integer. (INPUT/OUTPUT) */
63 /* KEV+NP is the size of the input matrix H. */
64 /* KEV is the size of the updated matrix HNEW. */
65
66 /* NP Integer. (INPUT) */
67 /* Number of implicit shifts to be applied. */
68
69 /* SHIFT Complex*16 array of length NP. (INPUT) */
70 /* The shifts to be applied. */
71
72 /* V Complex*16 N by (KEV+NP) array. (INPUT/OUTPUT) */
73 /* On INPUT, V contains the current KEV+NP Arnoldi vectors. */
74 /* On OUTPUT, V contains the updated KEV Arnoldi vectors */
75 /* in the first KEV columns of V. */
76
77 /* LDV Integer. (INPUT) */
78 /* Leading dimension of V exactly as declared in the calling */
79 /* program. */
80
81 /* H Complex*16 (KEV+NP) by (KEV+NP) array. (INPUT/OUTPUT) */
82 /* On INPUT, H contains the current KEV+NP by KEV+NP upper */
83 /* Hessenberg matrix of the Arnoldi factorization. */
84 /* On OUTPUT, H contains the updated KEV by KEV upper Hessenberg */
85 /* matrix in the KEV leading submatrix. */
86
87 /* LDH Integer. (INPUT) */
88 /* Leading dimension of H exactly as declared in the calling */
89 /* program. */
90
91 /* RESID Complex*16 array of length N. (INPUT/OUTPUT) */
92 /* On INPUT, RESID contains the the residual vector r_{k+p}. */
93 /* On OUTPUT, RESID is the update residual vector rnew_{k} */
94 /* in the first KEV locations. */
95
96 /* Q Complex*16 KEV+NP by KEV+NP work array. (WORKSPACE) */
97 /* Work array used to accumulate the rotations and reflections */
98 /* during the bulge chase sweep. */
99
100 /* LDQ Integer. (INPUT) */
101 /* Leading dimension of Q exactly as declared in the calling */
102 /* program. */
103
104 /* WORKL Complex*16 work array of length (KEV+NP). (WORKSPACE) */
105 /* Private (replicated) array on each PE or array allocated on */
106 /* the front end. */
107
108 /* WORKD Complex*16 work array of length 2*N. (WORKSPACE) */
109 /* Distributed array used in the application of the accumulated */
110 /* orthogonal matrix Q. */
111
112 /* \EndDoc */
113
114 /* ----------------------------------------------------------------------- */
115
116 /* \BeginLib */
117
118 /* \Local variables: */
119 /* xxxxxx Complex*16 */
120
121 /* \References: */
122 /* 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in */
123 /* a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), */
124 /* pp 357-385. */
125
126 /* \Routines called: */
127 /* ivout ARPACK utility routine that prints integers. */
128 /* second ARPACK utility routine for timing. */
129 /* zmout ARPACK utility routine that prints matrices */
130 /* zvout ARPACK utility routine that prints vectors. */
131 /* zlacpy LAPACK matrix copy routine. */
132 /* zlanhs LAPACK routine that computes various norms of a matrix. */
133 /* zlartg LAPACK Givens rotation construction routine. */
134 /* zlaset LAPACK matrix initialization routine. */
135 /* dlabad LAPACK routine for defining the underflow and overflow */
136 /* limits. */
137 /* dlamch LAPACK routine that determines machine constants. */
138 /* dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */
139 /* zgemv Level 2 BLAS routine for matrix vector multiplication. */
140 /* zaxpy Level 1 BLAS that computes a vector triad. */
141 /* zcopy Level 1 BLAS that copies one vector to another. */
142 /* zscal Level 1 BLAS that scales a vector. */
143
144 /* \Author */
145 /* Danny Sorensen Phuong Vu */
146 /* Richard Lehoucq CRPC / Rice University */
147 /* Dept. of Computational & Houston, Texas */
148 /* Applied Mathematics */
149 /* Rice University */
150 /* Houston, Texas */
151
152 /* \SCCS Information: @(#) */
153 /* FILE: napps.F SID: 2.3 DATE OF SID: 3/28/97 RELEASE: 2 */
154
155 /* \Remarks */
156 /* 1. In this version, each shift is applied to all the sublocks of */
157 /* the Hessenberg matrix H and not just to the submatrix that it */
158 /* comes from. Deflation as in LAPACK routine zlahqr (QR algorithm */
159 /* for upper Hessenberg matrices ) is used. */
160 /* Upon output, the subdiagonals of H are enforced to be non-negative */
161 /* real numbers. */
162
163 /* \EndLib */
164
165 /* ----------------------------------------------------------------------- */
166
167 /* Subroutine */ int znapps_(integer *n, integer *kev, integer *np,
168 doublecomplex *shift, doublecomplex *v, integer *ldv, doublecomplex *
169 h__, integer *ldh, doublecomplex *resid, doublecomplex *q, integer *
170 ldq, doublecomplex *workl, doublecomplex *workd)
171 {
172 /* Initialized data */
173
174 static logical first = TRUE_;
175
176 /* System generated locals */
177 integer h_dim1, h_offset, v_dim1, v_offset, q_dim1, q_offset, i__1, i__2,
178 i__3, i__4, i__5, i__6;
179 doublereal d__1, d__2, d__3, d__4;
180 doublecomplex z__1, z__2, z__3, z__4, z__5;
181
182 /* Builtin functions */
183 double d_imag(doublecomplex *);
184 void d_cnjg(doublecomplex *, doublecomplex *);
185
186 /* Local variables */
187 static doublereal c__;
188 static doublecomplex f, g;
189 static integer i__, j;
190 static doublecomplex r__, s, t;
191 static real t0, t1;
192 static doublecomplex h11, h21;
193 static integer jj;
194 static doublereal ulp, tst1;
195 static integer iend;
196 static doublereal unfl, ovfl;
197 static doublecomplex sigma;
198 extern /* Subroutine */ int zscal_(integer *, doublecomplex *,
199 doublecomplex *, integer *), zgemv_(char *, integer *, integer *,
200 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
201 integer *, doublecomplex *, doublecomplex *, integer *, ftnlen),
202 zcopy_(integer *, doublecomplex *, integer *, doublecomplex *,
203 integer *), ivout_(integer *, integer *, integer *, integer *,
204 char *, ftnlen), zaxpy_(integer *, doublecomplex *, doublecomplex
205 *, integer *, doublecomplex *, integer *), zmout_(integer *,
206 integer *, integer *, doublecomplex *, integer *, integer *, char
207 *, ftnlen), zvout_(integer *, integer *, doublecomplex *, integer
208 *, char *, ftnlen);
209 extern doublereal dlapy2_(doublereal *, doublereal *);
210 extern /* Subroutine */ int dlabad_(doublereal *, doublereal *);
211 extern doublereal dlamch_(char *, ftnlen);
212 extern /* Subroutine */ int second_(real *);
213 static integer istart, kplusp, msglvl;
214 static doublereal smlnum;
215 extern /* Subroutine */ int zlacpy_(char *, integer *, integer *,
216 doublecomplex *, integer *, doublecomplex *, integer *, ftnlen),
217 zlartg_(doublecomplex *, doublecomplex *, doublereal *,
218 doublecomplex *, doublecomplex *), zlaset_(char *, integer *,
219 integer *, doublecomplex *, doublecomplex *, doublecomplex *,
220 integer *, ftnlen);
221 extern doublereal zlanhs_(char *, integer *, doublecomplex *, integer *,
222 doublecomplex *, ftnlen);
223
224
225 /* %----------------------------------------------------% */
226 /* | Include files for debugging and timing information | */
227 /* %----------------------------------------------------% */
228
229
230 /* \SCCS Information: @(#) */
231 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
232
233 /* %---------------------------------% */
234 /* | See debug.doc for documentation | */
235 /* %---------------------------------% */
236
237 /* %------------------% */
238 /* | Scalar Arguments | */
239 /* %------------------% */
240
241 /* %--------------------------------% */
242 /* | See stat.doc for documentation | */
243 /* %--------------------------------% */
244
245 /* \SCCS Information: @(#) */
246 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
247
248
249
250 /* %-----------------% */
251 /* | Array Arguments | */
252 /* %-----------------% */
253
254
255 /* %------------% */
256 /* | Parameters | */
257 /* %------------% */
258
259
260 /* %------------------------% */
261 /* | Local Scalars & Arrays | */
262 /* %------------------------% */
263
264
265 /* %----------------------% */
266 /* | External Subroutines | */
267 /* %----------------------% */
268
269
270 /* %--------------------% */
271 /* | External Functions | */
272 /* %--------------------% */
273
274
275 /* %----------------------% */
276 /* | Intrinsics Functions | */
277 /* %----------------------% */
278
279
280 /* %---------------------% */
281 /* | Statement Functions | */
282 /* %---------------------% */
283
284
285 /* %----------------% */
286 /* | Data statments | */
287 /* %----------------% */
288
289 /* Parameter adjustments */
290 --workd;
291 --resid;
292 --workl;
293 --shift;
294 v_dim1 = *ldv;
295 v_offset = 1 + v_dim1;
296 v -= v_offset;
297 h_dim1 = *ldh;
298 h_offset = 1 + h_dim1;
299 h__ -= h_offset;
300 q_dim1 = *ldq;
301 q_offset = 1 + q_dim1;
302 q -= q_offset;
303
304 /* Function Body */
305
306 /* %-----------------------% */
307 /* | Executable Statements | */
308 /* %-----------------------% */
309
310 if (first) {
311
312 /* %-----------------------------------------------% */
313 /* | Set machine-dependent constants for the | */
314 /* | stopping criterion. If norm(H) <= sqrt(OVFL), | */
315 /* | overflow should not occur. | */
316 /* | REFERENCE: LAPACK subroutine zlahqr | */
317 /* %-----------------------------------------------% */
318
319 unfl = dlamch_("safe minimum", (ftnlen)12);
320 z__1.r = 1. / unfl, z__1.i = 0. / unfl;
321 ovfl = z__1.r;
322 dlabad_(&unfl, &ovfl);
323 ulp = dlamch_("precision", (ftnlen)9);
324 smlnum = unfl * (*n / ulp);
325 first = FALSE_;
326 }
327
328 /* %-------------------------------% */
329 /* | Initialize timing statistics | */
330 /* | & message level for debugging | */
331 /* %-------------------------------% */
332
333 second_(&t0);
334 msglvl = debug_1.mcapps;
335
336 kplusp = *kev + *np;
337
338 /* %--------------------------------------------% */
339 /* | Initialize Q to the identity to accumulate | */
340 /* | the rotations and reflections | */
341 /* %--------------------------------------------% */
342
343 zlaset_("All", &kplusp, &kplusp, &c_b2, &c_b1, &q[q_offset], ldq, (ftnlen)
344 3);
345
346 /* %----------------------------------------------% */
347 /* | Quick return if there are no shifts to apply | */
348 /* %----------------------------------------------% */
349
350 if (*np == 0) {
351 goto L9000;
352 }
353
354 /* %----------------------------------------------% */
355 /* | Chase the bulge with the application of each | */
356 /* | implicit shift. Each shift is applied to the | */
357 /* | whole matrix including each block. | */
358 /* %----------------------------------------------% */
359
360 i__1 = *np;
361 for (jj = 1; jj <= i__1; ++jj) {
362 i__2 = jj;
363 sigma.r = shift[i__2].r, sigma.i = shift[i__2].i;
364
365 if (msglvl > 2) {
366 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit, "_napps: sh"
367 "ift number.", (ftnlen)21);
368 zvout_(&debug_1.logfil, &c__1, &sigma, &debug_1.ndigit, "_napps:"
369 " Value of the shift ", (ftnlen)27);
370 }
371
372 istart = 1;
373 L20:
374
375 i__2 = kplusp - 1;
376 for (i__ = istart; i__ <= i__2; ++i__) {
377
378 /* %----------------------------------------% */
379 /* | Check for splitting and deflation. Use | */
380 /* | a standard test as in the QR algorithm | */
381 /* | REFERENCE: LAPACK subroutine zlahqr | */
382 /* %----------------------------------------% */
383
384 i__3 = i__ + i__ * h_dim1;
385 i__4 = i__ + 1 + (i__ + 1) * h_dim1;
386 tst1 = (d__1 = h__[i__3].r, abs(d__1)) + (d__2 = d_imag(&h__[i__
387 + i__ * h_dim1]), abs(d__2)) + ((d__3 = h__[i__4].r, abs(
388 d__3)) + (d__4 = d_imag(&h__[i__ + 1 + (i__ + 1) * h_dim1]
389 ), abs(d__4)));
390 if (tst1 == 0.) {
391 i__3 = kplusp - jj + 1;
392 tst1 = zlanhs_("1", &i__3, &h__[h_offset], ldh, &workl[1], (
393 ftnlen)1);
394 }
395 i__3 = i__ + 1 + i__ * h_dim1;
396 /* Computing MAX */
397 d__2 = ulp * tst1;
398 if ((d__1 = h__[i__3].r, abs(d__1)) <= max(d__2,smlnum)) {
399 if (msglvl > 0) {
400 ivout_(&debug_1.logfil, &c__1, &i__, &debug_1.ndigit,
401 "_napps: matrix splitting at row/column no.", (
402 ftnlen)42);
403 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit,
404 "_napps: matrix splitting with shift number.", (
405 ftnlen)43);
406 zvout_(&debug_1.logfil, &c__1, &h__[i__ + 1 + i__ *
407 h_dim1], &debug_1.ndigit, "_napps: off diagonal "
408 "element.", (ftnlen)29);
409 }
410 iend = i__;
411 i__3 = i__ + 1 + i__ * h_dim1;
412 h__[i__3].r = 0., h__[i__3].i = 0.;
413 goto L40;
414 }
415 /* L30: */
416 }
417 iend = kplusp;
418 L40:
419
420 if (msglvl > 2) {
421 ivout_(&debug_1.logfil, &c__1, &istart, &debug_1.ndigit, "_napps"
422 ": Start of current block ", (ftnlen)31);
423 ivout_(&debug_1.logfil, &c__1, &iend, &debug_1.ndigit, "_napps: "
424 "End of current block ", (ftnlen)29);
425 }
426
427 /* %------------------------------------------------% */
428 /* | No reason to apply a shift to block of order 1 | */
429 /* | or if the current block starts after the point | */
430 /* | of compression since we'll discard this stuff | */
431 /* %------------------------------------------------% */
432
433 if (istart == iend || istart > *kev) {
434 goto L100;
435 }
436
437 i__2 = istart + istart * h_dim1;
438 h11.r = h__[i__2].r, h11.i = h__[i__2].i;
439 i__2 = istart + 1 + istart * h_dim1;
440 h21.r = h__[i__2].r, h21.i = h__[i__2].i;
441 z__1.r = h11.r - sigma.r, z__1.i = h11.i - sigma.i;
442 f.r = z__1.r, f.i = z__1.i;
443 g.r = h21.r, g.i = h21.i;
444
445 i__2 = iend - 1;
446 for (i__ = istart; i__ <= i__2; ++i__) {
447
448 /* %------------------------------------------------------% */
449 /* | Construct the plane rotation G to zero out the bulge | */
450 /* %------------------------------------------------------% */
451
452 zlartg_(&f, &g, &c__, &s, &r__);
453 if (i__ > istart) {
454 i__3 = i__ + (i__ - 1) * h_dim1;
455 h__[i__3].r = r__.r, h__[i__3].i = r__.i;
456 i__3 = i__ + 1 + (i__ - 1) * h_dim1;
457 h__[i__3].r = 0., h__[i__3].i = 0.;
458 }
459
460 /* %---------------------------------------------% */
461 /* | Apply rotation to the left of H; H <- G'*H | */
462 /* %---------------------------------------------% */
463
464 i__3 = kplusp;
465 for (j = i__; j <= i__3; ++j) {
466 i__4 = i__ + j * h_dim1;
467 z__2.r = c__ * h__[i__4].r, z__2.i = c__ * h__[i__4].i;
468 i__5 = i__ + 1 + j * h_dim1;
469 z__3.r = s.r * h__[i__5].r - s.i * h__[i__5].i, z__3.i = s.r *
470 h__[i__5].i + s.i * h__[i__5].r;
471 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
472 t.r = z__1.r, t.i = z__1.i;
473 i__4 = i__ + 1 + j * h_dim1;
474 d_cnjg(&z__4, &s);
475 z__3.r = -z__4.r, z__3.i = -z__4.i;
476 i__5 = i__ + j * h_dim1;
477 z__2.r = z__3.r * h__[i__5].r - z__3.i * h__[i__5].i, z__2.i =
478 z__3.r * h__[i__5].i + z__3.i * h__[i__5].r;
479 i__6 = i__ + 1 + j * h_dim1;
480 z__5.r = c__ * h__[i__6].r, z__5.i = c__ * h__[i__6].i;
481 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
482 h__[i__4].r = z__1.r, h__[i__4].i = z__1.i;
483 i__4 = i__ + j * h_dim1;
484 h__[i__4].r = t.r, h__[i__4].i = t.i;
485 /* L50: */
486 }
487
488 /* %---------------------------------------------% */
489 /* | Apply rotation to the right of H; H <- H*G | */
490 /* %---------------------------------------------% */
491
492 /* Computing MIN */
493 i__4 = i__ + 2;
494 i__3 = min(i__4,iend);
495 for (j = 1; j <= i__3; ++j) {
496 i__4 = j + i__ * h_dim1;
497 z__2.r = c__ * h__[i__4].r, z__2.i = c__ * h__[i__4].i;
498 d_cnjg(&z__4, &s);
499 i__5 = j + (i__ + 1) * h_dim1;
500 z__3.r = z__4.r * h__[i__5].r - z__4.i * h__[i__5].i, z__3.i =
501 z__4.r * h__[i__5].i + z__4.i * h__[i__5].r;
502 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
503 t.r = z__1.r, t.i = z__1.i;
504 i__4 = j + (i__ + 1) * h_dim1;
505 z__3.r = -s.r, z__3.i = -s.i;
506 i__5 = j + i__ * h_dim1;
507 z__2.r = z__3.r * h__[i__5].r - z__3.i * h__[i__5].i, z__2.i =
508 z__3.r * h__[i__5].i + z__3.i * h__[i__5].r;
509 i__6 = j + (i__ + 1) * h_dim1;
510 z__4.r = c__ * h__[i__6].r, z__4.i = c__ * h__[i__6].i;
511 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
512 h__[i__4].r = z__1.r, h__[i__4].i = z__1.i;
513 i__4 = j + i__ * h_dim1;
514 h__[i__4].r = t.r, h__[i__4].i = t.i;
515 /* L60: */
516 }
517
518 /* %-----------------------------------------------------% */
519 /* | Accumulate the rotation in the matrix Q; Q <- Q*G' | */
520 /* %-----------------------------------------------------% */
521
522 /* Computing MIN */
523 i__4 = i__ + jj;
524 i__3 = min(i__4,kplusp);
525 for (j = 1; j <= i__3; ++j) {
526 i__4 = j + i__ * q_dim1;
527 z__2.r = c__ * q[i__4].r, z__2.i = c__ * q[i__4].i;
528 d_cnjg(&z__4, &s);
529 i__5 = j + (i__ + 1) * q_dim1;
530 z__3.r = z__4.r * q[i__5].r - z__4.i * q[i__5].i, z__3.i =
531 z__4.r * q[i__5].i + z__4.i * q[i__5].r;
532 z__1.r = z__2.r + z__3.r, z__1.i = z__2.i + z__3.i;
533 t.r = z__1.r, t.i = z__1.i;
534 i__4 = j + (i__ + 1) * q_dim1;
535 z__3.r = -s.r, z__3.i = -s.i;
536 i__5 = j + i__ * q_dim1;
537 z__2.r = z__3.r * q[i__5].r - z__3.i * q[i__5].i, z__2.i =
538 z__3.r * q[i__5].i + z__3.i * q[i__5].r;
539 i__6 = j + (i__ + 1) * q_dim1;
540 z__4.r = c__ * q[i__6].r, z__4.i = c__ * q[i__6].i;
541 z__1.r = z__2.r + z__4.r, z__1.i = z__2.i + z__4.i;
542 q[i__4].r = z__1.r, q[i__4].i = z__1.i;
543 i__4 = j + i__ * q_dim1;
544 q[i__4].r = t.r, q[i__4].i = t.i;
545 /* L70: */
546 }
547
548 /* %---------------------------% */
549 /* | Prepare for next rotation | */
550 /* %---------------------------% */
551
552 if (i__ < iend - 1) {
553 i__3 = i__ + 1 + i__ * h_dim1;
554 f.r = h__[i__3].r, f.i = h__[i__3].i;
555 i__3 = i__ + 2 + i__ * h_dim1;
556 g.r = h__[i__3].r, g.i = h__[i__3].i;
557 }
558 /* L80: */
559 }
560
561 /* %-------------------------------% */
562 /* | Finished applying the shift. | */
563 /* %-------------------------------% */
564
565 L100:
566
567 /* %---------------------------------------------------------% */
568 /* | Apply the same shift to the next block if there is any. | */
569 /* %---------------------------------------------------------% */
570
571 istart = iend + 1;
572 if (iend < kplusp) {
573 goto L20;
574 }
575
576 /* %---------------------------------------------% */
577 /* | Loop back to the top to get the next shift. | */
578 /* %---------------------------------------------% */
579
580 /* L110: */
581 }
582
583 /* %---------------------------------------------------% */
584 /* | Perform a similarity transformation that makes | */
585 /* | sure that the compressed H will have non-negative | */
586 /* | real subdiagonal elements. | */
587 /* %---------------------------------------------------% */
588
589 i__1 = *kev;
590 for (j = 1; j <= i__1; ++j) {
591 i__2 = j + 1 + j * h_dim1;
592 if (h__[i__2].r < 0. || d_imag(&h__[j + 1 + j * h_dim1]) != 0.) {
593 i__2 = j + 1 + j * h_dim1;
594 i__3 = j + 1 + j * h_dim1;
595 d__2 = h__[i__3].r;
596 d__3 = d_imag(&h__[j + 1 + j * h_dim1]);
597 d__1 = dlapy2_(&d__2, &d__3);
598 z__1.r = h__[i__2].r / d__1, z__1.i = h__[i__2].i / d__1;
599 t.r = z__1.r, t.i = z__1.i;
600 i__2 = kplusp - j + 1;
601 d_cnjg(&z__1, &t);
602 zscal_(&i__2, &z__1, &h__[j + 1 + j * h_dim1], ldh);
603 /* Computing MIN */
604 i__3 = j + 2;
605 i__2 = min(i__3,kplusp);
606 zscal_(&i__2, &t, &h__[(j + 1) * h_dim1 + 1], &c__1);
607 /* Computing MIN */
608 i__3 = j + *np + 1;
609 i__2 = min(i__3,kplusp);
610 zscal_(&i__2, &t, &q[(j + 1) * q_dim1 + 1], &c__1);
611 i__2 = j + 1 + j * h_dim1;
612 i__3 = j + 1 + j * h_dim1;
613 d__1 = h__[i__3].r;
614 z__1.r = d__1, z__1.i = 0.;
615 h__[i__2].r = z__1.r, h__[i__2].i = z__1.i;
616 }
617 /* L120: */
618 }
619
620 i__1 = *kev;
621 for (i__ = 1; i__ <= i__1; ++i__) {
622
623 /* %--------------------------------------------% */
624 /* | Final check for splitting and deflation. | */
625 /* | Use a standard test as in the QR algorithm | */
626 /* | REFERENCE: LAPACK subroutine zlahqr. | */
627 /* | Note: Since the subdiagonals of the | */
628 /* | compressed H are nonnegative real numbers, | */
629 /* | we take advantage of this. | */
630 /* %--------------------------------------------% */
631
632 i__2 = i__ + i__ * h_dim1;
633 i__3 = i__ + 1 + (i__ + 1) * h_dim1;
634 tst1 = (d__1 = h__[i__2].r, abs(d__1)) + (d__2 = d_imag(&h__[i__ +
635 i__ * h_dim1]), abs(d__2)) + ((d__3 = h__[i__3].r, abs(d__3))
636 + (d__4 = d_imag(&h__[i__ + 1 + (i__ + 1) * h_dim1]), abs(
637 d__4)));
638 if (tst1 == 0.) {
639 tst1 = zlanhs_("1", kev, &h__[h_offset], ldh, &workl[1], (ftnlen)
640 1);
641 }
642 i__2 = i__ + 1 + i__ * h_dim1;
643 /* Computing MAX */
644 d__1 = ulp * tst1;
645 if (h__[i__2].r <= max(d__1,smlnum)) {
646 i__3 = i__ + 1 + i__ * h_dim1;
647 h__[i__3].r = 0., h__[i__3].i = 0.;
648 }
649 /* L130: */
650 }
651
652 /* %-------------------------------------------------% */
653 /* | Compute the (kev+1)-st column of (V*Q) and | */
654 /* | temporarily store the result in WORKD(N+1:2*N). | */
655 /* | This is needed in the residual update since we | */
656 /* | cannot GUARANTEE that the corresponding entry | */
657 /* | of H would be zero as in exact arithmetic. | */
658 /* %-------------------------------------------------% */
659
660 i__1 = *kev + 1 + *kev * h_dim1;
661 if (h__[i__1].r > 0.) {
662 zgemv_("N", n, &kplusp, &c_b1, &v[v_offset], ldv, &q[(*kev + 1) *
663 q_dim1 + 1], &c__1, &c_b2, &workd[*n + 1], &c__1, (ftnlen)1);
664 }
665
666 /* %----------------------------------------------------------% */
667 /* | Compute column 1 to kev of (V*Q) in backward order | */
668 /* | taking advantage of the upper Hessenberg structure of Q. | */
669 /* %----------------------------------------------------------% */
670
671 i__1 = *kev;
672 for (i__ = 1; i__ <= i__1; ++i__) {
673 i__2 = kplusp - i__ + 1;
674 zgemv_("N", n, &i__2, &c_b1, &v[v_offset], ldv, &q[(*kev - i__ + 1) *
675 q_dim1 + 1], &c__1, &c_b2, &workd[1], &c__1, (ftnlen)1);
676 zcopy_(n, &workd[1], &c__1, &v[(kplusp - i__ + 1) * v_dim1 + 1], &
677 c__1);
678 /* L140: */
679 }
680
681 /* %-------------------------------------------------% */
682 /* | Move v(:,kplusp-kev+1:kplusp) into v(:,1:kev). | */
683 /* %-------------------------------------------------% */
684
685 zlacpy_("A", n, kev, &v[(kplusp - *kev + 1) * v_dim1 + 1], ldv, &v[
686 v_offset], ldv, (ftnlen)1);
687
688 /* %--------------------------------------------------------------% */
689 /* | Copy the (kev+1)-st column of (V*Q) in the appropriate place | */
690 /* %--------------------------------------------------------------% */
691
692 i__1 = *kev + 1 + *kev * h_dim1;
693 if (h__[i__1].r > 0.) {
694 zcopy_(n, &workd[*n + 1], &c__1, &v[(*kev + 1) * v_dim1 + 1], &c__1);
695 }
696
697 /* %-------------------------------------% */
698 /* | Update the residual vector: | */
699 /* | r <- sigmak*r + betak*v(:,kev+1) | */
700 /* | where | */
701 /* | sigmak = (e_{kev+p}'*Q)*e_{kev} | */
702 /* | betak = e_{kev+1}'*H*e_{kev} | */
703 /* %-------------------------------------% */
704
705 zscal_(n, &q[kplusp + *kev * q_dim1], &resid[1], &c__1);
706 i__1 = *kev + 1 + *kev * h_dim1;
707 if (h__[i__1].r > 0.) {
708 zaxpy_(n, &h__[*kev + 1 + *kev * h_dim1], &v[(*kev + 1) * v_dim1 + 1],
709 &c__1, &resid[1], &c__1);
710 }
711
712 if (msglvl > 1) {
713 zvout_(&debug_1.logfil, &c__1, &q[kplusp + *kev * q_dim1], &
714 debug_1.ndigit, "_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}", (
715 ftnlen)40);
716 zvout_(&debug_1.logfil, &c__1, &h__[*kev + 1 + *kev * h_dim1], &
717 debug_1.ndigit, "_napps: betak = e_{kev+1}^T*H*e_{kev}", (
718 ftnlen)37);
719 ivout_(&debug_1.logfil, &c__1, kev, &debug_1.ndigit, "_napps: Order "
720 "of the final Hessenberg matrix ", (ftnlen)45);
721 if (msglvl > 2) {
722 zmout_(&debug_1.logfil, kev, kev, &h__[h_offset], ldh, &
723 debug_1.ndigit, "_napps: updated Hessenberg matrix H for"
724 " next iteration", (ftnlen)54);
725 }
726
727 }
728
729 L9000:
730 second_(&t1);
731 timing_1.tcapps += t1 - t0;
732
733 return 0;
734
735 /* %---------------% */
736 /* | End of znapps | */
737 /* %---------------% */
738
739 } /* znapps_ */
740