| 1 |
/* ./src_f77/cnaupd.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_CNAUPD; |
| 15 |
|
| 16 |
#define debug_1 debug_CNAUPD |
| 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_CNAUPD; |
| 25 |
|
| 26 |
#define timing_1 timing_CNAUPD |
| 27 |
|
| 28 |
/* Table of constant values */ |
| 29 |
|
| 30 |
static integer c__1 = 1; |
| 31 |
|
| 32 |
/* \BeginDoc */ |
| 33 |
|
| 34 |
/* \Name: cnaupd */ |
| 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 ssaupd or snaupd 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 |
/* cnaupd 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 cnaupd */ |
| 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 cnaupd. 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 |
/* cnaupd 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 Real 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 = slamch('EPS') (machine precision as computed */ |
| 139 |
/* by the LAPACK auxiliary subroutine slamch). */ |
| 140 |
|
| 141 |
/* RESID Complex 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 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 cnaupd 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 cneupd. 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 |
/* cneupd if RVEC = .TRUE. See Remark 2 below. */ |
| 242 |
|
| 243 |
/* ------------------------------------------------------------- */ |
| 244 |
|
| 245 |
/* WORKD Complex 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 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 Real 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 cneupd. */ |
| 304 |
|
| 305 |
/* 2. If a basis for the invariant subspace corresponding to the converged Ritz */ |
| 306 |
/* values is needed, the user must call cneupd immediately following */ |
| 307 |
/* completion of cnaupd. 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 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 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 */ |
| 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 |
/* Real Matrices", Linear Algebra and its Applications, vol 88/89, */ |
| 382 |
/* pp 575-595, (1987). */ |
| 383 |
|
| 384 |
/* \Routines called: */ |
| 385 |
/* cnaup2 ARPACK routine that implements the Implicitly Restarted */ |
| 386 |
/* Arnoldi Iteration. */ |
| 387 |
/* cstatn ARPACK routine that initializes the timing variables. */ |
| 388 |
/* ivout ARPACK utility routine that prints integers. */ |
| 389 |
/* cvout ARPACK utility routine that prints vectors. */ |
| 390 |
/* second ARPACK utility routine for timing. */ |
| 391 |
/* slamch 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 cnaupd_(integer *ido, char *bmat, integer *n, char * |
| 411 |
which, integer *nev, real *tol, realcomplex *resid, integer *ncv, realcomplex |
| 412 |
*v, integer *ldv, integer *iparam, integer *ipntr, realcomplex *workd, |
| 413 |
realcomplex *workl, integer *lworkl, real *rwork, integer *info, ftnlen |
| 414 |
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 cvout_(integer *, integer *, realcomplex *, |
| 457 |
integer *, char *, ftnlen), ivout_(integer *, integer *, integer * |
| 458 |
, integer *, char *, ftnlen), cnaup2_(integer *, char *, integer * |
| 459 |
, char *, integer *, integer *, real *, realcomplex *, integer *, |
| 460 |
integer *, integer *, integer *, realcomplex *, integer *, realcomplex *, |
| 461 |
integer *, realcomplex *, realcomplex *, realcomplex *, integer *, realcomplex *, |
| 462 |
integer *, realcomplex *, real *, integer *, ftnlen, ftnlen); |
| 463 |
extern doublereal slamch_(char *, ftnlen); |
| 464 |
extern /* Subroutine */ int second_(real *); |
| 465 |
static integer bounds, ishift, msglvl, mxiter; |
| 466 |
extern /* Subroutine */ int cstatn_(void); |
| 467 |
|
| 468 |
/* Fortran I/O blocks */ |
| 469 |
static cilist io___21 = { 0, 6, 0, fmt_1000, 0 }; |
| 470 |
static cilist io___22 = { 0, 6, 0, fmt_1100, 0 }; |
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
/* %----------------------------------------------------% */ |
| 475 |
/* | Include files for debugging and timing information | */ |
| 476 |
/* %----------------------------------------------------% */ |
| 477 |
|
| 478 |
|
| 479 |
/* \SCCS Information: @(#) */ |
| 480 |
/* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 481 |
|
| 482 |
/* %---------------------------------% */ |
| 483 |
/* | See debug.doc for documentation | */ |
| 484 |
/* %---------------------------------% */ |
| 485 |
|
| 486 |
/* %------------------% */ |
| 487 |
/* | Scalar Arguments | */ |
| 488 |
/* %------------------% */ |
| 489 |
|
| 490 |
/* %--------------------------------% */ |
| 491 |
/* | See stat.doc for documentation | */ |
| 492 |
/* %--------------------------------% */ |
| 493 |
|
| 494 |
/* \SCCS Information: @(#) */ |
| 495 |
/* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
/* %-----------------% */ |
| 500 |
/* | Array Arguments | */ |
| 501 |
/* %-----------------% */ |
| 502 |
|
| 503 |
|
| 504 |
/* %------------% */ |
| 505 |
/* | Parameters | */ |
| 506 |
/* %------------% */ |
| 507 |
|
| 508 |
|
| 509 |
/* %---------------% */ |
| 510 |
/* | Local Scalars | */ |
| 511 |
/* %---------------% */ |
| 512 |
|
| 513 |
|
| 514 |
/* %----------------------% */ |
| 515 |
/* | External Subroutines | */ |
| 516 |
/* %----------------------% */ |
| 517 |
|
| 518 |
|
| 519 |
/* %--------------------% */ |
| 520 |
/* | External Functions | */ |
| 521 |
/* %--------------------% */ |
| 522 |
|
| 523 |
|
| 524 |
/* %-----------------------% */ |
| 525 |
/* | Executable Statements | */ |
| 526 |
/* %-----------------------% */ |
| 527 |
|
| 528 |
/* Parameter adjustments */ |
| 529 |
--workd; |
| 530 |
--resid; |
| 531 |
--rwork; |
| 532 |
v_dim1 = *ldv; |
| 533 |
v_offset = 1 + v_dim1; |
| 534 |
v -= v_offset; |
| 535 |
--iparam; |
| 536 |
--ipntr; |
| 537 |
--workl; |
| 538 |
|
| 539 |
/* Function Body */ |
| 540 |
if (*ido == 0) { |
| 541 |
|
| 542 |
/* %-------------------------------% */ |
| 543 |
/* | Initialize timing statistics | */ |
| 544 |
/* | & message level for debugging | */ |
| 545 |
/* %-------------------------------% */ |
| 546 |
|
| 547 |
cstatn_(); |
| 548 |
second_(&t0); |
| 549 |
msglvl = debug_1.mcaupd; |
| 550 |
|
| 551 |
/* %----------------% */ |
| 552 |
/* | Error checking | */ |
| 553 |
/* %----------------% */ |
| 554 |
|
| 555 |
ierr = 0; |
| 556 |
ishift = iparam[1]; |
| 557 |
/* levec = iparam(2) */ |
| 558 |
mxiter = iparam[3]; |
| 559 |
/* nb = iparam(4) */ |
| 560 |
nb = 1; |
| 561 |
|
| 562 |
/* %--------------------------------------------% */ |
| 563 |
/* | Revision 2 performs only implicit restart. | */ |
| 564 |
/* %--------------------------------------------% */ |
| 565 |
|
| 566 |
iupd = 1; |
| 567 |
mode = iparam[7]; |
| 568 |
|
| 569 |
if (*n <= 0) { |
| 570 |
ierr = -1; |
| 571 |
} else if (*nev <= 0) { |
| 572 |
ierr = -2; |
| 573 |
} else if (*ncv <= *nev || *ncv > *n) { |
| 574 |
ierr = -3; |
| 575 |
} else if (mxiter <= 0) { |
| 576 |
ierr = -4; |
| 577 |
} else if (s_cmp(which, "LM", (ftnlen)2, (ftnlen)2) != 0 && s_cmp( |
| 578 |
which, "SM", (ftnlen)2, (ftnlen)2) != 0 && s_cmp(which, "LR", |
| 579 |
(ftnlen)2, (ftnlen)2) != 0 && s_cmp(which, "SR", (ftnlen)2, ( |
| 580 |
ftnlen)2) != 0 && s_cmp(which, "LI", (ftnlen)2, (ftnlen)2) != |
| 581 |
0 && s_cmp(which, "SI", (ftnlen)2, (ftnlen)2) != 0) { |
| 582 |
ierr = -5; |
| 583 |
} else if (*(unsigned char *)bmat != 'I' && *(unsigned char *)bmat != |
| 584 |
'G') { |
| 585 |
ierr = -6; |
| 586 |
} else /* if(complicated condition) */ { |
| 587 |
/* Computing 2nd power */ |
| 588 |
i__1 = *ncv; |
| 589 |
if (*lworkl < i__1 * i__1 * 3 + *ncv * 5) { |
| 590 |
ierr = -7; |
| 591 |
} else if (mode < 1 || mode > 3) { |
| 592 |
ierr = -10; |
| 593 |
} else if (mode == 1 && *(unsigned char *)bmat == 'G') { |
| 594 |
ierr = -11; |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
/* %------------% */ |
| 599 |
/* | Error Exit | */ |
| 600 |
/* %------------% */ |
| 601 |
|
| 602 |
if (ierr != 0) { |
| 603 |
*info = ierr; |
| 604 |
*ido = 99; |
| 605 |
goto L9000; |
| 606 |
} |
| 607 |
|
| 608 |
/* %------------------------% */ |
| 609 |
/* | Set default parameters | */ |
| 610 |
/* %------------------------% */ |
| 611 |
|
| 612 |
if (nb <= 0) { |
| 613 |
nb = 1; |
| 614 |
} |
| 615 |
if (*tol <= 0.f) { |
| 616 |
*tol = slamch_("EpsMach", (ftnlen)7); |
| 617 |
} |
| 618 |
if (ishift != 0 && ishift != 1 && ishift != 2) { |
| 619 |
ishift = 1; |
| 620 |
} |
| 621 |
|
| 622 |
/* %----------------------------------------------% */ |
| 623 |
/* | NP is the number of additional steps to | */ |
| 624 |
/* | extend the length NEV Lanczos factorization. | */ |
| 625 |
/* | NEV0 is the local variable designating the | */ |
| 626 |
/* | size of the invariant subspace desired. | */ |
| 627 |
/* %----------------------------------------------% */ |
| 628 |
|
| 629 |
np = *ncv - *nev; |
| 630 |
nev0 = *nev; |
| 631 |
|
| 632 |
/* %-----------------------------% */ |
| 633 |
/* | Zero out internal workspace | */ |
| 634 |
/* %-----------------------------% */ |
| 635 |
|
| 636 |
/* Computing 2nd power */ |
| 637 |
i__2 = *ncv; |
| 638 |
i__1 = i__2 * i__2 * 3 + *ncv * 5; |
| 639 |
for (j = 1; j <= i__1; ++j) { |
| 640 |
i__2 = j; |
| 641 |
workl[i__2].r = 0.f, workl[i__2].i = 0.f; |
| 642 |
/* L10: */ |
| 643 |
} |
| 644 |
|
| 645 |
/* %-------------------------------------------------------------% */ |
| 646 |
/* | Pointer into WORKL for address of H, RITZ, BOUNDS, Q | */ |
| 647 |
/* | etc... and the remaining workspace. | */ |
| 648 |
/* | Also update pointer to be used on output. | */ |
| 649 |
/* | Memory is laid out as follows: | */ |
| 650 |
/* | workl(1:ncv*ncv) := generated Hessenberg matrix | */ |
| 651 |
/* | workl(ncv*ncv+1:ncv*ncv+ncv) := the ritz values | */ |
| 652 |
/* | workl(ncv*ncv+ncv+1:ncv*ncv+2*ncv) := error bounds | */ |
| 653 |
/* | workl(ncv*ncv+2*ncv+1:2*ncv*ncv+2*ncv) := rotation matrix Q | */ |
| 654 |
/* | workl(2*ncv*ncv+2*ncv+1:3*ncv*ncv+5*ncv) := workspace | */ |
| 655 |
/* | The final workspace is needed by subroutine cneigh called | */ |
| 656 |
/* | by cnaup2. Subroutine cneigh calls LAPACK routines for | */ |
| 657 |
/* | calculating eigenvalues and the last row of the eigenvector | */ |
| 658 |
/* | matrix. | */ |
| 659 |
/* %-------------------------------------------------------------% */ |
| 660 |
|
| 661 |
ldh = *ncv; |
| 662 |
ldq = *ncv; |
| 663 |
ih = 1; |
| 664 |
ritz = ih + ldh * *ncv; |
| 665 |
bounds = ritz + *ncv; |
| 666 |
iq = bounds + *ncv; |
| 667 |
iw = iq + ldq * *ncv; |
| 668 |
/* Computing 2nd power */ |
| 669 |
i__1 = *ncv; |
| 670 |
next = iw + i__1 * i__1 + *ncv * 3; |
| 671 |
|
| 672 |
ipntr[4] = next; |
| 673 |
ipntr[5] = ih; |
| 674 |
ipntr[6] = ritz; |
| 675 |
ipntr[7] = iq; |
| 676 |
ipntr[8] = bounds; |
| 677 |
ipntr[14] = iw; |
| 678 |
} |
| 679 |
|
| 680 |
/* %-------------------------------------------------------% */ |
| 681 |
/* | Carry out the Implicitly restarted Arnoldi Iteration. | */ |
| 682 |
/* %-------------------------------------------------------% */ |
| 683 |
|
| 684 |
cnaup2_(ido, bmat, n, which, &nev0, &np, tol, &resid[1], &mode, &iupd, & |
| 685 |
ishift, &mxiter, &v[v_offset], ldv, &workl[ih], &ldh, &workl[ritz] |
| 686 |
, &workl[bounds], &workl[iq], &ldq, &workl[iw], &ipntr[1], &workd[ |
| 687 |
1], &rwork[1], info, (ftnlen)1, (ftnlen)2); |
| 688 |
|
| 689 |
/* %--------------------------------------------------% */ |
| 690 |
/* | ido .ne. 99 implies use of reverse communication | */ |
| 691 |
/* | to compute operations involving OP. | */ |
| 692 |
/* %--------------------------------------------------% */ |
| 693 |
|
| 694 |
if (*ido == 3) { |
| 695 |
iparam[8] = np; |
| 696 |
} |
| 697 |
if (*ido != 99) { |
| 698 |
goto L9000; |
| 699 |
} |
| 700 |
|
| 701 |
iparam[3] = mxiter; |
| 702 |
iparam[5] = np; |
| 703 |
iparam[9] = timing_1.nopx; |
| 704 |
iparam[10] = timing_1.nbx; |
| 705 |
iparam[11] = timing_1.nrorth; |
| 706 |
|
| 707 |
/* %------------------------------------% */ |
| 708 |
/* | Exit if there was an informational | */ |
| 709 |
/* | error within cnaup2. | */ |
| 710 |
/* %------------------------------------% */ |
| 711 |
|
| 712 |
if (*info < 0) { |
| 713 |
goto L9000; |
| 714 |
} |
| 715 |
if (*info == 2) { |
| 716 |
*info = 3; |
| 717 |
} |
| 718 |
|
| 719 |
if (msglvl > 0) { |
| 720 |
ivout_(&debug_1.logfil, &c__1, &mxiter, &debug_1.ndigit, "_naupd: Nu" |
| 721 |
"mber of update iterations taken", (ftnlen)41); |
| 722 |
ivout_(&debug_1.logfil, &c__1, &np, &debug_1.ndigit, "_naupd: Number" |
| 723 |
" of wanted \"converged\" Ritz values", (ftnlen)48); |
| 724 |
cvout_(&debug_1.logfil, &np, &workl[ritz], &debug_1.ndigit, "_naupd:" |
| 725 |
" The final Ritz values", (ftnlen)29); |
| 726 |
cvout_(&debug_1.logfil, &np, &workl[bounds], &debug_1.ndigit, "_naup" |
| 727 |
"d: Associated Ritz estimates", (ftnlen)33); |
| 728 |
} |
| 729 |
|
| 730 |
second_(&t1); |
| 731 |
timing_1.tcaupd = t1 - t0; |
| 732 |
|
| 733 |
if (msglvl > 0) { |
| 734 |
|
| 735 |
/* %--------------------------------------------------------% */ |
| 736 |
/* | Version Number & Version Date are defined in version.h | */ |
| 737 |
/* %--------------------------------------------------------% */ |
| 738 |
|
| 739 |
s_wsfe(&io___21); |
| 740 |
e_wsfe(); |
| 741 |
s_wsfe(&io___22); |
| 742 |
do_fio(&c__1, (char *)&mxiter, (ftnlen)sizeof(integer)); |
| 743 |
do_fio(&c__1, (char *)&timing_1.nopx, (ftnlen)sizeof(integer)); |
| 744 |
do_fio(&c__1, (char *)&timing_1.nbx, (ftnlen)sizeof(integer)); |
| 745 |
do_fio(&c__1, (char *)&timing_1.nrorth, (ftnlen)sizeof(integer)); |
| 746 |
do_fio(&c__1, (char *)&timing_1.nitref, (ftnlen)sizeof(integer)); |
| 747 |
do_fio(&c__1, (char *)&timing_1.nrstrt, (ftnlen)sizeof(integer)); |
| 748 |
do_fio(&c__1, (char *)&timing_1.tmvopx, (ftnlen)sizeof(real)); |
| 749 |
do_fio(&c__1, (char *)&timing_1.tmvbx, (ftnlen)sizeof(real)); |
| 750 |
do_fio(&c__1, (char *)&timing_1.tcaupd, (ftnlen)sizeof(real)); |
| 751 |
do_fio(&c__1, (char *)&timing_1.tcaup2, (ftnlen)sizeof(real)); |
| 752 |
do_fio(&c__1, (char *)&timing_1.tcaitr, (ftnlen)sizeof(real)); |
| 753 |
do_fio(&c__1, (char *)&timing_1.titref, (ftnlen)sizeof(real)); |
| 754 |
do_fio(&c__1, (char *)&timing_1.tgetv0, (ftnlen)sizeof(real)); |
| 755 |
do_fio(&c__1, (char *)&timing_1.tceigh, (ftnlen)sizeof(real)); |
| 756 |
do_fio(&c__1, (char *)&timing_1.tcgets, (ftnlen)sizeof(real)); |
| 757 |
do_fio(&c__1, (char *)&timing_1.tcapps, (ftnlen)sizeof(real)); |
| 758 |
do_fio(&c__1, (char *)&timing_1.tcconv, (ftnlen)sizeof(real)); |
| 759 |
do_fio(&c__1, (char *)&timing_1.trvec, (ftnlen)sizeof(real)); |
| 760 |
e_wsfe(); |
| 761 |
} |
| 762 |
|
| 763 |
L9000: |
| 764 |
|
| 765 |
return 0; |
| 766 |
|
| 767 |
/* %---------------% */ |
| 768 |
/* | End of cnaupd | */ |
| 769 |
/* %---------------% */ |
| 770 |
|
| 771 |
} /* cnaupd_ */ |
| 772 |
|