Debian Codegraph @

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

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