Debian Codegraph @

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

raw
1 /* ./src_f77/dsgets.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_DSGETS;
15
16 #define debug_1 debug_DSGETS
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_DSGETS;
25
26 #define timing_1 timing_DSGETS
27
28 /* Table of constant values */
29
30 static logical c_true = TRUE_;
31 static integer c__1 = 1;
32
33 /* ----------------------------------------------------------------------- */
34 /* \BeginDoc */
35
36 /* \Name: dsgets */
37
38 /* \Description: */
39 /* Given the eigenvalues of the symmetric tridiagonal matrix H, */
40 /* computes the NP shifts AMU that are zeros of the polynomial of */
41 /* degree NP which filters out components of the unwanted eigenvectors */
42 /* corresponding to the AMU's based on some given criteria. */
43
44 /* NOTE: This is called even in the case of user specified shifts in */
45 /* order to sort the eigenvalues, and error bounds of H for later use. */
46
47 /* \Usage: */
48 /* call dsgets */
49 /* ( ISHIFT, WHICH, KEV, NP, RITZ, BOUNDS, SHIFTS ) */
50
51 /* \Arguments */
52 /* ISHIFT Integer. (INPUT) */
53 /* Method for selecting the implicit shifts at each iteration. */
54 /* ISHIFT = 0: user specified shifts */
55 /* ISHIFT = 1: exact shift with respect to the matrix H. */
56
57 /* WHICH Character*2. (INPUT) */
58 /* Shift selection criteria. */
59 /* 'LM' -> KEV eigenvalues of largest magnitude are retained. */
60 /* 'SM' -> KEV eigenvalues of smallest magnitude are retained. */
61 /* 'LA' -> KEV eigenvalues of largest value are retained. */
62 /* 'SA' -> KEV eigenvalues of smallest value are retained. */
63 /* 'BE' -> KEV eigenvalues, half from each end of the spectrum. */
64 /* If KEV is odd, compute one more from the high end. */
65
66 /* KEV Integer. (INPUT) */
67 /* KEV+NP is the size of the matrix H. */
68
69 /* NP Integer. (INPUT) */
70 /* Number of implicit shifts to be computed. */
71
72 /* RITZ Double precision array of length KEV+NP. (INPUT/OUTPUT) */
73 /* On INPUT, RITZ contains the eigenvalues of H. */
74 /* On OUTPUT, RITZ are sorted so that the unwanted eigenvalues */
75 /* are in the first NP locations and the wanted part is in */
76 /* the last KEV locations. When exact shifts are selected, the */
77 /* unwanted part corresponds to the shifts to be applied. */
78
79 /* BOUNDS Double precision array of length KEV+NP. (INPUT/OUTPUT) */
80 /* Error bounds corresponding to the ordering in RITZ. */
81
82 /* SHIFTS Double precision array of length NP. (INPUT/OUTPUT) */
83 /* On INPUT: contains the user specified shifts if ISHIFT = 0. */
84 /* On OUTPUT: contains the shifts sorted into decreasing order */
85 /* of magnitude with respect to the Ritz estimates contained in */
86 /* BOUNDS. If ISHIFT = 0, SHIFTS is not modified on exit. */
87
88 /* \EndDoc */
89
90 /* ----------------------------------------------------------------------- */
91
92 /* \BeginLib */
93
94 /* \Local variables: */
95 /* xxxxxx real */
96
97 /* \Routines called: */
98 /* dsortr ARPACK utility sorting routine. */
99 /* ivout ARPACK utility routine that prints integers. */
100 /* second ARPACK utility routine for timing. */
101 /* dvout ARPACK utility routine that prints vectors. */
102 /* dcopy Level 1 BLAS that copies one vector to another. */
103 /* dswap Level 1 BLAS that swaps the contents of two vectors. */
104
105 /* \Author */
106 /* Danny Sorensen Phuong Vu */
107 /* Richard Lehoucq CRPC / Rice University */
108 /* Dept. of Computational & Houston, Texas */
109 /* Applied Mathematics */
110 /* Rice University */
111 /* Houston, Texas */
112
113 /* \Revision history: */
114 /* xx/xx/93: Version ' 2.1' */
115
116 /* \SCCS Information: @(#) */
117 /* FILE: sgets.F SID: 2.4 DATE OF SID: 4/19/96 RELEASE: 2 */
118
119 /* \Remarks */
120
121 /* \EndLib */
122
123 /* ----------------------------------------------------------------------- */
124
125 /* Subroutine */ int dsgets_(integer *ishift, char *which, integer *kev,
126 integer *np, doublereal *ritz, doublereal *bounds, doublereal *shifts,
127 ftnlen which_len)
128 {
129 /* System generated locals */
130 integer i__1;
131
132 /* Builtin functions */
133 integer s_cmp(char *, char *, ftnlen, ftnlen);
134
135 /* Local variables */
136 static real t0, t1;
137 static integer kevd2;
138 extern /* Subroutine */ int dswap_(integer *, doublereal *, integer *,
139 doublereal *, integer *), dcopy_(integer *, doublereal *, integer
140 *, doublereal *, integer *), dvout_(integer *, integer *,
141 doublereal *, integer *, char *, ftnlen), ivout_(integer *,
142 integer *, integer *, integer *, char *, ftnlen), second_(real *);
143 static integer msglvl;
144 extern /* Subroutine */ int dsortr_(char *, logical *, integer *,
145 doublereal *, doublereal *, ftnlen);
146
147
148 /* %----------------------------------------------------% */
149 /* | Include files for debugging and timing information | */
150 /* %----------------------------------------------------% */
151
152
153 /* \SCCS Information: @(#) */
154 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
155
156 /* %---------------------------------% */
157 /* | See debug.doc for documentation | */
158 /* %---------------------------------% */
159
160 /* %------------------% */
161 /* | Scalar Arguments | */
162 /* %------------------% */
163
164 /* %--------------------------------% */
165 /* | See stat.doc for documentation | */
166 /* %--------------------------------% */
167
168 /* \SCCS Information: @(#) */
169 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
170
171
172
173 /* %-----------------% */
174 /* | Array Arguments | */
175 /* %-----------------% */
176
177
178 /* %------------% */
179 /* | Parameters | */
180 /* %------------% */
181
182
183 /* %---------------% */
184 /* | Local Scalars | */
185 /* %---------------% */
186
187
188 /* %----------------------% */
189 /* | External Subroutines | */
190 /* %----------------------% */
191
192
193 /* %---------------------% */
194 /* | Intrinsic Functions | */
195 /* %---------------------% */
196
197
198 /* %-----------------------% */
199 /* | Executable Statements | */
200 /* %-----------------------% */
201
202 /* %-------------------------------% */
203 /* | Initialize timing statistics | */
204 /* | & message level for debugging | */
205 /* %-------------------------------% */
206
207 /* Parameter adjustments */
208 --shifts;
209 --bounds;
210 --ritz;
211
212 /* Function Body */
213 second_(&t0);
214 msglvl = debug_1.msgets;
215
216 if (s_cmp(which, "BE", (ftnlen)2, (ftnlen)2) == 0) {
217
218 /* %-----------------------------------------------------% */
219 /* | Both ends of the spectrum are requested. | */
220 /* | Sort the eigenvalues into algebraically increasing | */
221 /* | order first then swap high end of the spectrum next | */
222 /* | to low end in appropriate locations. | */
223 /* | NOTE: when np < floor(kev/2) be careful not to swap | */
224 /* | overlapping locations. | */
225 /* %-----------------------------------------------------% */
226
227 i__1 = *kev + *np;
228 dsortr_("LA", &c_true, &i__1, &ritz[1], &bounds[1], (ftnlen)2);
229 kevd2 = *kev / 2;
230 if (*kev > 1) {
231 i__1 = min(kevd2,*np);
232 dswap_(&i__1, &ritz[1], &c__1, &ritz[max(kevd2,*np) + 1], &c__1);
233 i__1 = min(kevd2,*np);
234 dswap_(&i__1, &bounds[1], &c__1, &bounds[max(kevd2,*np) + 1], &
235 c__1);
236 }
237
238 } else {
239
240 /* %----------------------------------------------------% */
241 /* | LM, SM, LA, SA case. | */
242 /* | Sort the eigenvalues of H into the desired order | */
243 /* | and apply the resulting order to BOUNDS. | */
244 /* | The eigenvalues are sorted so that the wanted part | */
245 /* | are always in the last KEV locations. | */
246 /* %----------------------------------------------------% */
247
248 i__1 = *kev + *np;
249 dsortr_(which, &c_true, &i__1, &ritz[1], &bounds[1], (ftnlen)2);
250 }
251
252 if (*ishift == 1 && *np > 0) {
253
254 /* %-------------------------------------------------------% */
255 /* | Sort the unwanted Ritz values used as shifts so that | */
256 /* | the ones with largest Ritz estimates are first. | */
257 /* | This will tend to minimize the effects of the | */
258 /* | forward instability of the iteration when the shifts | */
259 /* | are applied in subroutine dsapps. | */
260 /* %-------------------------------------------------------% */
261
262 dsortr_("SM", &c_true, np, &bounds[1], &ritz[1], (ftnlen)2);
263 dcopy_(np, &ritz[1], &c__1, &shifts[1], &c__1);
264 }
265
266 second_(&t1);
267 timing_1.tsgets += t1 - t0;
268
269 if (msglvl > 0) {
270 ivout_(&debug_1.logfil, &c__1, kev, &debug_1.ndigit, "_sgets: KEV is",
271 (ftnlen)14);
272 ivout_(&debug_1.logfil, &c__1, np, &debug_1.ndigit, "_sgets: NP is", (
273 ftnlen)13);
274 i__1 = *kev + *np;
275 dvout_(&debug_1.logfil, &i__1, &ritz[1], &debug_1.ndigit, "_sgets: E"
276 "igenvalues of current H matrix", (ftnlen)39);
277 i__1 = *kev + *np;
278 dvout_(&debug_1.logfil, &i__1, &bounds[1], &debug_1.ndigit, "_sgets:"
279 " Associated Ritz estimates", (ftnlen)33);
280 }
281
282 return 0;
283
284 /* %---------------% */
285 /* | End of dsgets | */
286 /* %---------------% */
287
288 } /* dsgets_ */
289