Debian Codegraph @

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

raw
1 /* ./src_f77/dsaupd.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_DSAUPD;
15
16 #define debug_1 debug_DSAUPD
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_DSAUPD;
25
26 #define timing_1 timing_DSAUPD
27
28 /* Table of constant values */
29
30 static integer c__1 = 1;
31
32 /* ----------------------------------------------------------------------- */
33 /* \BeginDoc */
34
35 /* \Name: dsaupd */
36
37 /* \Description: */
38
39 /* Reverse communication interface for the Implicitly Restarted Arnoldi */
40 /* Iteration. For symmetric problems this reduces to a variant of the Lanczos */
41 /* method. This method has been designed to compute approximations to a */
42 /* few eigenpairs of a linear operator OP that is real and symmetric */
43 /* with respect to a real positive semi-definite symmetric matrix B, */
44 /* i.e. */
45
46 /* B*OP = (OP`)*B. */
47
48 /* Another way to express this condition is */
49
50 /* < x,OPy > = < OPx,y > where < z,w > = z`Bw . */
51
52 /* In the standard eigenproblem B is the identity matrix. */
53 /* ( A` denotes transpose of A) */
54
55 /* The computed approximate eigenvalues are called Ritz values and */
56 /* the corresponding approximate eigenvectors are called Ritz vectors. */
57
58 /* dsaupd is usually called iteratively to solve one of the */
59 /* following problems: */
60
61 /* Mode 1: A*x = lambda*x, A symmetric */
62 /* ===> OP = A and B = I. */
63
64 /* Mode 2: A*x = lambda*M*x, A symmetric, M symmetric positive definite */
65 /* ===> OP = inv[M]*A and B = M. */
66 /* ===> (If M can be factored see remark 3 below) */
67
68 /* Mode 3: K*x = lambda*M*x, K symmetric, M symmetric positive semi-definite */
69 /* ===> OP = (inv[K - sigma*M])*M and B = M. */
70 /* ===> Shift-and-Invert mode */
71
72 /* Mode 4: K*x = lambda*KG*x, K symmetric positive semi-definite, */
73 /* KG symmetric indefinite */
74 /* ===> OP = (inv[K - sigma*KG])*K and B = K. */
75 /* ===> Buckling mode */
76
77 /* Mode 5: A*x = lambda*M*x, A symmetric, M symmetric positive semi-definite */
78 /* ===> OP = inv[A - sigma*M]*[A + sigma*M] and B = M. */
79 /* ===> Cayley transformed mode */
80
81 /* NOTE: The action of w <- inv[A - sigma*M]*v or w <- inv[M]*v */
82 /* should be accomplished either by a direct method */
83 /* using a sparse matrix factorization and solving */
84
85 /* [A - sigma*M]*w = v or M*w = v, */
86
87 /* or through an iterative method for solving these */
88 /* systems. If an iterative method is used, the */
89 /* convergence test must be more stringent than */
90 /* the accuracy requirements for the eigenvalue */
91 /* approximations. */
92
93 /* \Usage: */
94 /* call dsaupd */
95 /* ( IDO, BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, */
96 /* IPNTR, WORKD, WORKL, LWORKL, INFO ) */
97
98 /* \Arguments */
99 /* IDO Integer. (INPUT/OUTPUT) */
100 /* Reverse communication flag. IDO must be zero on the first */
101 /* call to dsaupd . IDO will be set internally to */
102 /* indicate the type of operation to be performed. Control is */
103 /* then given back to the calling routine which has the */
104 /* responsibility to carry out the requested operation and call */
105 /* dsaupd with the result. The operand is given in */
106 /* WORKD(IPNTR(1)), the result must be put in WORKD(IPNTR(2)). */
107 /* (If Mode = 2 see remark 5 below) */
108 /* ------------------------------------------------------------- */
109 /* IDO = 0: first call to the reverse communication interface */
110 /* IDO = -1: compute Y = OP * X where */
111 /* IPNTR(1) is the pointer into WORKD for X, */
112 /* IPNTR(2) is the pointer into WORKD for Y. */
113 /* This is for the initialization phase to force the */
114 /* starting vector into the range of OP. */
115 /* IDO = 1: compute Y = OP * X where */
116 /* IPNTR(1) is the pointer into WORKD for X, */
117 /* IPNTR(2) is the pointer into WORKD for Y. */
118 /* In mode 3,4 and 5, the vector B * X is already */
119 /* available in WORKD(ipntr(3)). It does not */
120 /* need to be recomputed in forming OP * X. */
121 /* IDO = 2: compute Y = B * X where */
122 /* IPNTR(1) is the pointer into WORKD for X, */
123 /* IPNTR(2) is the pointer into WORKD for Y. */
124 /* IDO = 3: compute the IPARAM(8) shifts where */
125 /* IPNTR(11) is the pointer into WORKL for */
126 /* placing the shifts. See remark 6 below. */
127 /* IDO = 99: done */
128 /* ------------------------------------------------------------- */
129
130 /* BMAT Character*1. (INPUT) */
131 /* BMAT specifies the type of the matrix B that defines the */
132 /* semi-inner product for the operator OP. */
133 /* B = 'I' -> standard eigenvalue problem A*x = lambda*x */
134 /* B = 'G' -> generalized eigenvalue problem A*x = lambda*B*x */
135
136 /* N Integer. (INPUT) */
137 /* Dimension of the eigenproblem. */
138
139 /* WHICH Character*2. (INPUT) */
140 /* Specify which of the Ritz values of OP to compute. */
141
142 /* 'LA' - compute the NEV largest (algebraic) eigenvalues. */
143 /* 'SA' - compute the NEV smallest (algebraic) eigenvalues. */
144 /* 'LM' - compute the NEV largest (in magnitude) eigenvalues. */
145 /* 'SM' - compute the NEV smallest (in magnitude) eigenvalues. */
146 /* 'BE' - compute NEV eigenvalues, half from each end of the */
147 /* spectrum. When NEV is odd, compute one more from the */
148 /* high end than from the low end. */
149 /* (see remark 1 below) */
150
151 /* NEV Integer. (INPUT) */
152 /* Number of eigenvalues of OP to be computed. 0 < NEV < N. */
153
154 /* TOL Double precision scalar. (INPUT) */
155 /* Stopping criterion: the relative accuracy of the Ritz value */
156 /* is considered acceptable if BOUNDS(I) .LE. TOL*ABS(RITZ(I)). */
157 /* If TOL .LE. 0. is passed a default is set: */
158 /* DEFAULT = DLAMCH ('EPS') (machine precision as computed */
159 /* by the LAPACK auxiliary subroutine DLAMCH ). */
160
161 /* RESID Double precision array of length N. (INPUT/OUTPUT) */
162 /* On INPUT: */
163 /* If INFO .EQ. 0, a random initial residual vector is used. */
164 /* If INFO .NE. 0, RESID contains the initial residual vector, */
165 /* possibly from a previous run. */
166 /* On OUTPUT: */
167 /* RESID contains the final residual vector. */
168
169 /* NCV Integer. (INPUT) */
170 /* Number of columns of the matrix V (less than or equal to N). */
171 /* This will indicate how many Lanczos vectors are generated */
172 /* at each iteration. After the startup phase in which NEV */
173 /* Lanczos vectors are generated, the algorithm generates */
174 /* NCV-NEV Lanczos vectors at each subsequent update iteration. */
175 /* Most of the cost in generating each Lanczos vector is in the */
176 /* matrix-vector product OP*x. (See remark 4 below). */
177
178 /* V Double precision N by NCV array. (OUTPUT) */
179 /* The NCV columns of V contain the Lanczos basis vectors. */
180
181 /* LDV Integer. (INPUT) */
182 /* Leading dimension of V exactly as declared in the calling */
183 /* program. */
184
185 /* IPARAM Integer array of length 11. (INPUT/OUTPUT) */
186 /* IPARAM(1) = ISHIFT: method for selecting the implicit shifts. */
187 /* The shifts selected at each iteration are used to restart */
188 /* the Arnoldi iteration in an implicit fashion. */
189 /* ------------------------------------------------------------- */
190 /* ISHIFT = 0: the shifts are provided by the user via */
191 /* reverse communication. The NCV eigenvalues of */
192 /* the current tridiagonal matrix T are returned in */
193 /* the part of WORKL array corresponding to RITZ. */
194 /* See remark 6 below. */
195 /* ISHIFT = 1: exact shifts with respect to the reduced */
196 /* tridiagonal matrix T. This is equivalent to */
197 /* restarting the iteration with a starting vector */
198 /* that is a linear combination of Ritz vectors */
199 /* associated with the "wanted" Ritz values. */
200 /* ------------------------------------------------------------- */
201
202 /* IPARAM(2) = LEVEC */
203 /* No longer referenced. See remark 2 below. */
204
205 /* IPARAM(3) = MXITER */
206 /* On INPUT: maximum number of Arnoldi update iterations allowed. */
207 /* On OUTPUT: actual number of Arnoldi update iterations taken. */
208
209 /* IPARAM(4) = NB: blocksize to be used in the recurrence. */
210 /* The code currently works only for NB = 1. */
211
212 /* IPARAM(5) = NCONV: number of "converged" Ritz values. */
213 /* This represents the number of Ritz values that satisfy */
214 /* the convergence criterion. */
215
216 /* IPARAM(6) = IUPD */
217 /* No longer referenced. Implicit restarting is ALWAYS used. */
218
219 /* IPARAM(7) = MODE */
220 /* On INPUT determines what type of eigenproblem is being solved. */
221 /* Must be 1,2,3,4,5; See under \Description of dsaupd for the */
222 /* five modes available. */
223
224 /* IPARAM(8) = NP */
225 /* When ido = 3 and the user provides shifts through reverse */
226 /* communication (IPARAM(1)=0), dsaupd returns NP, the number */
227 /* of shifts the user is to provide. 0 < NP <=NCV-NEV. See Remark */
228 /* 6 below. */
229
230 /* IPARAM(9) = NUMOP, IPARAM(10) = NUMOPB, IPARAM(11) = NUMREO, */
231 /* OUTPUT: NUMOP = total number of OP*x operations, */
232 /* NUMOPB = total number of B*x operations if BMAT='G', */
233 /* NUMREO = total number of steps of re-orthogonalization. */
234
235 /* IPNTR Integer array of length 11. (OUTPUT) */
236 /* Pointer to mark the starting locations in the WORKD and WORKL */
237 /* arrays for matrices/vectors used by the Lanczos iteration. */
238 /* ------------------------------------------------------------- */
239 /* IPNTR(1): pointer to the current operand vector X in WORKD. */
240 /* IPNTR(2): pointer to the current result vector Y in WORKD. */
241 /* IPNTR(3): pointer to the vector B * X in WORKD when used in */
242 /* the shift-and-invert mode. */
243 /* IPNTR(4): pointer to the next available location in WORKL */
244 /* that is untouched by the program. */
245 /* IPNTR(5): pointer to the NCV by 2 tridiagonal matrix T in WORKL. */
246 /* IPNTR(6): pointer to the NCV RITZ values array in WORKL. */
247 /* IPNTR(7): pointer to the Ritz estimates in array WORKL associated */
248 /* with the Ritz values located in RITZ in WORKL. */
249 /* IPNTR(11): pointer to the NP shifts in WORKL. See Remark 6 below. */
250
251 /* Note: IPNTR(8:10) is only referenced by dseupd . See Remark 2. */
252 /* IPNTR(8): pointer to the NCV RITZ values of the original system. */
253 /* IPNTR(9): pointer to the NCV corresponding error bounds. */
254 /* IPNTR(10): pointer to the NCV by NCV matrix of eigenvectors */
255 /* of the tridiagonal matrix T. Only referenced by */
256 /* dseupd if RVEC = .TRUE. See Remarks. */
257 /* ------------------------------------------------------------- */
258
259 /* WORKD Double precision work array of length 3*N. (REVERSE COMMUNICATION) */
260 /* Distributed array to be used in the basic Arnoldi iteration */
261 /* for reverse communication. The user should not use WORKD */
262 /* as temporary workspace during the iteration. Upon termination */
263 /* WORKD(1:N) contains B*RESID(1:N). If the Ritz vectors are desired */
264 /* subroutine dseupd uses this output. */
265 /* See Data Distribution Note below. */
266
267 /* WORKL Double precision work array of length LWORKL. (OUTPUT/WORKSPACE) */
268 /* Private (replicated) array on each PE or array allocated on */
269 /* the front end. See Data Distribution Note below. */
270
271 /* LWORKL Integer. (INPUT) */
272 /* LWORKL must be at least NCV**2 + 8*NCV . */
273
274 /* INFO Integer. (INPUT/OUTPUT) */
275 /* If INFO .EQ. 0, a randomly initial residual vector is used. */
276 /* If INFO .NE. 0, RESID contains the initial residual vector, */
277 /* possibly from a previous run. */
278 /* Error flag on output. */
279 /* = 0: Normal exit. */
280 /* = 1: Maximum number of iterations taken. */
281 /* All possible eigenvalues of OP has been found. IPARAM(5) */
282 /* returns the number of wanted converged Ritz values. */
283 /* = 2: No longer an informational error. Deprecated starting */
284 /* with release 2 of ARPACK. */
285 /* = 3: No shifts could be applied during a cycle of the */
286 /* Implicitly restarted Arnoldi iteration. One possibility */
287 /* is to increase the size of NCV relative to NEV. */
288 /* See remark 4 below. */
289 /* = -1: N must be positive. */
290 /* = -2: NEV must be positive. */
291 /* = -3: NCV must be greater than NEV and less than or equal to N. */
292 /* = -4: The maximum number of Arnoldi update iterations allowed */
293 /* must be greater than zero. */
294 /* = -5: WHICH must be one of 'LM', 'SM', 'LA', 'SA' or 'BE'. */
295 /* = -6: BMAT must be one of 'I' or 'G'. */
296 /* = -7: Length of private work array WORKL is not sufficient. */
297 /* = -8: Error return from trid. eigenvalue calculation; */
298 /* Informatinal error from LAPACK routine dsteqr . */
299 /* = -9: Starting vector is zero. */
300 /* = -10: IPARAM(7) must be 1,2,3,4,5. */
301 /* = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatable. */
302 /* = -12: IPARAM(1) must be equal to 0 or 1. */
303 /* = -13: NEV and WHICH = 'BE' are incompatable. */
304 /* = -9999: Could not build an Arnoldi factorization. */
305 /* IPARAM(5) returns the size of the current Arnoldi */
306 /* factorization. The user is advised to check that */
307 /* enough workspace and array storage has been allocated. */
308
309
310 /* \Remarks */
311 /* 1. The converged Ritz values are always returned in ascending */
312 /* algebraic order. The computed Ritz values are approximate */
313 /* eigenvalues of OP. The selection of WHICH should be made */
314 /* with this in mind when Mode = 3,4,5. After convergence, */
315 /* approximate eigenvalues of the original problem may be obtained */
316 /* with the ARPACK subroutine dseupd . */
317
318 /* 2. If the Ritz vectors corresponding to the converged Ritz values */
319 /* are needed, the user must call dseupd immediately following completion */
320 /* of dsaupd . This is new starting with version 2.1 of ARPACK. */
321
322 /* 3. If M can be factored into a Cholesky factorization M = LL` */
323 /* then Mode = 2 should not be selected. Instead one should use */
324 /* Mode = 1 with OP = inv(L)*A*inv(L`). Appropriate triangular */
325 /* linear systems should be solved with L and L` rather */
326 /* than computing inverses. After convergence, an approximate */
327 /* eigenvector z of the original problem is recovered by solving */
328 /* L`z = x where x is a Ritz vector of OP. */
329
330 /* 4. At present there is no a-priori analysis to guide the selection */
331 /* of NCV relative to NEV. The only formal requrement is that NCV > NEV. */
332 /* However, it is recommended that NCV .ge. 2*NEV. If many problems of */
333 /* the same type are to be solved, one should experiment with increasing */
334 /* NCV while keeping NEV fixed for a given test problem. This will */
335 /* usually decrease the required number of OP*x operations but it */
336 /* also increases the work and storage required to maintain the orthogonal */
337 /* basis vectors. The optimal "cross-over" with respect to CPU time */
338 /* is problem dependent and must be determined empirically. */
339
340 /* 5. If IPARAM(7) = 2 then in the Reverse commuication interface the user */
341 /* must do the following. When IDO = 1, Y = OP * X is to be computed. */
342 /* When IPARAM(7) = 2 OP = inv(B)*A. After computing A*X the user */
343 /* must overwrite X with A*X. Y is then the solution to the linear set */
344 /* of equations B*Y = A*X. */
345
346 /* 6. When IPARAM(1) = 0, and IDO = 3, the user needs to provide the */
347 /* NP = IPARAM(8) shifts in locations: */
348 /* 1 WORKL(IPNTR(11)) */
349 /* 2 WORKL(IPNTR(11)+1) */
350 /* . */
351 /* . */
352 /* . */
353 /* NP WORKL(IPNTR(11)+NP-1). */
354
355 /* The eigenvalues of the current tridiagonal matrix are located in */
356 /* WORKL(IPNTR(6)) through WORKL(IPNTR(6)+NCV-1). They are in the */
357 /* order defined by WHICH. The associated Ritz estimates are located in */
358 /* WORKL(IPNTR(8)), WORKL(IPNTR(8)+1), ... , WORKL(IPNTR(8)+NCV-1). */
359
360 /* ----------------------------------------------------------------------- */
361
362 /* \Data Distribution Note: */
363
364 /* Fortran-D syntax: */
365 /* ================ */
366 /* REAL RESID(N), V(LDV,NCV), WORKD(3*N), WORKL(LWORKL) */
367 /* DECOMPOSE D1(N), D2(N,NCV) */
368 /* ALIGN RESID(I) with D1(I) */
369 /* ALIGN V(I,J) with D2(I,J) */
370 /* ALIGN WORKD(I) with D1(I) range (1:N) */
371 /* ALIGN WORKD(I) with D1(I-N) range (N+1:2*N) */
372 /* ALIGN WORKD(I) with D1(I-2*N) range (2*N+1:3*N) */
373 /* DISTRIBUTE D1(BLOCK), D2(BLOCK,:) */
374 /* REPLICATED WORKL(LWORKL) */
375
376 /* Cray MPP syntax: */
377 /* =============== */
378 /* REAL RESID(N), V(LDV,NCV), WORKD(N,3), WORKL(LWORKL) */
379 /* SHARED RESID(BLOCK), V(BLOCK,:), WORKD(BLOCK,:) */
380 /* REPLICATED WORKL(LWORKL) */
381
382
383 /* \BeginLib */
384
385 /* \References: */
386 /* 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in */
387 /* a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), */
388 /* pp 357-385. */
389 /* 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly */
390 /* Restarted Arnoldi Iteration", Rice University Technical Report */
391 /* TR95-13, Department of Computational and Applied Mathematics. */
392 /* 3. B.N. Parlett, "The Symmetric Eigenvalue Problem". Prentice-Hall, */
393 /* 1980. */
394 /* 4. B.N. Parlett, B. Nour-Omid, "Towards a Black Box Lanczos Program", */
395 /* Computer Physics Communications, 53 (1989), pp 169-179. */
396 /* 5. B. Nour-Omid, B.N. Parlett, T. Ericson, P.S. Jensen, "How to */
397 /* Implement the Spectral Transformation", Math. Comp., 48 (1987), */
398 /* pp 663-673. */
399 /* 6. R.G. Grimes, J.G. Lewis and H.D. Simon, "A Shifted Block Lanczos */
400 /* Algorithm for Solving Sparse Symmetric Generalized Eigenproblems", */
401 /* SIAM J. Matr. Anal. Apps., January (1993). */
402 /* 7. L. Reichel, W.B. Gragg, "Algorithm 686: FORTRAN Subroutines */
403 /* for Updating the QR decomposition", ACM TOMS, December 1990, */
404 /* Volume 16 Number 4, pp 369-377. */
405 /* 8. R.B. Lehoucq, D.C. Sorensen, "Implementation of Some Spectral */
406 /* Transformations in a k-Step Arnoldi Method". In Preparation. */
407
408 /* \Routines called: */
409 /* dsaup2 ARPACK routine that implements the Implicitly Restarted */
410 /* Arnoldi Iteration. */
411 /* dstats ARPACK routine that initialize timing and other statistics */
412 /* variables. */
413 /* ivout ARPACK utility routine that prints integers. */
414 /* second ARPACK utility routine for timing. */
415 /* dvout ARPACK utility routine that prints vectors. */
416 /* dlamch LAPACK routine that determines machine constants. */
417
418 /* \Authors */
419 /* Danny Sorensen Phuong Vu */
420 /* Richard Lehoucq CRPC / Rice University */
421 /* Dept. of Computational & Houston, Texas */
422 /* Applied Mathematics */
423 /* Rice University */
424 /* Houston, Texas */
425
426 /* \Revision history: */
427 /* 12/15/93: Version ' 2.4' */
428
429 /* \SCCS Information: @(#) */
430 /* FILE: saupd.F SID: 2.8 DATE OF SID: 04/10/01 RELEASE: 2 */
431
432 /* \Remarks */
433 /* 1. None */
434
435 /* \EndLib */
436
437 /* ----------------------------------------------------------------------- */
438
439 /* Subroutine */ int dsaupd_(integer *ido, char *bmat, integer *n, char *
440 which, integer *nev, doublereal *tol, doublereal *resid, integer *ncv,
441 doublereal *v, integer *ldv, integer *iparam, integer *ipntr,
442 doublereal *workd, doublereal *workl, integer *lworkl, integer *info,
443 ftnlen bmat_len, ftnlen which_len)
444 {
445 /* Format strings */
446 static char fmt_1000[] = "(//,5x,\002==================================="
447 "=======\002,/5x,\002= Symmetric implicit Arnoldi update code "
448 "=\002,/5x,\002= Version Number:\002,\002 2.4\002,19x,\002 =\002,"
449 "/5x,\002= Version Date: \002,\002 07/31/96\002,14x,\002 =\002,/"
450 "5x,\002==========================================\002,/5x,\002= "
451 "Summary of timing statistics =\002,/5x,\002==========="
452 "===============================\002,//)";
453 static char fmt_1100[] = "(5x,\002Total number update iterations "
454 " = \002,i5,/5x,\002Total number of OP*x operations "
455 " = \002,i5,/5x,\002Total number of B*x operations = "
456 "\002,i5,/5x,\002Total number of reorthogonalization steps = "
457 "\002,i5,/5x,\002Total number of iterative refinement steps = "
458 "\002,i5,/5x,\002Total number of restart steps = "
459 "\002,i5,/5x,\002Total time in user OP*x operation = "
460 "\002,f12.6,/5x,\002Total time in user B*x operation ="
461 " \002,f12.6,/5x,\002Total time in Arnoldi update routine = "
462 "\002,f12.6,/5x,\002Total time in saup2 routine ="
463 " \002,f12.6,/5x,\002Total time in basic Arnoldi iteration loop = "
464 "\002,f12.6,/5x,\002Total time in reorthogonalization phase ="
465 " \002,f12.6,/5x,\002Total time in (re)start vector generation = "
466 "\002,f12.6,/5x,\002Total time in trid eigenvalue subproblem ="
467 " \002,f12.6,/5x,\002Total time in getting the shifts = "
468 "\002,f12.6,/5x,\002Total time in applying the shifts ="
469 " \002,f12.6,/5x,\002Total time in convergence testing = "
470 "\002,f12.6)";
471
472 /* System generated locals */
473 integer v_dim1, v_offset, i__1, i__2;
474
475 /* Builtin functions */
476 integer s_cmp(char *, char *, ftnlen, ftnlen), s_wsfe(cilist *), e_wsfe(
477 void), do_fio(integer *, char *, ftnlen);
478
479 /* Local variables */
480 static integer j;
481 static real t0, t1;
482 static integer nb, ih, iq, np, iw, ldh, ldq, nev0, mode, ierr, iupd, next,
483 ritz;
484 extern /* Subroutine */ int dvout_(integer *, integer *, doublereal *,
485 integer *, char *, ftnlen), ivout_(integer *, integer *, integer *
486 , integer *, char *, ftnlen), dsaup2_(integer *, char *, integer *
487 , char *, integer *, integer *, doublereal *, doublereal *,
488 integer *, integer *, integer *, integer *, doublereal *, integer
489 *, doublereal *, integer *, doublereal *, doublereal *,
490 doublereal *, integer *, doublereal *, integer *, doublereal *,
491 integer *, ftnlen, ftnlen);
492 extern doublereal dlamch_(char *, ftnlen);
493 extern /* Subroutine */ int second_(real *);
494 static integer bounds, ishift, msglvl, mxiter;
495 extern /* Subroutine */ int dstats_(void);
496
497 /* Fortran I/O blocks */
498 static cilist io___21 = { 0, 6, 0, fmt_1000, 0 };
499 static cilist io___22 = { 0, 6, 0, fmt_1100, 0 };
500
501
502
503 /* %----------------------------------------------------% */
504 /* | Include files for debugging and timing information | */
505 /* %----------------------------------------------------% */
506
507
508 /* \SCCS Information: @(#) */
509 /* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */
510
511 /* %---------------------------------% */
512 /* | See debug.doc for documentation | */
513 /* %---------------------------------% */
514
515 /* %------------------% */
516 /* | Scalar Arguments | */
517 /* %------------------% */
518
519 /* %--------------------------------% */
520 /* | See stat.doc for documentation | */
521 /* %--------------------------------% */
522
523 /* \SCCS Information: @(#) */
524 /* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */
525
526
527
528 /* %-----------------% */
529 /* | Array Arguments | */
530 /* %-----------------% */
531
532
533 /* %------------% */
534 /* | Parameters | */
535 /* %------------% */
536
537
538 /* %---------------% */
539 /* | Local Scalars | */
540 /* %---------------% */
541
542
543 /* %----------------------% */
544 /* | External Subroutines | */
545 /* %----------------------% */
546
547
548 /* %--------------------% */
549 /* | External Functions | */
550 /* %--------------------% */
551
552
553 /* %-----------------------% */
554 /* | Executable Statements | */
555 /* %-----------------------% */
556
557 /* Parameter adjustments */
558 --workd;
559 --resid;
560 v_dim1 = *ldv;
561 v_offset = 1 + v_dim1;
562 v -= v_offset;
563 --iparam;
564 --ipntr;
565 --workl;
566
567 /* Function Body */
568 if (*ido == 0) {
569
570 /* %-------------------------------% */
571 /* | Initialize timing statistics | */
572 /* | & message level for debugging | */
573 /* %-------------------------------% */
574
575 dstats_();
576 second_(&t0);
577 msglvl = debug_1.msaupd;
578
579 ierr = 0;
580 ishift = iparam[1];
581 mxiter = iparam[3];
582 /* nb = iparam(4) */
583 nb = 1;
584
585 /* %--------------------------------------------% */
586 /* | Revision 2 performs only implicit restart. | */
587 /* %--------------------------------------------% */
588
589 iupd = 1;
590 mode = iparam[7];
591
592 /* %----------------% */
593 /* | Error checking | */
594 /* %----------------% */
595
596 if (*n <= 0) {
597 ierr = -1;
598 } else if (*nev <= 0) {
599 ierr = -2;
600 } else if (*ncv <= *nev || *ncv > *n) {
601 ierr = -3;
602 }
603
604 /* %----------------------------------------------% */
605 /* | NP is the number of additional steps to | */
606 /* | extend the length NEV Lanczos factorization. | */
607 /* %----------------------------------------------% */
608
609 np = *ncv - *nev;
610
611 if (mxiter <= 0) {
612 ierr = -4;
613 }
614 if (s_cmp(which, "LM", (ftnlen)2, (ftnlen)2) != 0 && s_cmp(which,
615 "SM", (ftnlen)2, (ftnlen)2) != 0 && s_cmp(which, "LA", (
616 ftnlen)2, (ftnlen)2) != 0 && s_cmp(which, "SA", (ftnlen)2, (
617 ftnlen)2) != 0 && s_cmp(which, "BE", (ftnlen)2, (ftnlen)2) !=
618 0) {
619 ierr = -5;
620 }
621 if (*(unsigned char *)bmat != 'I' && *(unsigned char *)bmat != 'G') {
622 ierr = -6;
623 }
624
625 /* Computing 2nd power */
626 i__1 = *ncv;
627 if (*lworkl < i__1 * i__1 + (*ncv << 3)) {
628 ierr = -7;
629 }
630 if (mode < 1 || mode > 5) {
631 ierr = -10;
632 } else if (mode == 1 && *(unsigned char *)bmat == 'G') {
633 ierr = -11;
634 } else if (ishift < 0 || ishift > 1) {
635 ierr = -12;
636 } else if (*nev == 1 && s_cmp(which, "BE", (ftnlen)2, (ftnlen)2) == 0)
637 {
638 ierr = -13;
639 }
640
641 /* %------------% */
642 /* | Error Exit | */
643 /* %------------% */
644
645 if (ierr != 0) {
646 *info = ierr;
647 *ido = 99;
648 goto L9000;
649 }
650
651 /* %------------------------% */
652 /* | Set default parameters | */
653 /* %------------------------% */
654
655 if (nb <= 0) {
656 nb = 1;
657 }
658 if (*tol <= 0.) {
659 *tol = dlamch_("EpsMach", (ftnlen)7);
660 }
661
662 /* %----------------------------------------------% */
663 /* | NP is the number of additional steps to | */
664 /* | extend the length NEV Lanczos factorization. | */
665 /* | NEV0 is the local variable designating the | */
666 /* | size of the invariant subspace desired. | */
667 /* %----------------------------------------------% */
668
669 np = *ncv - *nev;
670 nev0 = *nev;
671
672 /* %-----------------------------% */
673 /* | Zero out internal workspace | */
674 /* %-----------------------------% */
675
676 /* Computing 2nd power */
677 i__2 = *ncv;
678 i__1 = i__2 * i__2 + (*ncv << 3);
679 for (j = 1; j <= i__1; ++j) {
680 workl[j] = 0.;
681 /* L10: */
682 }
683
684 /* %-------------------------------------------------------% */
685 /* | Pointer into WORKL for address of H, RITZ, BOUNDS, Q | */
686 /* | etc... and the remaining workspace. | */
687 /* | Also update pointer to be used on output. | */
688 /* | Memory is laid out as follows: | */
689 /* | workl(1:2*ncv) := generated tridiagonal matrix | */
690 /* | workl(2*ncv+1:2*ncv+ncv) := ritz values | */
691 /* | workl(3*ncv+1:3*ncv+ncv) := computed error bounds | */
692 /* | workl(4*ncv+1:4*ncv+ncv*ncv) := rotation matrix Q | */
693 /* | workl(4*ncv+ncv*ncv+1:7*ncv+ncv*ncv) := workspace | */
694 /* %-------------------------------------------------------% */
695
696 ldh = *ncv;
697 ldq = *ncv;
698 ih = 1;
699 ritz = ih + (ldh << 1);
700 bounds = ritz + *ncv;
701 iq = bounds + *ncv;
702 /* Computing 2nd power */
703 i__1 = *ncv;
704 iw = iq + i__1 * i__1;
705 next = iw + *ncv * 3;
706
707 ipntr[4] = next;
708 ipntr[5] = ih;
709 ipntr[6] = ritz;
710 ipntr[7] = bounds;
711 ipntr[11] = iw;
712 }
713
714 /* %-------------------------------------------------------% */
715 /* | Carry out the Implicitly restarted Lanczos Iteration. | */
716 /* %-------------------------------------------------------% */
717
718 dsaup2_(ido, bmat, n, which, &nev0, &np, tol, &resid[1], &mode, &iupd, &
719 ishift, &mxiter, &v[v_offset], ldv, &workl[ih], &ldh, &workl[ritz]
720 , &workl[bounds], &workl[iq], &ldq, &workl[iw], &ipntr[1], &workd[
721 1], info, (ftnlen)1, (ftnlen)2);
722
723 /* %--------------------------------------------------% */
724 /* | ido .ne. 99 implies use of reverse communication | */
725 /* | to compute operations involving OP or shifts. | */
726 /* %--------------------------------------------------% */
727
728 if (*ido == 3) {
729 iparam[8] = np;
730 }
731 if (*ido != 99) {
732 goto L9000;
733 }
734
735 iparam[3] = mxiter;
736 iparam[5] = np;
737 iparam[9] = timing_1.nopx;
738 iparam[10] = timing_1.nbx;
739 iparam[11] = timing_1.nrorth;
740
741 /* %------------------------------------% */
742 /* | Exit if there was an informational | */
743 /* | error within dsaup2 . | */
744 /* %------------------------------------% */
745
746 if (*info < 0) {
747 goto L9000;
748 }
749 if (*info == 2) {
750 *info = 3;
751 }
752
753 if (msglvl > 0) {
754 ivout_(&debug_1.logfil, &c__1, &mxiter, &debug_1.ndigit, "_saupd: nu"
755 "mber of update iterations taken", (ftnlen)41);
756 ivout_(&debug_1.logfil, &c__1, &np, &debug_1.ndigit, "_saupd: number"
757 " of \"converged\" Ritz values", (ftnlen)41);
758 dvout_(&debug_1.logfil, &np, &workl[ritz], &debug_1.ndigit, "_saupd:"
759 " final Ritz values", (ftnlen)25);
760 dvout_(&debug_1.logfil, &np, &workl[bounds], &debug_1.ndigit, "_saup"
761 "d: corresponding error bounds", (ftnlen)34);
762 }
763
764 second_(&t1);
765 timing_1.tsaupd = t1 - t0;
766
767 if (msglvl > 0) {
768
769 /* %--------------------------------------------------------% */
770 /* | Version Number & Version Date are defined in version.h | */
771 /* %--------------------------------------------------------% */
772
773 s_wsfe(&io___21);
774 e_wsfe();
775 s_wsfe(&io___22);
776 do_fio(&c__1, (char *)&mxiter, (ftnlen)sizeof(integer));
777 do_fio(&c__1, (char *)&timing_1.nopx, (ftnlen)sizeof(integer));
778 do_fio(&c__1, (char *)&timing_1.nbx, (ftnlen)sizeof(integer));
779 do_fio(&c__1, (char *)&timing_1.nrorth, (ftnlen)sizeof(integer));
780 do_fio(&c__1, (char *)&timing_1.nitref, (ftnlen)sizeof(integer));
781 do_fio(&c__1, (char *)&timing_1.nrstrt, (ftnlen)sizeof(integer));
782 do_fio(&c__1, (char *)&timing_1.tmvopx, (ftnlen)sizeof(real));
783 do_fio(&c__1, (char *)&timing_1.tmvbx, (ftnlen)sizeof(real));
784 do_fio(&c__1, (char *)&timing_1.tsaupd, (ftnlen)sizeof(real));
785 do_fio(&c__1, (char *)&timing_1.tsaup2, (ftnlen)sizeof(real));
786 do_fio(&c__1, (char *)&timing_1.tsaitr, (ftnlen)sizeof(real));
787 do_fio(&c__1, (char *)&timing_1.titref, (ftnlen)sizeof(real));
788 do_fio(&c__1, (char *)&timing_1.tgetv0, (ftnlen)sizeof(real));
789 do_fio(&c__1, (char *)&timing_1.tseigt, (ftnlen)sizeof(real));
790 do_fio(&c__1, (char *)&timing_1.tsgets, (ftnlen)sizeof(real));
791 do_fio(&c__1, (char *)&timing_1.tsapps, (ftnlen)sizeof(real));
792 do_fio(&c__1, (char *)&timing_1.tsconv, (ftnlen)sizeof(real));
793 e_wsfe();
794 }
795
796 L9000:
797
798 return 0;
799
800 /* %---------------% */
801 /* | End of dsaupd | */
802 /* %---------------% */
803
804 } /* dsaupd_ */
805