Debian Codegraph @

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

raw
1 /* ./src_f77/zneigh.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_ZNEIGH;
15
16 #define debug_1 debug_ZNEIGH
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_ZNEIGH;
25
26 #define timing_1 timing_ZNEIGH
27
28 /* Table of constant values */
29
30 static doublecomplex c_b1 = {1.,0.};
31 static doublecomplex c_b2 = {0.,0.};
32 static logical c_true = TRUE_;
33 static integer c__1 = 1;
34
35 /* \BeginDoc */
36
37 /* \Name: zneigh */
38
39 /* \Description: */
40 /* Compute the eigenvalues of the current upper Hessenberg matrix */
41 /* and the corresponding Ritz estimates given the current residual norm. */
42
43 /* \Usage: */
44 /* call zneigh */
45 /* ( RNORM, N, H, LDH, RITZ, BOUNDS, Q, LDQ, WORKL, RWORK, IERR ) */
46
47 /* \Arguments */
48 /* RNORM Double precision scalar. (INPUT) */
49 /* Residual norm corresponding to the current upper Hessenberg */
50 /* matrix H. */
51
52 /* N Integer. (INPUT) */
53 /* Size of the matrix H. */
54
55 /* H Complex*16 N by N array. (INPUT) */
56 /* H contains the current upper Hessenberg matrix. */
57
58 /* LDH Integer. (INPUT) */
59 /* Leading dimension of H exactly as declared in the calling */
60 /* program. */
61
62 /* RITZ Complex*16 array of length N. (OUTPUT) */
63 /* On output, RITZ(1:N) contains the eigenvalues of H. */
64
65 /* BOUNDS Complex*16 array of length N. (OUTPUT) */
66 /* On output, BOUNDS contains the Ritz estimates associated with */
67 /* the eigenvalues held in RITZ. This is equal to RNORM */
68 /* times the last components of the eigenvectors corresponding */
69 /* to the eigenvalues in RITZ. */
70
71 /* Q Complex*16 N by N array. (WORKSPACE) */
72 /* Workspace needed to store the eigenvectors of H. */
73
74 /* LDQ Integer. (INPUT) */
75 /* Leading dimension of Q exactly as declared in the calling */
76 /* program. */
77
78 /* WORKL Complex*16 work array of length N**2 + 3*N. (WORKSPACE) */
79 /* Private (replicated) array on each PE or array allocated on */
80 /* the front end. This is needed to keep the full Schur form */
81 /* of H and also in the calculation of the eigenvectors of H. */
82
83 /* RWORK Double precision work array of length N (WORKSPACE) */
84 /* Private (replicated) array on each PE or array allocated on */
85 /* the front end. */
86
87 /* IERR Integer. (OUTPUT) */
88 /* Error exit flag from zlahqr or ztrevc. */
89
90 /* \EndDoc */
91
92 /* ----------------------------------------------------------------------- */
93
94 /* \BeginLib */
95
96 /* \Local variables: */
97 /* xxxxxx Complex*16 */
98
99 /* \Routines called: */
100 /* ivout ARPACK utility routine that prints integers. */
101 /* second ARPACK utility routine for timing. */
102 /* zmout ARPACK utility routine that prints matrices */
103 /* zvout ARPACK utility routine that prints vectors. */
104 /* dvout ARPACK utility routine that prints vectors. */
105 /* zlacpy LAPACK matrix copy routine. */
106 /* zlahqr LAPACK routine to compute the Schur form of an */
107 /* upper Hessenberg matrix. */
108 /* zlaset LAPACK matrix initialization routine. */
109 /* ztrevc LAPACK routine to compute the eigenvectors of a matrix */
110 /* in upper triangular form */
111 /* zcopy Level 1 BLAS that copies one vector to another. */
112 /* zdscal Level 1 BLAS that scales a complex vector by a real number. */
113 /* dznrm2 Level 1 BLAS that computes the norm of a vector. */
114
115
116 /* \Author */
117 /* Danny Sorensen Phuong Vu */
118 /* Richard Lehoucq CRPC / Rice University */
119 /* Dept. of Computational & Houston, Texas */
120 /* Applied Mathematics */
121 /* Rice University */
122 /* Houston, Texas */
123
124 /* \SCCS Information: @(#) */
125 /* FILE: neigh.F SID: 2.2 DATE OF SID: 4/20/96 RELEASE: 2 */
126
127 /* \Remarks */
128 /* None */
129
130 /* \EndLib */
131
132 /* ----------------------------------------------------------------------- */
133
134 /* Subroutine */ int zneigh_(doublereal *rnorm, integer *n, doublecomplex *
135 h__, integer *ldh, doublecomplex *ritz, doublecomplex *bounds,
136 doublecomplex *q, integer *ldq, doublecomplex *workl, doublereal *
137 rwork, integer *ierr)
138 {
139 /* System generated locals */
140 integer h_dim1, h_offset, q_dim1, q_offset, i__1;
141 doublereal d__1;
142
143 /* Local variables */
144 static integer j;
145 static real t0, t1;
146 static doublecomplex vl[1];
147 static doublereal temp;
148 extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *,
149 doublecomplex *, integer *), zmout_(integer *, integer *, integer
150 *, doublecomplex *, integer *, integer *, char *, ftnlen), zvout_(
151 integer *, integer *, doublecomplex *, integer *, char *, ftnlen);
152 extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
153 extern /* Subroutine */ int second_(real *);
154 static logical select[1];
155 static integer msglvl;
156 extern /* Subroutine */ int zlacpy_(char *, integer *, integer *,
157 doublecomplex *, integer *, doublecomplex *, integer *, ftnlen),
158 zlahqr_(logical *, logical *, integer *, integer *, integer *,
159 doublecomplex *, integer *, doublecomplex *, integer *, integer *,
160 doublecomplex *, integer *, integer *), ztrevc_(char *, char *,
161 logical *, integer *, doublecomplex *, integer *, doublecomplex *,
162 integer *, doublecomplex *, integer *, integer *, integer *,
163 doublecomplex *, doublereal *, integer *, ftnlen, ftnlen),
164 zdscal_(integer *, doublereal *, doublecomplex *, integer *),
165 zlaset_(char *, integer *, integer *, doublecomplex *,
166 doublecomplex *, doublecomplex *, integer *, ftnlen);
167
168
169 /* %----------------------------------------------------% */
170 /* | Include files for debugging and timing information | */
171 /* %----------------------------------------------------% */
172
173
174 /* \SCCS Information: @(#) */
175 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
176
177 /* %---------------------------------% */
178 /* | See debug.doc for documentation | */
179 /* %---------------------------------% */
180
181 /* %------------------% */
182 /* | Scalar Arguments | */
183 /* %------------------% */
184
185 /* %--------------------------------% */
186 /* | See stat.doc for documentation | */
187 /* %--------------------------------% */
188
189 /* \SCCS Information: @(#) */
190 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
191
192
193
194 /* %-----------------% */
195 /* | Array Arguments | */
196 /* %-----------------% */
197
198
199 /* %------------% */
200 /* | Parameters | */
201 /* %------------% */
202
203
204 /* %------------------------% */
205 /* | Local Scalars & Arrays | */
206 /* %------------------------% */
207
208
209 /* %----------------------% */
210 /* | External Subroutines | */
211 /* %----------------------% */
212
213
214 /* %--------------------% */
215 /* | External Functions | */
216 /* %--------------------% */
217
218
219 /* %-----------------------% */
220 /* | Executable Statements | */
221 /* %-----------------------% */
222
223 /* %-------------------------------% */
224 /* | Initialize timing statistics | */
225 /* | & message level for debugging | */
226 /* %-------------------------------% */
227
228 /* Parameter adjustments */
229 --rwork;
230 --workl;
231 --bounds;
232 --ritz;
233 h_dim1 = *ldh;
234 h_offset = 1 + h_dim1;
235 h__ -= h_offset;
236 q_dim1 = *ldq;
237 q_offset = 1 + q_dim1;
238 q -= q_offset;
239
240 /* Function Body */
241 second_(&t0);
242 msglvl = debug_1.mceigh;
243
244 if (msglvl > 2) {
245 zmout_(&debug_1.logfil, n, n, &h__[h_offset], ldh, &debug_1.ndigit,
246 "_neigh: Entering upper Hessenberg matrix H ", (ftnlen)43);
247 }
248
249 /* %----------------------------------------------------------% */
250 /* | 1. Compute the eigenvalues, the last components of the | */
251 /* | corresponding Schur vectors and the full Schur form T | */
252 /* | of the current upper Hessenberg matrix H. | */
253 /* | zlahqr returns the full Schur form of H | */
254 /* | in WORKL(1:N**2), and the Schur vectors in q. | */
255 /* %----------------------------------------------------------% */
256
257 zlacpy_("All", n, n, &h__[h_offset], ldh, &workl[1], n, (ftnlen)3);
258 zlaset_("All", n, n, &c_b2, &c_b1, &q[q_offset], ldq, (ftnlen)3);
259 zlahqr_(&c_true, &c_true, n, &c__1, n, &workl[1], ldh, &ritz[1], &c__1, n,
260 &q[q_offset], ldq, ierr);
261 if (*ierr != 0) {
262 goto L9000;
263 }
264
265 zcopy_(n, &q[*n - 1 + q_dim1], ldq, &bounds[1], &c__1);
266 if (msglvl > 1) {
267 zvout_(&debug_1.logfil, n, &bounds[1], &debug_1.ndigit, "_neigh: las"
268 "t row of the Schur matrix for H", (ftnlen)42);
269 }
270
271 /* %----------------------------------------------------------% */
272 /* | 2. Compute the eigenvectors of the full Schur form T and | */
273 /* | apply the Schur vectors to get the corresponding | */
274 /* | eigenvectors. | */
275 /* %----------------------------------------------------------% */
276
277 ztrevc_("Right", "Back", select, n, &workl[1], n, vl, n, &q[q_offset],
278 ldq, n, n, &workl[*n * *n + 1], &rwork[1], ierr, (ftnlen)5, (
279 ftnlen)4);
280
281 if (*ierr != 0) {
282 goto L9000;
283 }
284
285 /* %------------------------------------------------% */
286 /* | Scale the returning eigenvectors so that their | */
287 /* | Euclidean norms are all one. LAPACK subroutine | */
288 /* | ztrevc returns each eigenvector normalized so | */
289 /* | that the element of largest magnitude has | */
290 /* | magnitude 1; here the magnitude of a complex | */
291 /* | number (x,y) is taken to be |x| + |y|. | */
292 /* %------------------------------------------------% */
293
294 i__1 = *n;
295 for (j = 1; j <= i__1; ++j) {
296 temp = dznrm2_(n, &q[j * q_dim1 + 1], &c__1);
297 d__1 = 1. / temp;
298 zdscal_(n, &d__1, &q[j * q_dim1 + 1], &c__1);
299 /* L10: */
300 }
301
302 if (msglvl > 1) {
303 zcopy_(n, &q[*n + q_dim1], ldq, &workl[1], &c__1);
304 zvout_(&debug_1.logfil, n, &workl[1], &debug_1.ndigit, "_neigh: Last"
305 " row of the eigenvector matrix for H", (ftnlen)48);
306 }
307
308 /* %----------------------------% */
309 /* | Compute the Ritz estimates | */
310 /* %----------------------------% */
311
312 zcopy_(n, &q[*n + q_dim1], n, &bounds[1], &c__1);
313 zdscal_(n, rnorm, &bounds[1], &c__1);
314
315 if (msglvl > 2) {
316 zvout_(&debug_1.logfil, n, &ritz[1], &debug_1.ndigit, "_neigh: The e"
317 "igenvalues of H", (ftnlen)28);
318 zvout_(&debug_1.logfil, n, &bounds[1], &debug_1.ndigit, "_neigh: Rit"
319 "z estimates for the eigenvalues of H", (ftnlen)47);
320 }
321
322 second_(&t1);
323 timing_1.tceigh += t1 - t0;
324
325 L9000:
326 return 0;
327
328 /* %---------------% */
329 /* | End of zneigh | */
330 /* %---------------% */
331
332 } /* zneigh_ */
333