Debian Codegraph @

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

raw
1 /* ./src_f77/dnapps.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_DNAPPS;
15
16 #define debug_1 debug_DNAPPS
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_DNAPPS;
25
26 #define timing_1 timing_DNAPPS
27
28 /* Table of constant values */
29
30 static doublereal c_b5 = 0.;
31 static doublereal c_b6 = 1.;
32 static integer c__1 = 1;
33 static doublereal c_b43 = -1.;
34
35 /* ----------------------------------------------------------------------- */
36 /* \BeginDoc */
37
38 /* \Name: dnapps */
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 dnapps */
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, Double precision array of length NP. (INPUT) */
74 /* SHIFTI Real and imaginary part of the shifts to be applied. */
75 /* Upon, entry to dnapps, the shifts must be sorted so that the */
76 /* conjugate pairs are in consecutive locations. */
77
78 /* V Double precision 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 Double precision (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 Double precision 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 Double precision 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 Double precision 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 Double precision 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 /* dmout ARPACK utility routine that prints matrices. */
136 /* dvout ARPACK utility routine that prints vectors. */
137 /* dlabad LAPACK routine that computes machine constants. */
138 /* dlacpy LAPACK matrix copy routine. */
139 /* dlamch LAPACK routine that determines machine constants. */
140 /* dlanhs LAPACK routine that computes various norms of a matrix. */
141 /* dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */
142 /* dlarf LAPACK routine that applies Householder reflection to */
143 /* a matrix. */
144 /* dlarfg LAPACK Householder reflection construction routine. */
145 /* dlartg LAPACK Givens rotation construction routine. */
146 /* dlaset LAPACK matrix initialization routine. */
147 /* dgemv Level 2 BLAS routine for matrix vector multiplication. */
148 /* daxpy Level 1 BLAS that computes a vector triad. */
149 /* dcopy Level 1 BLAS that copies one vector to another . */
150 /* dscal 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 dlahqr (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 dnapps_(integer *n, integer *kev, integer *np,
178 doublereal *shiftr, doublereal *shifti, doublereal *v, integer *ldv,
179 doublereal *h__, integer *ldh, doublereal *resid, doublereal *q,
180 integer *ldq, doublereal *workl, doublereal *workd)
181 {
182 /* Initialized data */
183
184 static logical first = TRUE_;
185
186 /* System generated locals */
187 integer h_dim1, h_offset, v_dim1, v_offset, q_dim1, q_offset, i__1, i__2,
188 i__3, i__4;
189 doublereal d__1, d__2;
190
191 /* Local variables */
192 static doublereal c__, f, g;
193 static integer i__, j;
194 static doublereal r__, s, t, u[3];
195 static real t0, t1;
196 static doublereal h11, h12, h21, h22, h32;
197 static integer jj, ir, nr;
198 static doublereal tau, ulp, tst1;
199 static integer iend;
200 static doublereal unfl, ovfl;
201 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
202 integer *), dlarf_(char *, integer *, integer *, doublereal *,
203 integer *, doublereal *, doublereal *, integer *, doublereal *,
204 ftnlen);
205 static logical cconj;
206 extern /* Subroutine */ int dgemv_(char *, integer *, integer *,
207 doublereal *, doublereal *, integer *, doublereal *, integer *,
208 doublereal *, doublereal *, integer *, ftnlen), dcopy_(integer *,
209 doublereal *, integer *, doublereal *, integer *), daxpy_(integer
210 *, doublereal *, doublereal *, integer *, doublereal *, integer *)
211 , dmout_(integer *, integer *, integer *, doublereal *, integer *,
212 integer *, char *, ftnlen), dvout_(integer *, integer *,
213 doublereal *, integer *, char *, ftnlen), ivout_(integer *,
214 integer *, integer *, integer *, char *, ftnlen);
215 extern doublereal dlapy2_(doublereal *, doublereal *);
216 extern /* Subroutine */ int dlabad_(doublereal *, doublereal *);
217 extern doublereal dlamch_(char *, ftnlen);
218 extern /* Subroutine */ int dlarfg_(integer *, doublereal *, doublereal *,
219 integer *, doublereal *);
220 static doublereal sigmai;
221 extern /* Subroutine */ int second_(real *);
222 static integer istart, kplusp, msglvl;
223 static doublereal sigmar, smlnum;
224 extern /* Subroutine */ int dlacpy_(char *, integer *, integer *,
225 doublereal *, integer *, doublereal *, integer *, ftnlen),
226 dlaset_(char *, integer *, integer *, doublereal *, doublereal *,
227 doublereal *, integer *, ftnlen), dlartg_(doublereal *,
228 doublereal *, doublereal *, doublereal *, doublereal *);
229 extern doublereal dlanhs_(char *, integer *, doublereal *, integer *,
230 doublereal *, ftnlen);
231
232
233 /* %----------------------------------------------------% */
234 /* | Include files for debugging and timing information | */
235 /* %----------------------------------------------------% */
236
237
238 /* \SCCS Information: @(#) */
239 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
240
241 /* %---------------------------------% */
242 /* | See debug.doc for documentation | */
243 /* %---------------------------------% */
244
245 /* %------------------% */
246 /* | Scalar Arguments | */
247 /* %------------------% */
248
249 /* %--------------------------------% */
250 /* | See stat.doc for documentation | */
251 /* %--------------------------------% */
252
253 /* \SCCS Information: @(#) */
254 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
255
256
257
258 /* %-----------------% */
259 /* | Array Arguments | */
260 /* %-----------------% */
261
262
263 /* %------------% */
264 /* | Parameters | */
265 /* %------------% */
266
267
268 /* %------------------------% */
269 /* | Local Scalars & Arrays | */
270 /* %------------------------% */
271
272
273 /* %----------------------% */
274 /* | External Subroutines | */
275 /* %----------------------% */
276
277
278 /* %--------------------% */
279 /* | External Functions | */
280 /* %--------------------% */
281
282
283 /* %----------------------% */
284 /* | Intrinsics Functions | */
285 /* %----------------------% */
286
287
288 /* %----------------% */
289 /* | Data statments | */
290 /* %----------------% */
291
292 /* Parameter adjustments */
293 --workd;
294 --resid;
295 --workl;
296 --shifti;
297 --shiftr;
298 v_dim1 = *ldv;
299 v_offset = 1 + v_dim1;
300 v -= v_offset;
301 h_dim1 = *ldh;
302 h_offset = 1 + h_dim1;
303 h__ -= h_offset;
304 q_dim1 = *ldq;
305 q_offset = 1 + q_dim1;
306 q -= q_offset;
307
308 /* Function Body */
309
310 /* %-----------------------% */
311 /* | Executable Statements | */
312 /* %-----------------------% */
313
314 if (first) {
315
316 /* %-----------------------------------------------% */
317 /* | Set machine-dependent constants for the | */
318 /* | stopping criterion. If norm(H) <= sqrt(OVFL), | */
319 /* | overflow should not occur. | */
320 /* | REFERENCE: LAPACK subroutine dlahqr | */
321 /* %-----------------------------------------------% */
322
323 unfl = dlamch_("safe minimum", (ftnlen)12);
324 ovfl = 1. / unfl;
325 dlabad_(&unfl, &ovfl);
326 ulp = dlamch_("precision", (ftnlen)9);
327 smlnum = unfl * (*n / ulp);
328 first = FALSE_;
329 }
330
331 /* %-------------------------------% */
332 /* | Initialize timing statistics | */
333 /* | & message level for debugging | */
334 /* %-------------------------------% */
335
336 second_(&t0);
337 msglvl = debug_1.mnapps;
338 kplusp = *kev + *np;
339
340 /* %--------------------------------------------% */
341 /* | Initialize Q to the identity to accumulate | */
342 /* | the rotations and reflections | */
343 /* %--------------------------------------------% */
344
345 dlaset_("All", &kplusp, &kplusp, &c_b5, &c_b6, &q[q_offset], ldq, (ftnlen)
346 3);
347
348 /* %----------------------------------------------% */
349 /* | Quick return if there are no shifts to apply | */
350 /* %----------------------------------------------% */
351
352 if (*np == 0) {
353 goto L9000;
354 }
355
356 /* %----------------------------------------------% */
357 /* | Chase the bulge with the application of each | */
358 /* | implicit shift. Each shift is applied to the | */
359 /* | whole matrix including each block. | */
360 /* %----------------------------------------------% */
361
362 cconj = FALSE_;
363 i__1 = *np;
364 for (jj = 1; jj <= i__1; ++jj) {
365 sigmar = shiftr[jj];
366 sigmai = shifti[jj];
367
368 if (msglvl > 2) {
369 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit, "_napps: sh"
370 "ift number.", (ftnlen)21);
371 dvout_(&debug_1.logfil, &c__1, &sigmar, &debug_1.ndigit, "_napps"
372 ": The real part of the shift ", (ftnlen)35);
373 dvout_(&debug_1.logfil, &c__1, &sigmai, &debug_1.ndigit, "_napps"
374 ": The imaginary part of the shift ", (ftnlen)40);
375 }
376
377 /* %-------------------------------------------------% */
378 /* | The following set of conditionals is necessary | */
379 /* | in order that complex conjugate pairs of shifts | */
380 /* | are applied together or not at all. | */
381 /* %-------------------------------------------------% */
382
383 if (cconj) {
384
385 /* %-----------------------------------------% */
386 /* | cconj = .true. means the previous shift | */
387 /* | had non-zero imaginary part. | */
388 /* %-----------------------------------------% */
389
390 cconj = FALSE_;
391 goto L110;
392 } else if (jj < *np && abs(sigmai) > 0.) {
393
394 /* %------------------------------------% */
395 /* | Start of a complex conjugate pair. | */
396 /* %------------------------------------% */
397
398 cconj = TRUE_;
399 } else if (jj == *np && abs(sigmai) > 0.) {
400
401 /* %----------------------------------------------% */
402 /* | The last shift has a nonzero imaginary part. | */
403 /* | Don't apply it; thus the order of the | */
404 /* | compressed H is order KEV+1 since only np-1 | */
405 /* | were applied. | */
406 /* %----------------------------------------------% */
407
408 ++(*kev);
409 goto L110;
410 }
411 istart = 1;
412 L20:
413
414 /* %--------------------------------------------------% */
415 /* | if sigmai = 0 then | */
416 /* | Apply the jj-th shift ... | */
417 /* | else | */
418 /* | Apply the jj-th and (jj+1)-th together ... | */
419 /* | (Note that jj < np at this point in the code) | */
420 /* | end | */
421 /* | to the current block of H. The next do loop | */
422 /* | determines the current block ; | */
423 /* %--------------------------------------------------% */
424
425 i__2 = kplusp - 1;
426 for (i__ = istart; i__ <= i__2; ++i__) {
427
428 /* %----------------------------------------% */
429 /* | Check for splitting and deflation. Use | */
430 /* | a standard test as in the QR algorithm | */
431 /* | REFERENCE: LAPACK subroutine dlahqr | */
432 /* %----------------------------------------% */
433
434 tst1 = (d__1 = h__[i__ + i__ * h_dim1], abs(d__1)) + (d__2 = h__[
435 i__ + 1 + (i__ + 1) * h_dim1], abs(d__2));
436 if (tst1 == 0.) {
437 i__3 = kplusp - jj + 1;
438 tst1 = dlanhs_("1", &i__3, &h__[h_offset], ldh, &workl[1], (
439 ftnlen)1);
440 }
441 /* Computing MAX */
442 d__2 = ulp * tst1;
443 if ((d__1 = h__[i__ + 1 + i__ * h_dim1], abs(d__1)) <= max(d__2,
444 smlnum)) {
445 if (msglvl > 0) {
446 ivout_(&debug_1.logfil, &c__1, &i__, &debug_1.ndigit,
447 "_napps: matrix splitting at row/column no.", (
448 ftnlen)42);
449 ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit,
450 "_napps: matrix splitting with shift number.", (
451 ftnlen)43);
452 dvout_(&debug_1.logfil, &c__1, &h__[i__ + 1 + i__ *
453 h_dim1], &debug_1.ndigit, "_napps: off diagonal "
454 "element.", (ftnlen)29);
455 }
456 iend = i__;
457 h__[i__ + 1 + i__ * h_dim1] = 0.;
458 goto L40;
459 }
460 /* L30: */
461 }
462 iend = kplusp;
463 L40:
464
465 if (msglvl > 2) {
466 ivout_(&debug_1.logfil, &c__1, &istart, &debug_1.ndigit, "_napps"
467 ": Start of current block ", (ftnlen)31);
468 ivout_(&debug_1.logfil, &c__1, &iend, &debug_1.ndigit, "_napps: "
469 "End of current block ", (ftnlen)29);
470 }
471
472 /* %------------------------------------------------% */
473 /* | No reason to apply a shift to block of order 1 | */
474 /* %------------------------------------------------% */
475
476 if (istart == iend) {
477 goto L100;
478 }
479
480 /* %------------------------------------------------------% */
481 /* | If istart + 1 = iend then no reason to apply a | */
482 /* | complex conjugate pair of shifts on a 2 by 2 matrix. | */
483 /* %------------------------------------------------------% */
484
485 if (istart + 1 == iend && abs(sigmai) > 0.) {
486 goto L100;
487 }
488
489 h11 = h__[istart + istart * h_dim1];
490 h21 = h__[istart + 1 + istart * h_dim1];
491 if (abs(sigmai) <= 0.) {
492
493 /* %---------------------------------------------% */
494 /* | Real-valued shift ==> apply single shift QR | */
495 /* %---------------------------------------------% */
496
497 f = h11 - sigmar;
498 g = h21;
499
500 i__2 = iend - 1;
501 for (i__ = istart; i__ <= i__2; ++i__) {
502
503 /* %-----------------------------------------------------% */
504 /* | Contruct the plane rotation G to zero out the bulge | */
505 /* %-----------------------------------------------------% */
506
507 dlartg_(&f, &g, &c__, &s, &r__);
508 if (i__ > istart) {
509
510 /* %-------------------------------------------% */
511 /* | The following ensures that h(1:iend-1,1), | */
512 /* | the first iend-2 off diagonal of elements | */
513 /* | H, remain non negative. | */
514 /* %-------------------------------------------% */
515
516 if (r__ < 0.) {
517 r__ = -r__;
518 c__ = -c__;
519 s = -s;
520 }
521 h__[i__ + (i__ - 1) * h_dim1] = r__;
522 h__[i__ + 1 + (i__ - 1) * h_dim1] = 0.;
523 }
524
525 /* %---------------------------------------------% */
526 /* | Apply rotation to the left of H; H <- G'*H | */
527 /* %---------------------------------------------% */
528
529 i__3 = kplusp;
530 for (j = i__; j <= i__3; ++j) {
531 t = c__ * h__[i__ + j * h_dim1] + s * h__[i__ + 1 + j *
532 h_dim1];
533 h__[i__ + 1 + j * h_dim1] = -s * h__[i__ + j * h_dim1] +
534 c__ * h__[i__ + 1 + j * h_dim1];
535 h__[i__ + j * h_dim1] = t;
536 /* L50: */
537 }
538
539 /* %---------------------------------------------% */
540 /* | Apply rotation to the right of H; H <- H*G | */
541 /* %---------------------------------------------% */
542
543 /* Computing MIN */
544 i__4 = i__ + 2;
545 i__3 = min(i__4,iend);
546 for (j = 1; j <= i__3; ++j) {
547 t = c__ * h__[j + i__ * h_dim1] + s * h__[j + (i__ + 1) *
548 h_dim1];
549 h__[j + (i__ + 1) * h_dim1] = -s * h__[j + i__ * h_dim1]
550 + c__ * h__[j + (i__ + 1) * h_dim1];
551 h__[j + i__ * h_dim1] = t;
552 /* L60: */
553 }
554
555 /* %----------------------------------------------------% */
556 /* | Accumulate the rotation in the matrix Q; Q <- Q*G | */
557 /* %----------------------------------------------------% */
558
559 /* Computing MIN */
560 i__4 = i__ + jj;
561 i__3 = min(i__4,kplusp);
562 for (j = 1; j <= i__3; ++j) {
563 t = c__ * q[j + i__ * q_dim1] + s * q[j + (i__ + 1) *
564 q_dim1];
565 q[j + (i__ + 1) * q_dim1] = -s * q[j + i__ * q_dim1] +
566 c__ * q[j + (i__ + 1) * q_dim1];
567 q[j + i__ * q_dim1] = t;
568 /* L70: */
569 }
570
571 /* %---------------------------% */
572 /* | Prepare for next rotation | */
573 /* %---------------------------% */
574
575 if (i__ < iend - 1) {
576 f = h__[i__ + 1 + i__ * h_dim1];
577 g = h__[i__ + 2 + i__ * h_dim1];
578 }
579 /* L80: */
580 }
581
582 /* %-----------------------------------% */
583 /* | Finished applying the real shift. | */
584 /* %-----------------------------------% */
585
586 } else {
587
588 /* %----------------------------------------------------% */
589 /* | Complex conjugate shifts ==> apply double shift QR | */
590 /* %----------------------------------------------------% */
591
592 h12 = h__[istart + (istart + 1) * h_dim1];
593 h22 = h__[istart + 1 + (istart + 1) * h_dim1];
594 h32 = h__[istart + 2 + (istart + 1) * h_dim1];
595
596 /* %---------------------------------------------------------% */
597 /* | Compute 1st column of (H - shift*I)*(H - conj(shift)*I) | */
598 /* %---------------------------------------------------------% */
599
600 s = sigmar * 2.f;
601 t = dlapy2_(&sigmar, &sigmai);
602 u[0] = (h11 * (h11 - s) + t * t) / h21 + h12;
603 u[1] = h11 + h22 - s;
604 u[2] = h32;
605
606 i__2 = iend - 1;
607 for (i__ = istart; i__ <= i__2; ++i__) {
608
609 /* Computing MIN */
610 i__3 = 3, i__4 = iend - i__ + 1;
611 nr = min(i__3,i__4);
612
613 /* %-----------------------------------------------------% */
614 /* | Construct Householder reflector G to zero out u(1). | */
615 /* | G is of the form I - tau*( 1 u )' * ( 1 u' ). | */
616 /* %-----------------------------------------------------% */
617
618 dlarfg_(&nr, u, &u[1], &c__1, &tau);
619
620 if (i__ > istart) {
621 h__[i__ + (i__ - 1) * h_dim1] = u[0];
622 h__[i__ + 1 + (i__ - 1) * h_dim1] = 0.;
623 if (i__ < iend - 1) {
624 h__[i__ + 2 + (i__ - 1) * h_dim1] = 0.;
625 }
626 }
627 u[0] = 1.;
628
629 /* %--------------------------------------% */
630 /* | Apply the reflector to the left of H | */
631 /* %--------------------------------------% */
632
633 i__3 = kplusp - i__ + 1;
634 dlarf_("Left", &nr, &i__3, u, &c__1, &tau, &h__[i__ + i__ *
635 h_dim1], ldh, &workl[1], (ftnlen)4);
636
637 /* %---------------------------------------% */
638 /* | Apply the reflector to the right of H | */
639 /* %---------------------------------------% */
640
641 /* Computing MIN */
642 i__3 = i__ + 3;
643 ir = min(i__3,iend);
644 dlarf_("Right", &ir, &nr, u, &c__1, &tau, &h__[i__ * h_dim1 +
645 1], ldh, &workl[1], (ftnlen)5);
646
647 /* %-----------------------------------------------------% */
648 /* | Accumulate the reflector in the matrix Q; Q <- Q*G | */
649 /* %-----------------------------------------------------% */
650
651 dlarf_("Right", &kplusp, &nr, u, &c__1, &tau, &q[i__ * q_dim1
652 + 1], ldq, &workl[1], (ftnlen)5);
653
654 /* %----------------------------% */
655 /* | Prepare for next reflector | */
656 /* %----------------------------% */
657
658 if (i__ < iend - 1) {
659 u[0] = h__[i__ + 1 + i__ * h_dim1];
660 u[1] = h__[i__ + 2 + i__ * h_dim1];
661 if (i__ < iend - 2) {
662 u[2] = h__[i__ + 3 + i__ * h_dim1];
663 }
664 }
665
666 /* L90: */
667 }
668
669 /* %--------------------------------------------% */
670 /* | Finished applying a complex pair of shifts | */
671 /* | to the current block | */
672 /* %--------------------------------------------% */
673
674 }
675
676 L100:
677
678 /* %---------------------------------------------------------% */
679 /* | Apply the same shift to the next block if there is any. | */
680 /* %---------------------------------------------------------% */
681
682 istart = iend + 1;
683 if (iend < kplusp) {
684 goto L20;
685 }
686
687 /* %---------------------------------------------% */
688 /* | Loop back to the top to get the next shift. | */
689 /* %---------------------------------------------% */
690
691 L110:
692 ;
693 }
694
695 /* %--------------------------------------------------% */
696 /* | Perform a similarity transformation that makes | */
697 /* | sure that H will have non negative sub diagonals | */
698 /* %--------------------------------------------------% */
699
700 i__1 = *kev;
701 for (j = 1; j <= i__1; ++j) {
702 if (h__[j + 1 + j * h_dim1] < 0.) {
703 i__2 = kplusp - j + 1;
704 dscal_(&i__2, &c_b43, &h__[j + 1 + j * h_dim1], ldh);
705 /* Computing MIN */
706 i__3 = j + 2;
707 i__2 = min(i__3,kplusp);
708 dscal_(&i__2, &c_b43, &h__[(j + 1) * h_dim1 + 1], &c__1);
709 /* Computing MIN */
710 i__3 = j + *np + 1;
711 i__2 = min(i__3,kplusp);
712 dscal_(&i__2, &c_b43, &q[(j + 1) * q_dim1 + 1], &c__1);
713 }
714 /* L120: */
715 }
716
717 i__1 = *kev;
718 for (i__ = 1; i__ <= i__1; ++i__) {
719
720 /* %--------------------------------------------% */
721 /* | Final check for splitting and deflation. | */
722 /* | Use a standard test as in the QR algorithm | */
723 /* | REFERENCE: LAPACK subroutine dlahqr | */
724 /* %--------------------------------------------% */
725
726 tst1 = (d__1 = h__[i__ + i__ * h_dim1], abs(d__1)) + (d__2 = h__[i__
727 + 1 + (i__ + 1) * h_dim1], abs(d__2));
728 if (tst1 == 0.) {
729 tst1 = dlanhs_("1", kev, &h__[h_offset], ldh, &workl[1], (ftnlen)
730 1);
731 }
732 /* Computing MAX */
733 d__1 = ulp * tst1;
734 if (h__[i__ + 1 + i__ * h_dim1] <= max(d__1,smlnum)) {
735 h__[i__ + 1 + i__ * h_dim1] = 0.;
736 }
737 /* L130: */
738 }
739
740 /* %-------------------------------------------------% */
741 /* | Compute the (kev+1)-st column of (V*Q) and | */
742 /* | temporarily store the result in WORKD(N+1:2*N). | */
743 /* | This is needed in the residual update since we | */
744 /* | cannot GUARANTEE that the corresponding entry | */
745 /* | of H would be zero as in exact arithmetic. | */
746 /* %-------------------------------------------------% */
747
748 if (h__[*kev + 1 + *kev * h_dim1] > 0.) {
749 dgemv_("N", n, &kplusp, &c_b6, &v[v_offset], ldv, &q[(*kev + 1) *
750 q_dim1 + 1], &c__1, &c_b5, &workd[*n + 1], &c__1, (ftnlen)1);
751 }
752
753 /* %----------------------------------------------------------% */
754 /* | Compute column 1 to kev of (V*Q) in backward order | */
755 /* | taking advantage of the upper Hessenberg structure of Q. | */
756 /* %----------------------------------------------------------% */
757
758 i__1 = *kev;
759 for (i__ = 1; i__ <= i__1; ++i__) {
760 i__2 = kplusp - i__ + 1;
761 dgemv_("N", n, &i__2, &c_b6, &v[v_offset], ldv, &q[(*kev - i__ + 1) *
762 q_dim1 + 1], &c__1, &c_b5, &workd[1], &c__1, (ftnlen)1);
763 dcopy_(n, &workd[1], &c__1, &v[(kplusp - i__ + 1) * v_dim1 + 1], &
764 c__1);
765 /* L140: */
766 }
767
768 /* %-------------------------------------------------% */
769 /* | Move v(:,kplusp-kev+1:kplusp) into v(:,1:kev). | */
770 /* %-------------------------------------------------% */
771
772 dlacpy_("A", n, kev, &v[(kplusp - *kev + 1) * v_dim1 + 1], ldv, &v[
773 v_offset], ldv, (ftnlen)1);
774
775 /* %--------------------------------------------------------------% */
776 /* | Copy the (kev+1)-st column of (V*Q) in the appropriate place | */
777 /* %--------------------------------------------------------------% */
778
779 if (h__[*kev + 1 + *kev * h_dim1] > 0.) {
780 dcopy_(n, &workd[*n + 1], &c__1, &v[(*kev + 1) * v_dim1 + 1], &c__1);
781 }
782
783 /* %-------------------------------------% */
784 /* | Update the residual vector: | */
785 /* | r <- sigmak*r + betak*v(:,kev+1) | */
786 /* | where | */
787 /* | sigmak = (e_{kplusp}'*Q)*e_{kev} | */
788 /* | betak = e_{kev+1}'*H*e_{kev} | */
789 /* %-------------------------------------% */
790
791 dscal_(n, &q[kplusp + *kev * q_dim1], &resid[1], &c__1);
792 if (h__[*kev + 1 + *kev * h_dim1] > 0.) {
793 daxpy_(n, &h__[*kev + 1 + *kev * h_dim1], &v[(*kev + 1) * v_dim1 + 1],
794 &c__1, &resid[1], &c__1);
795 }
796
797 if (msglvl > 1) {
798 dvout_(&debug_1.logfil, &c__1, &q[kplusp + *kev * q_dim1], &
799 debug_1.ndigit, "_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}", (
800 ftnlen)40);
801 dvout_(&debug_1.logfil, &c__1, &h__[*kev + 1 + *kev * h_dim1], &
802 debug_1.ndigit, "_napps: betak = e_{kev+1}^T*H*e_{kev}", (
803 ftnlen)37);
804 ivout_(&debug_1.logfil, &c__1, kev, &debug_1.ndigit, "_napps: Order "
805 "of the final Hessenberg matrix ", (ftnlen)45);
806 if (msglvl > 2) {
807 dmout_(&debug_1.logfil, kev, kev, &h__[h_offset], ldh, &
808 debug_1.ndigit, "_napps: updated Hessenberg matrix H for"
809 " next iteration", (ftnlen)54);
810 }
811
812 }
813
814 L9000:
815 second_(&t1);
816 timing_1.tnapps += t1 - t0;
817
818 return 0;
819
820 /* %---------------% */
821 /* | End of dnapps | */
822 /* %---------------% */
823
824 } /* dnapps_ */
825