Debian Codegraph @

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

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