Debian Codegraph @

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

raw
1 /* ./src_f77/sneigh.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_SNEIGH;
15
16 #define debug_1 debug_SNEIGH
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_SNEIGH;
25
26 #define timing_1 timing_SNEIGH
27
28 /* Table of constant values */
29
30 static logical c_true = TRUE_;
31 static integer c__1 = 1;
32 static real c_b18 = 1.f;
33 static real c_b20 = 0.f;
34
35 /* ----------------------------------------------------------------------- */
36 /* \BeginDoc */
37
38 /* \Name: sneigh */
39
40 /* \Description: */
41 /* Compute the eigenvalues of the current upper Hessenberg matrix */
42 /* and the corresponding Ritz estimates given the current residual norm. */
43
44 /* \Usage: */
45 /* call sneigh */
46 /* ( RNORM, N, H, LDH, RITZR, RITZI, BOUNDS, Q, LDQ, WORKL, IERR ) */
47
48 /* \Arguments */
49 /* RNORM Real scalar. (INPUT) */
50 /* Residual norm corresponding to the current upper Hessenberg */
51 /* matrix H. */
52
53 /* N Integer. (INPUT) */
54 /* Size of the matrix H. */
55
56 /* H Real N by N array. (INPUT) */
57 /* H contains the current upper Hessenberg matrix. */
58
59 /* LDH Integer. (INPUT) */
60 /* Leading dimension of H exactly as declared in the calling */
61 /* program. */
62
63 /* RITZR, Real arrays of length N. (OUTPUT) */
64 /* RITZI On output, RITZR(1:N) (resp. RITZI(1:N)) contains the real */
65 /* (respectively imaginary) parts of the eigenvalues of H. */
66
67 /* BOUNDS Real array of length N. (OUTPUT) */
68 /* On output, BOUNDS contains the Ritz estimates associated with */
69 /* the eigenvalues RITZR and RITZI. This is equal to RNORM */
70 /* times the last components of the eigenvectors corresponding */
71 /* to the eigenvalues in RITZR and RITZI. */
72
73 /* Q Real N by N array. (WORKSPACE) */
74 /* Workspace needed to store the eigenvectors of H. */
75
76 /* LDQ Integer. (INPUT) */
77 /* Leading dimension of Q exactly as declared in the calling */
78 /* program. */
79
80 /* WORKL Real work array of length N**2 + 3*N. (WORKSPACE) */
81 /* Private (replicated) array on each PE or array allocated on */
82 /* the front end. This is needed to keep the full Schur form */
83 /* of H and also in the calculation of the eigenvectors of H. */
84
85 /* IERR Integer. (OUTPUT) */
86 /* Error exit flag from slaqrb or strevc. */
87
88 /* \EndDoc */
89
90 /* ----------------------------------------------------------------------- */
91
92 /* \BeginLib */
93
94 /* \Local variables: */
95 /* xxxxxx real */
96
97 /* \Routines called: */
98 /* slaqrb ARPACK routine to compute the real Schur form of an */
99 /* upper Hessenberg matrix and last row of the Schur vectors. */
100 /* second ARPACK utility routine for timing. */
101 /* smout ARPACK utility routine that prints matrices */
102 /* svout ARPACK utility routine that prints vectors. */
103 /* slacpy LAPACK matrix copy routine. */
104 /* slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */
105 /* strevc LAPACK routine to compute the eigenvectors of a matrix */
106 /* in upper quasi-triangular form */
107 /* sgemv Level 2 BLAS routine for matrix vector multiplication. */
108 /* scopy Level 1 BLAS that copies one vector to another . */
109 /* snrm2 Level 1 BLAS that computes the norm of a vector. */
110 /* sscal Level 1 BLAS that scales a vector. */
111
112
113 /* \Author */
114 /* Danny Sorensen Phuong Vu */
115 /* Richard Lehoucq CRPC / Rice University */
116 /* Dept. of Computational & Houston, Texas */
117 /* Applied Mathematics */
118 /* Rice University */
119 /* Houston, Texas */
120
121 /* \Revision history: */
122 /* xx/xx/92: Version ' 2.1' */
123
124 /* \SCCS Information: @(#) */
125 /* FILE: neigh.F SID: 2.3 DATE OF SID: 4/20/96 RELEASE: 2 */
126
127 /* \Remarks */
128 /* None */
129
130 /* \EndLib */
131
132 /* ----------------------------------------------------------------------- */
133
134 /* Subroutine */ int sneigh_(real *rnorm, integer *n, real *h__, integer *ldh,
135 real *ritzr, real *ritzi, real *bounds, real *q, integer *ldq, real *
136 workl, integer *ierr)
137 {
138 /* System generated locals */
139 integer h_dim1, h_offset, q_dim1, q_offset, i__1;
140 real r__1, r__2;
141
142 /* Local variables */
143 static integer i__;
144 static real t0, t1, vl[1], temp;
145 extern doublereal snrm2_(integer *, real *, integer *);
146 static integer iconj;
147 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
148 sgemv_(char *, integer *, integer *, real *, real *, integer *,
149 real *, integer *, real *, real *, integer *, ftnlen), smout_(
150 integer *, integer *, integer *, real *, integer *, integer *,
151 char *, ftnlen), svout_(integer *, integer *, real *, integer *,
152 char *, ftnlen);
153 extern doublereal slapy2_(real *, real *);
154 extern /* Subroutine */ int second_(real *);
155 static logical select[1];
156 static integer msglvl;
157 extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *,
158 integer *, real *, integer *, ftnlen), slaqrb_(logical *, integer
159 *, integer *, integer *, real *, integer *, real *, real *, real *
160 , integer *), strevc_(char *, char *, logical *, integer *, real *
161 , integer *, real *, integer *, real *, integer *, integer *,
162 integer *, real *, integer *, ftnlen, ftnlen);
163
164
165 /* %----------------------------------------------------% */
166 /* | Include files for debugging and timing information | */
167 /* %----------------------------------------------------% */
168
169
170 /* \SCCS Information: @(#) */
171 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
172
173 /* %---------------------------------% */
174 /* | See debug.doc for documentation | */
175 /* %---------------------------------% */
176
177 /* %------------------% */
178 /* | Scalar Arguments | */
179 /* %------------------% */
180
181 /* %--------------------------------% */
182 /* | See stat.doc for documentation | */
183 /* %--------------------------------% */
184
185 /* \SCCS Information: @(#) */
186 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
187
188
189
190 /* %-----------------% */
191 /* | Array Arguments | */
192 /* %-----------------% */
193
194
195 /* %------------% */
196 /* | Parameters | */
197 /* %------------% */
198
199
200 /* %------------------------% */
201 /* | Local Scalars & Arrays | */
202 /* %------------------------% */
203
204
205 /* %----------------------% */
206 /* | External Subroutines | */
207 /* %----------------------% */
208
209
210 /* %--------------------% */
211 /* | External Functions | */
212 /* %--------------------% */
213
214
215 /* %---------------------% */
216 /* | Intrinsic Functions | */
217 /* %---------------------% */
218
219
220 /* %-----------------------% */
221 /* | Executable Statements | */
222 /* %-----------------------% */
223
224
225 /* %-------------------------------% */
226 /* | Initialize timing statistics | */
227 /* | & message level for debugging | */
228 /* %-------------------------------% */
229
230 /* Parameter adjustments */
231 --workl;
232 --bounds;
233 --ritzi;
234 --ritzr;
235 h_dim1 = *ldh;
236 h_offset = 1 + h_dim1;
237 h__ -= h_offset;
238 q_dim1 = *ldq;
239 q_offset = 1 + q_dim1;
240 q -= q_offset;
241
242 /* Function Body */
243 second_(&t0);
244 msglvl = debug_1.mneigh;
245
246 if (msglvl > 2) {
247 smout_(&debug_1.logfil, n, n, &h__[h_offset], ldh, &debug_1.ndigit,
248 "_neigh: Entering upper Hessenberg matrix H ", (ftnlen)43);
249 }
250
251 /* %-----------------------------------------------------------% */
252 /* | 1. Compute the eigenvalues, the last components of the | */
253 /* | corresponding Schur vectors and the full Schur form T | */
254 /* | of the current upper Hessenberg matrix H. | */
255 /* | slaqrb returns the full Schur form of H in WORKL(1:N**2) | */
256 /* | and the last components of the Schur vectors in BOUNDS. | */
257 /* %-----------------------------------------------------------% */
258
259 slacpy_("All", n, n, &h__[h_offset], ldh, &workl[1], n, (ftnlen)3);
260 slaqrb_(&c_true, n, &c__1, n, &workl[1], n, &ritzr[1], &ritzi[1], &bounds[
261 1], ierr);
262 if (*ierr != 0) {
263 goto L9000;
264 }
265
266 if (msglvl > 1) {
267 svout_(&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 last components of the Schur vectors to get | */
274 /* | the last components of the corresponding eigenvectors. | */
275 /* | Remember that if the i-th and (i+1)-st eigenvalues are | */
276 /* | complex conjugate pairs, then the real & imaginary part | */
277 /* | of the eigenvector components are split across adjacent | */
278 /* | columns of Q. | */
279 /* %-----------------------------------------------------------% */
280
281 strevc_("R", "A", select, n, &workl[1], n, vl, n, &q[q_offset], ldq, n, n,
282 &workl[*n * *n + 1], ierr, (ftnlen)1, (ftnlen)1);
283
284 if (*ierr != 0) {
285 goto L9000;
286 }
287
288 /* %------------------------------------------------% */
289 /* | Scale the returning eigenvectors so that their | */
290 /* | euclidean norms are all one. LAPACK subroutine | */
291 /* | strevc returns each eigenvector normalized so | */
292 /* | that the element of largest magnitude has | */
293 /* | magnitude 1; here the magnitude of a complex | */
294 /* | number (x,y) is taken to be |x| + |y|. | */
295 /* %------------------------------------------------% */
296
297 iconj = 0;
298 i__1 = *n;
299 for (i__ = 1; i__ <= i__1; ++i__) {
300 if ((r__1 = ritzi[i__], dabs(r__1)) <= 0.f) {
301
302 /* %----------------------% */
303 /* | Real eigenvalue case | */
304 /* %----------------------% */
305
306 temp = snrm2_(n, &q[i__ * q_dim1 + 1], &c__1);
307 r__1 = 1.f / temp;
308 sscal_(n, &r__1, &q[i__ * q_dim1 + 1], &c__1);
309 } else {
310
311 /* %-------------------------------------------% */
312 /* | Complex conjugate pair case. Note that | */
313 /* | since the real and imaginary part of | */
314 /* | the eigenvector are stored in consecutive | */
315 /* | columns, we further normalize by the | */
316 /* | square root of two. | */
317 /* %-------------------------------------------% */
318
319 if (iconj == 0) {
320 r__1 = snrm2_(n, &q[i__ * q_dim1 + 1], &c__1);
321 r__2 = snrm2_(n, &q[(i__ + 1) * q_dim1 + 1], &c__1);
322 temp = slapy2_(&r__1, &r__2);
323 r__1 = 1.f / temp;
324 sscal_(n, &r__1, &q[i__ * q_dim1 + 1], &c__1);
325 r__1 = 1.f / temp;
326 sscal_(n, &r__1, &q[(i__ + 1) * q_dim1 + 1], &c__1);
327 iconj = 1;
328 } else {
329 iconj = 0;
330 }
331 }
332 /* L10: */
333 }
334
335 sgemv_("T", n, n, &c_b18, &q[q_offset], ldq, &bounds[1], &c__1, &c_b20, &
336 workl[1], &c__1, (ftnlen)1);
337
338 if (msglvl > 1) {
339 svout_(&debug_1.logfil, n, &workl[1], &debug_1.ndigit, "_neigh: Last"
340 " row of the eigenvector matrix for H", (ftnlen)48);
341 }
342
343 /* %----------------------------% */
344 /* | Compute the Ritz estimates | */
345 /* %----------------------------% */
346
347 iconj = 0;
348 i__1 = *n;
349 for (i__ = 1; i__ <= i__1; ++i__) {
350 if ((r__1 = ritzi[i__], dabs(r__1)) <= 0.f) {
351
352 /* %----------------------% */
353 /* | Real eigenvalue case | */
354 /* %----------------------% */
355
356 bounds[i__] = *rnorm * (r__1 = workl[i__], dabs(r__1));
357 } else {
358
359 /* %-------------------------------------------% */
360 /* | Complex conjugate pair case. Note that | */
361 /* | since the real and imaginary part of | */
362 /* | the eigenvector are stored in consecutive | */
363 /* | columns, we need to take the magnitude | */
364 /* | of the last components of the two vectors | */
365 /* %-------------------------------------------% */
366
367 if (iconj == 0) {
368 bounds[i__] = *rnorm * slapy2_(&workl[i__], &workl[i__ + 1]);
369 bounds[i__ + 1] = bounds[i__];
370 iconj = 1;
371 } else {
372 iconj = 0;
373 }
374 }
375 /* L20: */
376 }
377
378 if (msglvl > 2) {
379 svout_(&debug_1.logfil, n, &ritzr[1], &debug_1.ndigit, "_neigh: Real"
380 " part of the eigenvalues of H", (ftnlen)41);
381 svout_(&debug_1.logfil, n, &ritzi[1], &debug_1.ndigit, "_neigh: Imag"
382 "inary part of the eigenvalues of H", (ftnlen)46);
383 svout_(&debug_1.logfil, n, &bounds[1], &debug_1.ndigit, "_neigh: Rit"
384 "z estimates for the eigenvalues of H", (ftnlen)47);
385 }
386
387 second_(&t1);
388 timing_1.tneigh += t1 - t0;
389
390 L9000:
391 return 0;
392
393 /* %---------------% */
394 /* | End of sneigh | */
395 /* %---------------% */
396
397 } /* sneigh_ */
398