Debian Codegraph @

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

raw
1 /* ./src_f77/cnapps.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_CNAPPS;
15
16 #define debug_1 debug_CNAPPS
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_CNAPPS;
25
26 #define timing_1 timing_CNAPPS
27
28 /* Table of constant values */
29
30 static realcomplex c_b1 = {1.f,0.f};
31 static realcomplex c_b2 = {0.f,0.f};
32 static integer c__1 = 1;
33
34 /* \BeginDoc */
35
36 /* \Name: cnapps */
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 cnapps */
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 array of length NP. (INPUT) */
70 /* The shifts to be applied. */
71
72 /* V Complex 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 (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 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 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 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 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 */
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 /* cmout ARPACK utility routine that prints matrices */
130 /* cvout ARPACK utility routine that prints vectors. */
131 /* clacpy LAPACK matrix copy routine. */
132 /* clanhs LAPACK routine that computes various norms of a matrix. */
133 /* clartg LAPACK Givens rotation construction routine. */
134 /* claset LAPACK matrix initialization routine. */
135 /* slabad LAPACK routine for defining the underflow and overflow */
136 /* limits. */
137 /* slamch LAPACK routine that determines machine constants. */
138 /* slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */
139 /* cgemv Level 2 BLAS routine for matrix vector multiplication. */
140 /* caxpy Level 1 BLAS that computes a vector triad. */
141 /* ccopy Level 1 BLAS that copies one vector to another. */
142 /* cscal 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 clahqr (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 cnapps_(integer *n, integer *kev, integer *np, realcomplex *
168 shift, realcomplex *v, integer *ldv, realcomplex *h__, integer *ldh, realcomplex *
169 resid, realcomplex *q, integer *ldq, realcomplex *workl, realcomplex *workd)
170 {
171 /* Initialized data */
172
173 static logical first = TRUE_;
174
175 /* System generated locals */
176 integer h_dim1, h_offset, v_dim1, v_offset, q_dim1, q_offset, i__1, i__2,
177 i__3, i__4, i__5, i__6;
178 real r__1, r__2, r__3, r__4;
179 realcomplex q__1, q__2, q__3, q__4, q__5;
180
181 /* Builtin functions */
182 double r_imag(realcomplex *);
183 void r_cnjg(realcomplex *, realcomplex *);
184
185 /* Local variables */
186 static real c__;
187 static realcomplex f, g;
188 static integer i__, j;
189 static realcomplex r__, s, t;
190 static real t0, t1;
191 static realcomplex h11, h21;
192 static integer jj;
193 static real ulp, tst1;
194 static integer iend;
195 static real unfl, ovfl;
196 extern /* Subroutine */ int cscal_(integer *, realcomplex *, realcomplex *,
197 integer *);
198 static realcomplex sigma;
199 extern /* Subroutine */ int cgemv_(char *, integer *, integer *, realcomplex *
200 , realcomplex *, integer *, realcomplex *, integer *, realcomplex *, realcomplex *
201 , integer *, ftnlen), ccopy_(integer *, realcomplex *, integer *,
202 realcomplex *, integer *), caxpy_(integer *, realcomplex *, realcomplex *,
203 integer *, realcomplex *, integer *), cmout_(integer *, integer *,
204 integer *, realcomplex *, integer *, integer *, char *, ftnlen),
205 cvout_(integer *, integer *, realcomplex *, integer *, char *, ftnlen)
206 , ivout_(integer *, integer *, integer *, integer *, char *,
207 ftnlen);
208 extern doublereal slapy2_(real *, real *);
209 extern /* Subroutine */ int slabad_(real *, real *);
210 extern doublereal clanhs_(char *, integer *, realcomplex *, integer *,
211 realcomplex *, ftnlen), slamch_(char *, ftnlen);
212 extern /* Subroutine */ int clacpy_(char *, integer *, integer *, realcomplex
213 *, integer *, realcomplex *, integer *, ftnlen);
214 static integer istart, kplusp, msglvl;
215 static real smlnum;
216 extern /* Subroutine */ int clartg_(realcomplex *, realcomplex *, real *, realcomplex
217 *, realcomplex *), claset_(char *, integer *, integer *, realcomplex *,
218 realcomplex *, realcomplex *, integer *, ftnlen), second_(real *);
219
220
221 /* %----------------------------------------------------% */
222 /* | Include files for debugging and timing information | */
223 /* %----------------------------------------------------% */
224
225
226 /* \SCCS Information: @(#) */
227 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
228
229 /* %---------------------------------% */
230 /* | See debug.doc for documentation | */
231 /* %---------------------------------% */
232
233 /* %------------------% */
234 /* | Scalar Arguments | */
235 /* %------------------% */
236
237 /* %--------------------------------% */
238 /* | See stat.doc for documentation | */
239 /* %--------------------------------% */
240
241 /* \SCCS Information: @(#) */
242 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
243
244
245
246 /* %-----------------% */
247 /* | Array Arguments | */
248 /* %-----------------% */
249
250
251 /* %------------% */
252 /* | Parameters | */
253 /* %------------% */
254
255
256 /* %------------------------% */
257 /* | Local Scalars & Arrays | */
258 /* %------------------------% */
259
260
261 /* %----------------------% */
262 /* | External Subroutines | */
263 /* %----------------------% */
264
265
266 /* %--------------------% */
267 /* | External Functions | */
268 /* %--------------------% */
269
270
271 /* %----------------------% */
272 /* | Intrinsics Functions | */
273 /* %----------------------% */
274
275
276 /* %---------------------% */
277 /* | Statement Functions | */
278 /* %---------------------% */
279
280
281 /* %----------------% */
282 /* | Data statments | */
283 /* %----------------% */
284
285 /* Parameter adjustments */
286 --workd;
287 --resid;
288 --workl;
289 --shift;
290 v_dim1 = *ldv;
291 v_offset = 1 + v_dim1;
292 v -= v_offset;
293 h_dim1 = *ldh;
294 h_offset = 1 + h_dim1;
295 h__ -= h_offset;
296 q_dim1 = *ldq;
297 q_offset = 1 + q_dim1;
298 q -= q_offset;
299
300 /* Function Body */
301
302 /* %-----------------------% */
303 /* | Executable Statements | */
304 /* %-----------------------% */
305
306 if (first) {
307
308 /* %-----------------------------------------------% */
309 /* | Set machine-dependent constants for the | */
310 /* | stopping criterion. If norm(H) <= sqrt(OVFL), | */
311 /* | overflow should not occur. | */
312 /* | REFERENCE: LAPACK subroutine clahqr | */
313 /* %-----------------------------------------------% */
314
315 unfl = slamch_("safe minimum", (ftnlen)12);
316 q__1.r = 1.f / unfl, q__1.i = 0.f / unfl;
317 ovfl = q__1.r;
318 slabad_(&unfl, &ovfl);
319 ulp = slamch_("precision", (ftnlen)9);
320 smlnum = unfl * (*n / ulp);
321 first = FALSE_;
322 }
323
324 /* %-------------------------------% */
325 /* | Initialize timing statistics | */
326 /* | & message level for debugging | */
327 /* %-------------------------------% */
328
329 second_(&t0);
330 msglvl = debug_1.mcapps;
331
332 kplusp = *kev + *np;
333
334 /* %--------------------------------------------% */
335 /* | Initialize Q to the identity to accumulate | */
336 /* | the rotations and reflections | */
337 /* %--------------------------------------------% */
338
339 claset_("All", &kplusp, &kplusp, &c_b2, &c_b1, &q[q_offset], ldq, (ftnlen)
340 3);
341
342 /* %----------------------------------------------% */
343 /* | Quick return if there are no shifts to apply | */
344 /* %----------------------------------------------% */
345
346 if (*np == 0) {
347 goto L9000;
348 }
349
350 /* %----------------------------------------------% */
351 /* | Chase the bulge with the application of each | */
352 /* | implicit shift. Each shift is applied to the | */
353 /* | whole matrix including each block. | */
354 /* %----------------------------------------------% */
355
356 i__1 = *np;
357 for (jj = 1; jj <= i__1; ++jj) {
358 i__2 = jj;
359 sigma.r = shift[i__2].r, sigma.i = shift[i__2].i;
360
361 if (msglvl > 2) {
362 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit, "_napps: sh"
363 "ift number.", (ftnlen)21);
364 cvout_(&debug_1.logfil, &c__1, &sigma, &debug_1.ndigit, "_napps:"
365 " Value of the shift ", (ftnlen)27);
366 }
367
368 istart = 1;
369 L20:
370
371 i__2 = kplusp - 1;
372 for (i__ = istart; i__ <= i__2; ++i__) {
373
374 /* %----------------------------------------% */
375 /* | Check for splitting and deflation. Use | */
376 /* | a standard test as in the QR algorithm | */
377 /* | REFERENCE: LAPACK subroutine clahqr | */
378 /* %----------------------------------------% */
379
380 i__3 = i__ + i__ * h_dim1;
381 i__4 = i__ + 1 + (i__ + 1) * h_dim1;
382 tst1 = (r__1 = h__[i__3].r, dabs(r__1)) + (r__2 = r_imag(&h__[i__
383 + i__ * h_dim1]), dabs(r__2)) + ((r__3 = h__[i__4].r,
384 dabs(r__3)) + (r__4 = r_imag(&h__[i__ + 1 + (i__ + 1) *
385 h_dim1]), dabs(r__4)));
386 if (tst1 == 0.f) {
387 i__3 = kplusp - jj + 1;
388 tst1 = clanhs_("1", &i__3, &h__[h_offset], ldh, &workl[1], (
389 ftnlen)1);
390 }
391 i__3 = i__ + 1 + i__ * h_dim1;
392 /* Computing MAX */
393 r__2 = ulp * tst1;
394 if ((r__1 = h__[i__3].r, dabs(r__1)) <= dmax(r__2,smlnum)) {
395 if (msglvl > 0) {
396 ivout_(&debug_1.logfil, &c__1, &i__, &debug_1.ndigit,
397 "_napps: matrix splitting at row/column no.", (
398 ftnlen)42);
399 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit,
400 "_napps: matrix splitting with shift number.", (
401 ftnlen)43);
402 cvout_(&debug_1.logfil, &c__1, &h__[i__ + 1 + i__ *
403 h_dim1], &debug_1.ndigit, "_napps: off diagonal "
404 "element.", (ftnlen)29);
405 }
406 iend = i__;
407 i__3 = i__ + 1 + i__ * h_dim1;
408 h__[i__3].r = 0.f, h__[i__3].i = 0.f;
409 goto L40;
410 }
411 /* L30: */
412 }
413 iend = kplusp;
414 L40:
415
416 if (msglvl > 2) {
417 ivout_(&debug_1.logfil, &c__1, &istart, &debug_1.ndigit, "_napps"
418 ": Start of current block ", (ftnlen)31);
419 ivout_(&debug_1.logfil, &c__1, &iend, &debug_1.ndigit, "_napps: "
420 "End of current block ", (ftnlen)29);
421 }
422
423 /* %------------------------------------------------% */
424 /* | No reason to apply a shift to block of order 1 | */
425 /* | or if the current block starts after the point | */
426 /* | of compression since we'll discard this stuff | */
427 /* %------------------------------------------------% */
428
429 if (istart == iend || istart > *kev) {
430 goto L100;
431 }
432
433 i__2 = istart + istart * h_dim1;
434 h11.r = h__[i__2].r, h11.i = h__[i__2].i;
435 i__2 = istart + 1 + istart * h_dim1;
436 h21.r = h__[i__2].r, h21.i = h__[i__2].i;
437 q__1.r = h11.r - sigma.r, q__1.i = h11.i - sigma.i;
438 f.r = q__1.r, f.i = q__1.i;
439 g.r = h21.r, g.i = h21.i;
440
441 i__2 = iend - 1;
442 for (i__ = istart; i__ <= i__2; ++i__) {
443
444 /* %------------------------------------------------------% */
445 /* | Construct the plane rotation G to zero out the bulge | */
446 /* %------------------------------------------------------% */
447
448 clartg_(&f, &g, &c__, &s, &r__);
449 if (i__ > istart) {
450 i__3 = i__ + (i__ - 1) * h_dim1;
451 h__[i__3].r = r__.r, h__[i__3].i = r__.i;
452 i__3 = i__ + 1 + (i__ - 1) * h_dim1;
453 h__[i__3].r = 0.f, h__[i__3].i = 0.f;
454 }
455
456 /* %---------------------------------------------% */
457 /* | Apply rotation to the left of H; H <- G'*H | */
458 /* %---------------------------------------------% */
459
460 i__3 = kplusp;
461 for (j = i__; j <= i__3; ++j) {
462 i__4 = i__ + j * h_dim1;
463 q__2.r = c__ * h__[i__4].r, q__2.i = c__ * h__[i__4].i;
464 i__5 = i__ + 1 + j * h_dim1;
465 q__3.r = s.r * h__[i__5].r - s.i * h__[i__5].i, q__3.i = s.r *
466 h__[i__5].i + s.i * h__[i__5].r;
467 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
468 t.r = q__1.r, t.i = q__1.i;
469 i__4 = i__ + 1 + j * h_dim1;
470 r_cnjg(&q__4, &s);
471 q__3.r = -q__4.r, q__3.i = -q__4.i;
472 i__5 = i__ + j * h_dim1;
473 q__2.r = q__3.r * h__[i__5].r - q__3.i * h__[i__5].i, q__2.i =
474 q__3.r * h__[i__5].i + q__3.i * h__[i__5].r;
475 i__6 = i__ + 1 + j * h_dim1;
476 q__5.r = c__ * h__[i__6].r, q__5.i = c__ * h__[i__6].i;
477 q__1.r = q__2.r + q__5.r, q__1.i = q__2.i + q__5.i;
478 h__[i__4].r = q__1.r, h__[i__4].i = q__1.i;
479 i__4 = i__ + j * h_dim1;
480 h__[i__4].r = t.r, h__[i__4].i = t.i;
481 /* L50: */
482 }
483
484 /* %---------------------------------------------% */
485 /* | Apply rotation to the right of H; H <- H*G | */
486 /* %---------------------------------------------% */
487
488 /* Computing MIN */
489 i__4 = i__ + 2;
490 i__3 = min(i__4,iend);
491 for (j = 1; j <= i__3; ++j) {
492 i__4 = j + i__ * h_dim1;
493 q__2.r = c__ * h__[i__4].r, q__2.i = c__ * h__[i__4].i;
494 r_cnjg(&q__4, &s);
495 i__5 = j + (i__ + 1) * h_dim1;
496 q__3.r = q__4.r * h__[i__5].r - q__4.i * h__[i__5].i, q__3.i =
497 q__4.r * h__[i__5].i + q__4.i * h__[i__5].r;
498 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
499 t.r = q__1.r, t.i = q__1.i;
500 i__4 = j + (i__ + 1) * h_dim1;
501 q__3.r = -s.r, q__3.i = -s.i;
502 i__5 = j + i__ * h_dim1;
503 q__2.r = q__3.r * h__[i__5].r - q__3.i * h__[i__5].i, q__2.i =
504 q__3.r * h__[i__5].i + q__3.i * h__[i__5].r;
505 i__6 = j + (i__ + 1) * h_dim1;
506 q__4.r = c__ * h__[i__6].r, q__4.i = c__ * h__[i__6].i;
507 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
508 h__[i__4].r = q__1.r, h__[i__4].i = q__1.i;
509 i__4 = j + i__ * h_dim1;
510 h__[i__4].r = t.r, h__[i__4].i = t.i;
511 /* L60: */
512 }
513
514 /* %-----------------------------------------------------% */
515 /* | Accumulate the rotation in the matrix Q; Q <- Q*G' | */
516 /* %-----------------------------------------------------% */
517
518 /* Computing MIN */
519 i__4 = i__ + jj;
520 i__3 = min(i__4,kplusp);
521 for (j = 1; j <= i__3; ++j) {
522 i__4 = j + i__ * q_dim1;
523 q__2.r = c__ * q[i__4].r, q__2.i = c__ * q[i__4].i;
524 r_cnjg(&q__4, &s);
525 i__5 = j + (i__ + 1) * q_dim1;
526 q__3.r = q__4.r * q[i__5].r - q__4.i * q[i__5].i, q__3.i =
527 q__4.r * q[i__5].i + q__4.i * q[i__5].r;
528 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
529 t.r = q__1.r, t.i = q__1.i;
530 i__4 = j + (i__ + 1) * q_dim1;
531 q__3.r = -s.r, q__3.i = -s.i;
532 i__5 = j + i__ * q_dim1;
533 q__2.r = q__3.r * q[i__5].r - q__3.i * q[i__5].i, q__2.i =
534 q__3.r * q[i__5].i + q__3.i * q[i__5].r;
535 i__6 = j + (i__ + 1) * q_dim1;
536 q__4.r = c__ * q[i__6].r, q__4.i = c__ * q[i__6].i;
537 q__1.r = q__2.r + q__4.r, q__1.i = q__2.i + q__4.i;
538 q[i__4].r = q__1.r, q[i__4].i = q__1.i;
539 i__4 = j + i__ * q_dim1;
540 q[i__4].r = t.r, q[i__4].i = t.i;
541 /* L70: */
542 }
543
544 /* %---------------------------% */
545 /* | Prepare for next rotation | */
546 /* %---------------------------% */
547
548 if (i__ < iend - 1) {
549 i__3 = i__ + 1 + i__ * h_dim1;
550 f.r = h__[i__3].r, f.i = h__[i__3].i;
551 i__3 = i__ + 2 + i__ * h_dim1;
552 g.r = h__[i__3].r, g.i = h__[i__3].i;
553 }
554 /* L80: */
555 }
556
557 /* %-------------------------------% */
558 /* | Finished applying the shift. | */
559 /* %-------------------------------% */
560
561 L100:
562
563 /* %---------------------------------------------------------% */
564 /* | Apply the same shift to the next block if there is any. | */
565 /* %---------------------------------------------------------% */
566
567 istart = iend + 1;
568 if (iend < kplusp) {
569 goto L20;
570 }
571
572 /* %---------------------------------------------% */
573 /* | Loop back to the top to get the next shift. | */
574 /* %---------------------------------------------% */
575
576 /* L110: */
577 }
578
579 /* %---------------------------------------------------% */
580 /* | Perform a similarity transformation that makes | */
581 /* | sure that the compressed H will have non-negative | */
582 /* | real subdiagonal elements. | */
583 /* %---------------------------------------------------% */
584
585 i__1 = *kev;
586 for (j = 1; j <= i__1; ++j) {
587 i__2 = j + 1 + j * h_dim1;
588 if (h__[i__2].r < 0.f || r_imag(&h__[j + 1 + j * h_dim1]) != 0.f) {
589 i__2 = j + 1 + j * h_dim1;
590 i__3 = j + 1 + j * h_dim1;
591 r__2 = h__[i__3].r;
592 r__3 = r_imag(&h__[j + 1 + j * h_dim1]);
593 r__1 = slapy2_(&r__2, &r__3);
594 q__1.r = h__[i__2].r / r__1, q__1.i = h__[i__2].i / r__1;
595 t.r = q__1.r, t.i = q__1.i;
596 i__2 = kplusp - j + 1;
597 r_cnjg(&q__1, &t);
598 cscal_(&i__2, &q__1, &h__[j + 1 + j * h_dim1], ldh);
599 /* Computing MIN */
600 i__3 = j + 2;
601 i__2 = min(i__3,kplusp);
602 cscal_(&i__2, &t, &h__[(j + 1) * h_dim1 + 1], &c__1);
603 /* Computing MIN */
604 i__3 = j + *np + 1;
605 i__2 = min(i__3,kplusp);
606 cscal_(&i__2, &t, &q[(j + 1) * q_dim1 + 1], &c__1);
607 i__2 = j + 1 + j * h_dim1;
608 i__3 = j + 1 + j * h_dim1;
609 r__1 = h__[i__3].r;
610 q__1.r = r__1, q__1.i = 0.f;
611 h__[i__2].r = q__1.r, h__[i__2].i = q__1.i;
612 }
613 /* L120: */
614 }
615
616 i__1 = *kev;
617 for (i__ = 1; i__ <= i__1; ++i__) {
618
619 /* %--------------------------------------------% */
620 /* | Final check for splitting and deflation. | */
621 /* | Use a standard test as in the QR algorithm | */
622 /* | REFERENCE: LAPACK subroutine clahqr. | */
623 /* | Note: Since the subdiagonals of the | */
624 /* | compressed H are nonnegative real numbers, | */
625 /* | we take advantage of this. | */
626 /* %--------------------------------------------% */
627
628 i__2 = i__ + i__ * h_dim1;
629 i__3 = i__ + 1 + (i__ + 1) * h_dim1;
630 tst1 = (r__1 = h__[i__2].r, dabs(r__1)) + (r__2 = r_imag(&h__[i__ +
631 i__ * h_dim1]), dabs(r__2)) + ((r__3 = h__[i__3].r, dabs(r__3)
632 ) + (r__4 = r_imag(&h__[i__ + 1 + (i__ + 1) * h_dim1]), dabs(
633 r__4)));
634 if (tst1 == 0.f) {
635 tst1 = clanhs_("1", kev, &h__[h_offset], ldh, &workl[1], (ftnlen)
636 1);
637 }
638 i__2 = i__ + 1 + i__ * h_dim1;
639 /* Computing MAX */
640 r__1 = ulp * tst1;
641 if (h__[i__2].r <= dmax(r__1,smlnum)) {
642 i__3 = i__ + 1 + i__ * h_dim1;
643 h__[i__3].r = 0.f, h__[i__3].i = 0.f;
644 }
645 /* L130: */
646 }
647
648 /* %-------------------------------------------------% */
649 /* | Compute the (kev+1)-st column of (V*Q) and | */
650 /* | temporarily store the result in WORKD(N+1:2*N). | */
651 /* | This is needed in the residual update since we | */
652 /* | cannot GUARANTEE that the corresponding entry | */
653 /* | of H would be zero as in exact arithmetic. | */
654 /* %-------------------------------------------------% */
655
656 i__1 = *kev + 1 + *kev * h_dim1;
657 if (h__[i__1].r > 0.f) {
658 cgemv_("N", n, &kplusp, &c_b1, &v[v_offset], ldv, &q[(*kev + 1) *
659 q_dim1 + 1], &c__1, &c_b2, &workd[*n + 1], &c__1, (ftnlen)1);
660 }
661
662 /* %----------------------------------------------------------% */
663 /* | Compute column 1 to kev of (V*Q) in backward order | */
664 /* | taking advantage of the upper Hessenberg structure of Q. | */
665 /* %----------------------------------------------------------% */
666
667 i__1 = *kev;
668 for (i__ = 1; i__ <= i__1; ++i__) {
669 i__2 = kplusp - i__ + 1;
670 cgemv_("N", n, &i__2, &c_b1, &v[v_offset], ldv, &q[(*kev - i__ + 1) *
671 q_dim1 + 1], &c__1, &c_b2, &workd[1], &c__1, (ftnlen)1);
672 ccopy_(n, &workd[1], &c__1, &v[(kplusp - i__ + 1) * v_dim1 + 1], &
673 c__1);
674 /* L140: */
675 }
676
677 /* %-------------------------------------------------% */
678 /* | Move v(:,kplusp-kev+1:kplusp) into v(:,1:kev). | */
679 /* %-------------------------------------------------% */
680
681 clacpy_("A", n, kev, &v[(kplusp - *kev + 1) * v_dim1 + 1], ldv, &v[
682 v_offset], ldv, (ftnlen)1);
683
684 /* %--------------------------------------------------------------% */
685 /* | Copy the (kev+1)-st column of (V*Q) in the appropriate place | */
686 /* %--------------------------------------------------------------% */
687
688 i__1 = *kev + 1 + *kev * h_dim1;
689 if (h__[i__1].r > 0.f) {
690 ccopy_(n, &workd[*n + 1], &c__1, &v[(*kev + 1) * v_dim1 + 1], &c__1);
691 }
692
693 /* %-------------------------------------% */
694 /* | Update the residual vector: | */
695 /* | r <- sigmak*r + betak*v(:,kev+1) | */
696 /* | where | */
697 /* | sigmak = (e_{kev+p}'*Q)*e_{kev} | */
698 /* | betak = e_{kev+1}'*H*e_{kev} | */
699 /* %-------------------------------------% */
700
701 cscal_(n, &q[kplusp + *kev * q_dim1], &resid[1], &c__1);
702 i__1 = *kev + 1 + *kev * h_dim1;
703 if (h__[i__1].r > 0.f) {
704 caxpy_(n, &h__[*kev + 1 + *kev * h_dim1], &v[(*kev + 1) * v_dim1 + 1],
705 &c__1, &resid[1], &c__1);
706 }
707
708 if (msglvl > 1) {
709 cvout_(&debug_1.logfil, &c__1, &q[kplusp + *kev * q_dim1], &
710 debug_1.ndigit, "_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}", (
711 ftnlen)40);
712 cvout_(&debug_1.logfil, &c__1, &h__[*kev + 1 + *kev * h_dim1], &
713 debug_1.ndigit, "_napps: betak = e_{kev+1}^T*H*e_{kev}", (
714 ftnlen)37);
715 ivout_(&debug_1.logfil, &c__1, kev, &debug_1.ndigit, "_napps: Order "
716 "of the final Hessenberg matrix ", (ftnlen)45);
717 if (msglvl > 2) {
718 cmout_(&debug_1.logfil, kev, kev, &h__[h_offset], ldh, &
719 debug_1.ndigit, "_napps: updated Hessenberg matrix H for"
720 " next iteration", (ftnlen)54);
721 }
722
723 }
724
725 L9000:
726 second_(&t1);
727 timing_1.tcapps += t1 - t0;
728
729 return 0;
730
731 /* %---------------% */
732 /* | End of cnapps | */
733 /* %---------------% */
734
735 } /* cnapps_ */
736