Debian Codegraph @

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

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