| 1 |
c----------------------------------------------------------------------- |
| 2 |
c\BeginDoc |
| 3 |
c |
| 4 |
c\Name: dsaup2 |
| 5 |
c |
| 6 |
c\Description: |
| 7 |
c Intermediate level interface called by dsaupd. |
| 8 |
c |
| 9 |
c\Usage: |
| 10 |
c call dsaup2 |
| 11 |
c ( IDO, BMAT, N, WHICH, NEV, NP, TOL, RESID, MODE, IUPD, |
| 12 |
c ISHIFT, MXITER, V, LDV, H, LDH, RITZ, BOUNDS, Q, LDQ, WORKL, |
| 13 |
c IPNTR, WORKD, INFO ) |
| 14 |
c |
| 15 |
c\Arguments |
| 16 |
c |
| 17 |
c IDO, BMAT, N, WHICH, NEV, TOL, RESID: same as defined in dsaupd. |
| 18 |
c MODE, ISHIFT, MXITER: see the definition of IPARAM in dsaupd. |
| 19 |
c |
| 20 |
c NP Integer. (INPUT/OUTPUT) |
| 21 |
c Contains the number of implicit shifts to apply during |
| 22 |
c each Arnoldi/Lanczos iteration. |
| 23 |
c If ISHIFT=1, NP is adjusted dynamically at each iteration |
| 24 |
c to accelerate convergence and prevent stagnation. |
| 25 |
c This is also roughly equal to the number of matrix-vector |
| 26 |
c products (involving the operator OP) per Arnoldi iteration. |
| 27 |
c The logic for adjusting is contained within the current |
| 28 |
c subroutine. |
| 29 |
c If ISHIFT=0, NP is the number of shifts the user needs |
| 30 |
c to provide via reverse comunication. 0 < NP < NCV-NEV. |
| 31 |
c NP may be less than NCV-NEV since a leading block of the current |
| 32 |
c upper Tridiagonal matrix has split off and contains "unwanted" |
| 33 |
c Ritz values. |
| 34 |
c Upon termination of the IRA iteration, NP contains the number |
| 35 |
c of "converged" wanted Ritz values. |
| 36 |
c |
| 37 |
c IUPD Integer. (INPUT) |
| 38 |
c IUPD .EQ. 0: use explicit restart instead implicit update. |
| 39 |
c IUPD .NE. 0: use implicit update. |
| 40 |
c |
| 41 |
c V Double precision N by (NEV+NP) array. (INPUT/OUTPUT) |
| 42 |
c The Lanczos basis vectors. |
| 43 |
c |
| 44 |
c LDV Integer. (INPUT) |
| 45 |
c Leading dimension of V exactly as declared in the calling |
| 46 |
c program. |
| 47 |
c |
| 48 |
c H Double precision (NEV+NP) by 2 array. (OUTPUT) |
| 49 |
c H is used to store the generated symmetric tridiagonal matrix |
| 50 |
c The subdiagonal is stored in the first column of H starting |
| 51 |
c at H(2,1). The main diagonal is stored in the second column |
| 52 |
c of H starting at H(1,2). If dsaup2 converges store the |
| 53 |
c B-norm of the final residual vector in H(1,1). |
| 54 |
c |
| 55 |
c LDH Integer. (INPUT) |
| 56 |
c Leading dimension of H exactly as declared in the calling |
| 57 |
c program. |
| 58 |
c |
| 59 |
c RITZ Double precision array of length NEV+NP. (OUTPUT) |
| 60 |
c RITZ(1:NEV) contains the computed Ritz values of OP. |
| 61 |
c |
| 62 |
c BOUNDS Double precision array of length NEV+NP. (OUTPUT) |
| 63 |
c BOUNDS(1:NEV) contain the error bounds corresponding to RITZ. |
| 64 |
c |
| 65 |
c Q Double precision (NEV+NP) by (NEV+NP) array. (WORKSPACE) |
| 66 |
c Private (replicated) work array used to accumulate the |
| 67 |
c rotation in the shift application step. |
| 68 |
c |
| 69 |
c LDQ Integer. (INPUT) |
| 70 |
c Leading dimension of Q exactly as declared in the calling |
| 71 |
c program. |
| 72 |
c |
| 73 |
c WORKL Double precision array of length at least 3*(NEV+NP). (INPUT/WORKSPACE) |
| 74 |
c Private (replicated) array on each PE or array allocated on |
| 75 |
c the front end. It is used in the computation of the |
| 76 |
c tridiagonal eigenvalue problem, the calculation and |
| 77 |
c application of the shifts and convergence checking. |
| 78 |
c If ISHIFT .EQ. O and IDO .EQ. 3, the first NP locations |
| 79 |
c of WORKL are used in reverse communication to hold the user |
| 80 |
c supplied shifts. |
| 81 |
c |
| 82 |
c IPNTR Integer array of length 3. (OUTPUT) |
| 83 |
c Pointer to mark the starting locations in the WORKD for |
| 84 |
c vectors used by the Lanczos iteration. |
| 85 |
c ------------------------------------------------------------- |
| 86 |
c IPNTR(1): pointer to the current operand vector X. |
| 87 |
c IPNTR(2): pointer to the current result vector Y. |
| 88 |
c IPNTR(3): pointer to the vector B * X when used in one of |
| 89 |
c the spectral transformation modes. X is the current |
| 90 |
c operand. |
| 91 |
c ------------------------------------------------------------- |
| 92 |
c |
| 93 |
c WORKD Double precision work array of length 3*N. (REVERSE COMMUNICATION) |
| 94 |
c Distributed array to be used in the basic Lanczos iteration |
| 95 |
c for reverse communication. The user should not use WORKD |
| 96 |
c as temporary workspace during the iteration !!!!!!!!!! |
| 97 |
c See Data Distribution Note in dsaupd. |
| 98 |
c |
| 99 |
c INFO Integer. (INPUT/OUTPUT) |
| 100 |
c If INFO .EQ. 0, a randomly initial residual vector is used. |
| 101 |
c If INFO .NE. 0, RESID contains the initial residual vector, |
| 102 |
c possibly from a previous run. |
| 103 |
c Error flag on output. |
| 104 |
c = 0: Normal return. |
| 105 |
c = 1: All possible eigenvalues of OP has been found. |
| 106 |
c NP returns the size of the invariant subspace |
| 107 |
c spanning the operator OP. |
| 108 |
c = 2: No shifts could be applied. |
| 109 |
c = -8: Error return from trid. eigenvalue calculation; |
| 110 |
c This should never happen. |
| 111 |
c = -9: Starting vector is zero. |
| 112 |
c = -9999: Could not build an Lanczos factorization. |
| 113 |
c Size that was built in returned in NP. |
| 114 |
c |
| 115 |
c\EndDoc |
| 116 |
c |
| 117 |
c----------------------------------------------------------------------- |
| 118 |
c |
| 119 |
c\BeginLib |
| 120 |
c |
| 121 |
c\References: |
| 122 |
c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in |
| 123 |
c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), |
| 124 |
c pp 357-385. |
| 125 |
c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly |
| 126 |
c Restarted Arnoldi Iteration", Rice University Technical Report |
| 127 |
c TR95-13, Department of Computational and Applied Mathematics. |
| 128 |
c 3. B.N. Parlett, "The Symmetric Eigenvalue Problem". Prentice-Hall, |
| 129 |
c 1980. |
| 130 |
c 4. B.N. Parlett, B. Nour-Omid, "Towards a Black Box Lanczos Program", |
| 131 |
c Computer Physics Communications, 53 (1989), pp 169-179. |
| 132 |
c 5. B. Nour-Omid, B.N. Parlett, T. Ericson, P.S. Jensen, "How to |
| 133 |
c Implement the Spectral Transformation", Math. Comp., 48 (1987), |
| 134 |
c pp 663-673. |
| 135 |
c 6. R.G. Grimes, J.G. Lewis and H.D. Simon, "A Shifted Block Lanczos |
| 136 |
c Algorithm for Solving Sparse Symmetric Generalized Eigenproblems", |
| 137 |
c SIAM J. Matr. Anal. Apps., January (1993). |
| 138 |
c 7. L. Reichel, W.B. Gragg, "Algorithm 686: FORTRAN Subroutines |
| 139 |
c for Updating the QR decomposition", ACM TOMS, December 1990, |
| 140 |
c Volume 16 Number 4, pp 369-377. |
| 141 |
c |
| 142 |
c\Routines called: |
| 143 |
c dgetv0 ARPACK initial vector generation routine. |
| 144 |
c dsaitr ARPACK Lanczos factorization routine. |
| 145 |
c dsapps ARPACK application of implicit shifts routine. |
| 146 |
c dsconv ARPACK convergence of Ritz values routine. |
| 147 |
c dseigt ARPACK compute Ritz values and error bounds routine. |
| 148 |
c dsgets ARPACK reorder Ritz values and error bounds routine. |
| 149 |
c dsortr ARPACK sorting routine. |
| 150 |
c second ARPACK utility routine for timing. |
| 151 |
c dlamch LAPACK routine that determines machine constants. |
| 152 |
c dcopy Level 1 BLAS that copies one vector to another. |
| 153 |
c ddot Level 1 BLAS that computes the scalar product of two vectors. |
| 154 |
c dnrm2 Level 1 BLAS that computes the norm of a vector. |
| 155 |
c dscal Level 1 BLAS that scales a vector. |
| 156 |
c dswap Level 1 BLAS that swaps two vectors. |
| 157 |
c |
| 158 |
c\Author |
| 159 |
c Danny Sorensen Phuong Vu |
| 160 |
c Richard Lehoucq CRPC / Rice University |
| 161 |
c Dept. of Computational & Houston, Texas |
| 162 |
c Applied Mathematics |
| 163 |
c Rice University |
| 164 |
c Houston, Texas |
| 165 |
c |
| 166 |
c\Revision history: |
| 167 |
c 12/15/93: Version ' 2.4' |
| 168 |
c xx/xx/95: Version ' 2.4'. (R.B. Lehoucq) |
| 169 |
c |
| 170 |
c\SCCS Information: @(#) |
| 171 |
c FILE: saup2.F SID: 2.6 DATE OF SID: 8/16/96 RELEASE: 2 |
| 172 |
c |
| 173 |
c\EndLib |
| 174 |
c |
| 175 |
c----------------------------------------------------------------------- |
| 176 |
c |
| 177 |
subroutine dsaup2 |
| 178 |
& ( ido, bmat, n, which, nev, np, tol, resid, mode, iupd, |
| 179 |
& ishift, mxiter, v, ldv, h, ldh, ritz, bounds, |
| 180 |
& q, ldq, workl, ipntr, workd, info ) |
| 181 |
c |
| 182 |
c %----------------------------------------------------% |
| 183 |
c | Include files for debugging and timing information | |
| 184 |
c %----------------------------------------------------% |
| 185 |
c |
| 186 |
include 'debug.h' |
| 187 |
include 'stat.h' |
| 188 |
c |
| 189 |
c %------------------% |
| 190 |
c | Scalar Arguments | |
| 191 |
c %------------------% |
| 192 |
c |
| 193 |
character bmat*1, which*2 |
| 194 |
integer ido, info, ishift, iupd, ldh, ldq, ldv, mxiter, |
| 195 |
& n, mode, nev, np |
| 196 |
Double precision |
| 197 |
& tol |
| 198 |
c |
| 199 |
c %-----------------% |
| 200 |
c | Array Arguments | |
| 201 |
c %-----------------% |
| 202 |
c |
| 203 |
integer ipntr(3) |
| 204 |
Double precision |
| 205 |
& bounds(nev+np), h(ldh,2), q(ldq,nev+np), resid(n), |
| 206 |
& ritz(nev+np), v(ldv,nev+np), workd(3*n), |
| 207 |
& workl(3*(nev+np)) |
| 208 |
c |
| 209 |
c %------------% |
| 210 |
c | Parameters | |
| 211 |
c %------------% |
| 212 |
c |
| 213 |
Double precision |
| 214 |
& one, zero |
| 215 |
parameter (one = 1.0D+0, zero = 0.0D+0) |
| 216 |
c |
| 217 |
c %---------------% |
| 218 |
c | Local Scalars | |
| 219 |
c %---------------% |
| 220 |
c |
| 221 |
character wprime*2 |
| 222 |
logical cnorm, getv0, initv, update, ushift |
| 223 |
integer ierr, iter, j, kplusp, msglvl, nconv, nevbef, nev0, |
| 224 |
& np0, nptemp, nevd2, nevm2, kp(3) |
| 225 |
Double precision |
| 226 |
& rnorm, temp, eps23 |
| 227 |
save cnorm, getv0, initv, update, ushift, |
| 228 |
& iter, kplusp, msglvl, nconv, nev0, np0, |
| 229 |
& rnorm, eps23 |
| 230 |
c |
| 231 |
c %----------------------% |
| 232 |
c | External Subroutines | |
| 233 |
c %----------------------% |
| 234 |
c |
| 235 |
external dcopy, dgetv0, dsaitr, dscal, dsconv, dseigt, dsgets, |
| 236 |
& dsapps, dsortr, second, dswap |
| 237 |
c |
| 238 |
c %--------------------% |
| 239 |
c | External Functions | |
| 240 |
c %--------------------% |
| 241 |
c |
| 242 |
Double precision |
| 243 |
& ddot, dnrm2, dlamch |
| 244 |
external ddot, dnrm2, dlamch |
| 245 |
c |
| 246 |
c %---------------------% |
| 247 |
c | Intrinsic Functions | |
| 248 |
c %---------------------% |
| 249 |
c |
| 250 |
intrinsic min |
| 251 |
c |
| 252 |
c %-----------------------% |
| 253 |
c | Executable Statements | |
| 254 |
c %-----------------------% |
| 255 |
c |
| 256 |
if (ido .eq. 0) then |
| 257 |
c |
| 258 |
c %-------------------------------% |
| 259 |
c | Initialize timing statistics | |
| 260 |
c | & message level for debugging | |
| 261 |
c %-------------------------------% |
| 262 |
c |
| 263 |
call second (t0) |
| 264 |
msglvl = msaup2 |
| 265 |
c |
| 266 |
c %---------------------------------% |
| 267 |
c | Set machine dependent constant. | |
| 268 |
c %---------------------------------% |
| 269 |
c |
| 270 |
eps23 = dlamch('Epsilon-Machine') |
| 271 |
eps23 = eps23**(2.0D+0/3.0D+0) |
| 272 |
c |
| 273 |
c %-------------------------------------% |
| 274 |
c | nev0 and np0 are integer variables | |
| 275 |
c | hold the initial values of NEV & NP | |
| 276 |
c %-------------------------------------% |
| 277 |
c |
| 278 |
nev0 = nev |
| 279 |
np0 = np |
| 280 |
c |
| 281 |
c %-------------------------------------% |
| 282 |
c | kplusp is the bound on the largest | |
| 283 |
c | Lanczos factorization built. | |
| 284 |
c | nconv is the current number of | |
| 285 |
c | "converged" eigenvlues. | |
| 286 |
c | iter is the counter on the current | |
| 287 |
c | iteration step. | |
| 288 |
c %-------------------------------------% |
| 289 |
c |
| 290 |
kplusp = nev0 + np0 |
| 291 |
nconv = 0 |
| 292 |
iter = 0 |
| 293 |
c |
| 294 |
c %--------------------------------------------% |
| 295 |
c | Set flags for computing the first NEV steps | |
| 296 |
c | of the Lanczos factorization. | |
| 297 |
c %--------------------------------------------% |
| 298 |
c |
| 299 |
getv0 = .true. |
| 300 |
update = .false. |
| 301 |
ushift = .false. |
| 302 |
cnorm = .false. |
| 303 |
c |
| 304 |
if (info .ne. 0) then |
| 305 |
c |
| 306 |
c %--------------------------------------------% |
| 307 |
c | User provides the initial residual vector. | |
| 308 |
c %--------------------------------------------% |
| 309 |
c |
| 310 |
initv = .true. |
| 311 |
info = 0 |
| 312 |
else |
| 313 |
initv = .false. |
| 314 |
end if |
| 315 |
end if |
| 316 |
c |
| 317 |
c %---------------------------------------------% |
| 318 |
c | Get a possibly random starting vector and | |
| 319 |
c | force it into the range of the operator OP. | |
| 320 |
c %---------------------------------------------% |
| 321 |
c |
| 322 |
10 continue |
| 323 |
c |
| 324 |
if (getv0) then |
| 325 |
call dgetv0 (ido, bmat, 1, initv, n, 1, v, ldv, resid, rnorm, |
| 326 |
& ipntr, workd, info) |
| 327 |
c |
| 328 |
if (ido .ne. 99) go to 9000 |
| 329 |
c |
| 330 |
if (rnorm .eq. zero) then |
| 331 |
c |
| 332 |
c %-----------------------------------------% |
| 333 |
c | The initial vector is zero. Error exit. | |
| 334 |
c %-----------------------------------------% |
| 335 |
c |
| 336 |
info = -9 |
| 337 |
go to 1200 |
| 338 |
end if |
| 339 |
getv0 = .false. |
| 340 |
ido = 0 |
| 341 |
end if |
| 342 |
c |
| 343 |
c %------------------------------------------------------------% |
| 344 |
c | Back from reverse communication: continue with update step | |
| 345 |
c %------------------------------------------------------------% |
| 346 |
c |
| 347 |
if (update) go to 20 |
| 348 |
c |
| 349 |
c %-------------------------------------------% |
| 350 |
c | Back from computing user specified shifts | |
| 351 |
c %-------------------------------------------% |
| 352 |
c |
| 353 |
if (ushift) go to 50 |
| 354 |
c |
| 355 |
c %-------------------------------------% |
| 356 |
c | Back from computing residual norm | |
| 357 |
c | at the end of the current iteration | |
| 358 |
c %-------------------------------------% |
| 359 |
c |
| 360 |
if (cnorm) go to 100 |
| 361 |
c |
| 362 |
c %----------------------------------------------------------% |
| 363 |
c | Compute the first NEV steps of the Lanczos factorization | |
| 364 |
c %----------------------------------------------------------% |
| 365 |
c |
| 366 |
call dsaitr (ido, bmat, n, 0, nev0, mode, resid, rnorm, v, ldv, |
| 367 |
& h, ldh, ipntr, workd, info) |
| 368 |
c |
| 369 |
c %---------------------------------------------------% |
| 370 |
c | ido .ne. 99 implies use of reverse communication | |
| 371 |
c | to compute operations involving OP and possibly B | |
| 372 |
c %---------------------------------------------------% |
| 373 |
c |
| 374 |
if (ido .ne. 99) go to 9000 |
| 375 |
c |
| 376 |
if (info .gt. 0) then |
| 377 |
c |
| 378 |
c %-----------------------------------------------------% |
| 379 |
c | dsaitr was unable to build an Lanczos factorization | |
| 380 |
c | of length NEV0. INFO is returned with the size of | |
| 381 |
c | the factorization built. Exit main loop. | |
| 382 |
c %-----------------------------------------------------% |
| 383 |
c |
| 384 |
np = info |
| 385 |
mxiter = iter |
| 386 |
info = -9999 |
| 387 |
go to 1200 |
| 388 |
end if |
| 389 |
c |
| 390 |
c %--------------------------------------------------------------% |
| 391 |
c | | |
| 392 |
c | M A I N LANCZOS I T E R A T I O N L O O P | |
| 393 |
c | Each iteration implicitly restarts the Lanczos | |
| 394 |
c | factorization in place. | |
| 395 |
c | | |
| 396 |
c %--------------------------------------------------------------% |
| 397 |
c |
| 398 |
1000 continue |
| 399 |
c |
| 400 |
iter = iter + 1 |
| 401 |
c |
| 402 |
c if (msglvl .gt. 0) then |
| 403 |
c call ivout (logfil, 1, iter, ndigit, |
| 404 |
c & '_saup2: **** Start of major iteration number ****') |
| 405 |
c end if |
| 406 |
c if (msglvl .gt. 1) then |
| 407 |
c call ivout (logfil, 1, nev, ndigit, |
| 408 |
c & '_saup2: The length of the current Lanczos factorization') |
| 409 |
c call ivout (logfil, 1, np, ndigit, |
| 410 |
c & '_saup2: Extend the Lanczos factorization by') |
| 411 |
c end if |
| 412 |
c |
| 413 |
c %------------------------------------------------------------% |
| 414 |
c | Compute NP additional steps of the Lanczos factorization. | |
| 415 |
c %------------------------------------------------------------% |
| 416 |
c |
| 417 |
ido = 0 |
| 418 |
20 continue |
| 419 |
update = .true. |
| 420 |
c |
| 421 |
call dsaitr (ido, bmat, n, nev, np, mode, resid, rnorm, v, |
| 422 |
& ldv, h, ldh, ipntr, workd, info) |
| 423 |
c |
| 424 |
c %---------------------------------------------------% |
| 425 |
c | ido .ne. 99 implies use of reverse communication | |
| 426 |
c | to compute operations involving OP and possibly B | |
| 427 |
c %---------------------------------------------------% |
| 428 |
c |
| 429 |
if (ido .ne. 99) go to 9000 |
| 430 |
c |
| 431 |
if (info .gt. 0) then |
| 432 |
c |
| 433 |
c %-----------------------------------------------------% |
| 434 |
c | dsaitr was unable to build an Lanczos factorization | |
| 435 |
c | of length NEV0+NP0. INFO is returned with the size | |
| 436 |
c | of the factorization built. Exit main loop. | |
| 437 |
c %-----------------------------------------------------% |
| 438 |
c |
| 439 |
np = info |
| 440 |
mxiter = iter |
| 441 |
info = -9999 |
| 442 |
go to 1200 |
| 443 |
end if |
| 444 |
update = .false. |
| 445 |
c |
| 446 |
c if (msglvl .gt. 1) then |
| 447 |
c call dvout (logfil, 1, rnorm, ndigit, |
| 448 |
c & '_saup2: Current B-norm of residual for factorization') |
| 449 |
c end if |
| 450 |
c |
| 451 |
c %--------------------------------------------------------% |
| 452 |
c | Compute the eigenvalues and corresponding error bounds | |
| 453 |
c | of the current symmetric tridiagonal matrix. | |
| 454 |
c %--------------------------------------------------------% |
| 455 |
c |
| 456 |
call dseigt (rnorm, kplusp, h, ldh, ritz, bounds, workl, ierr) |
| 457 |
c |
| 458 |
if (ierr .ne. 0) then |
| 459 |
info = -8 |
| 460 |
go to 1200 |
| 461 |
end if |
| 462 |
c |
| 463 |
c %----------------------------------------------------% |
| 464 |
c | Make a copy of eigenvalues and corresponding error | |
| 465 |
c | bounds obtained from _seigt. | |
| 466 |
c %----------------------------------------------------% |
| 467 |
c |
| 468 |
call dcopy(kplusp, ritz, 1, workl(kplusp+1), 1) |
| 469 |
call dcopy(kplusp, bounds, 1, workl(2*kplusp+1), 1) |
| 470 |
c |
| 471 |
c %---------------------------------------------------% |
| 472 |
c | Select the wanted Ritz values and their bounds | |
| 473 |
c | to be used in the convergence test. | |
| 474 |
c | The selection is based on the requested number of | |
| 475 |
c | eigenvalues instead of the current NEV and NP to | |
| 476 |
c | prevent possible misconvergence. | |
| 477 |
c | * Wanted Ritz values := RITZ(NP+1:NEV+NP) | |
| 478 |
c | * Shifts := RITZ(1:NP) := WORKL(1:NP) | |
| 479 |
c %---------------------------------------------------% |
| 480 |
c |
| 481 |
nev = nev0 |
| 482 |
np = np0 |
| 483 |
call dsgets (ishift, which, nev, np, ritz, bounds, workl) |
| 484 |
c |
| 485 |
c %-------------------% |
| 486 |
c | Convergence test. | |
| 487 |
c %-------------------% |
| 488 |
c |
| 489 |
call dcopy (nev, bounds(np+1), 1, workl(np+1), 1) |
| 490 |
call dsconv (nev, ritz(np+1), workl(np+1), tol, nconv) |
| 491 |
c |
| 492 |
if (msglvl .gt. 2) then |
| 493 |
kp(1) = nev |
| 494 |
kp(2) = np |
| 495 |
kp(3) = nconv |
| 496 |
c call ivout (logfil, 3, kp, ndigit, |
| 497 |
c & '_saup2: NEV, NP, NCONV are') |
| 498 |
c call dvout (logfil, kplusp, ritz, ndigit, |
| 499 |
c & '_saup2: The eigenvalues of H') |
| 500 |
c call dvout (logfil, kplusp, bounds, ndigit, |
| 501 |
c & '_saup2: Ritz estimates of the current NCV Ritz values') |
| 502 |
end if |
| 503 |
c |
| 504 |
c %---------------------------------------------------------% |
| 505 |
c | Count the number of unwanted Ritz values that have zero | |
| 506 |
c | Ritz estimates. If any Ritz estimates are equal to zero | |
| 507 |
c | then a leading block of H of order equal to at least | |
| 508 |
c | the number of Ritz values with zero Ritz estimates has | |
| 509 |
c | split off. None of these Ritz values may be removed by | |
| 510 |
c | shifting. Decrease NP the number of shifts to apply. If | |
| 511 |
c | no shifts may be applied, then prepare to exit | |
| 512 |
c %---------------------------------------------------------% |
| 513 |
c |
| 514 |
nptemp = np |
| 515 |
do 30 j=1, nptemp |
| 516 |
if (bounds(j) .eq. zero) then |
| 517 |
np = np - 1 |
| 518 |
nev = nev + 1 |
| 519 |
end if |
| 520 |
30 continue |
| 521 |
c |
| 522 |
if ( (nconv .ge. nev0) .or. |
| 523 |
& (iter .gt. mxiter) .or. |
| 524 |
& (np .eq. 0) ) then |
| 525 |
c |
| 526 |
c %------------------------------------------------% |
| 527 |
c | Prepare to exit. Put the converged Ritz values | |
| 528 |
c | and corresponding bounds in RITZ(1:NCONV) and | |
| 529 |
c | BOUNDS(1:NCONV) respectively. Then sort. Be | |
| 530 |
c | careful when NCONV > NP since we don't want to | |
| 531 |
c | swap overlapping locations. | |
| 532 |
c %------------------------------------------------% |
| 533 |
c |
| 534 |
if (which .eq. 'BE') then |
| 535 |
c |
| 536 |
c %-----------------------------------------------------% |
| 537 |
c | Both ends of the spectrum are requested. | |
| 538 |
c | Sort the eigenvalues into algebraically decreasing | |
| 539 |
c | order first then swap low end of the spectrum next | |
| 540 |
c | to high end in appropriate locations. | |
| 541 |
c | NOTE: when np < floor(nev/2) be careful not to swap | |
| 542 |
c | overlapping locations. | |
| 543 |
c %-----------------------------------------------------% |
| 544 |
c |
| 545 |
wprime = 'SA' |
| 546 |
call dsortr (wprime, .true., kplusp, ritz, bounds) |
| 547 |
nevd2 = nev / 2 |
| 548 |
nevm2 = nev - nevd2 |
| 549 |
if ( nev .gt. 1 ) then |
| 550 |
call dswap ( min(nevd2,np), ritz(nevm2+1), 1, |
| 551 |
& ritz( max(kplusp-nevd2+1,kplusp-np+1) ), 1) |
| 552 |
call dswap ( min(nevd2,np), bounds(nevm2+1), 1, |
| 553 |
& bounds( max(kplusp-nevd2+1,kplusp-np)+1 ), 1) |
| 554 |
end if |
| 555 |
c |
| 556 |
else |
| 557 |
c |
| 558 |
c %--------------------------------------------------% |
| 559 |
c | LM, SM, LA, SA case. | |
| 560 |
c | Sort the eigenvalues of H into the an order that | |
| 561 |
c | is opposite to WHICH, and apply the resulting | |
| 562 |
c | order to BOUNDS. The eigenvalues are sorted so | |
| 563 |
c | that the wanted part are always within the first | |
| 564 |
c | NEV locations. | |
| 565 |
c %--------------------------------------------------% |
| 566 |
c |
| 567 |
if (which .eq. 'LM') wprime = 'SM' |
| 568 |
if (which .eq. 'SM') wprime = 'LM' |
| 569 |
if (which .eq. 'LA') wprime = 'SA' |
| 570 |
if (which .eq. 'SA') wprime = 'LA' |
| 571 |
c |
| 572 |
call dsortr (wprime, .true., kplusp, ritz, bounds) |
| 573 |
c |
| 574 |
end if |
| 575 |
c |
| 576 |
c %--------------------------------------------------% |
| 577 |
c | Scale the Ritz estimate of each Ritz value | |
| 578 |
c | by 1 / max(eps23,magnitude of the Ritz value). | |
| 579 |
c %--------------------------------------------------% |
| 580 |
c |
| 581 |
do 35 j = 1, nev0 |
| 582 |
temp = max( eps23, abs(ritz(j)) ) |
| 583 |
bounds(j) = bounds(j)/temp |
| 584 |
35 continue |
| 585 |
c |
| 586 |
c %----------------------------------------------------% |
| 587 |
c | Sort the Ritz values according to the scaled Ritz | |
| 588 |
c | esitmates. This will push all the converged ones | |
| 589 |
c | towards the front of ritzr, ritzi, bounds | |
| 590 |
c | (in the case when NCONV < NEV.) | |
| 591 |
c %----------------------------------------------------% |
| 592 |
c |
| 593 |
wprime = 'LA' |
| 594 |
call dsortr(wprime, .true., nev0, bounds, ritz) |
| 595 |
c |
| 596 |
c %----------------------------------------------% |
| 597 |
c | Scale the Ritz estimate back to its original | |
| 598 |
c | value. | |
| 599 |
c %----------------------------------------------% |
| 600 |
c |
| 601 |
do 40 j = 1, nev0 |
| 602 |
temp = max( eps23, abs(ritz(j)) ) |
| 603 |
bounds(j) = bounds(j)*temp |
| 604 |
40 continue |
| 605 |
c |
| 606 |
c %--------------------------------------------------% |
| 607 |
c | Sort the "converged" Ritz values again so that | |
| 608 |
c | the "threshold" values and their associated Ritz | |
| 609 |
c | estimates appear at the appropriate position in | |
| 610 |
c | ritz and bound. | |
| 611 |
c %--------------------------------------------------% |
| 612 |
c |
| 613 |
if (which .eq. 'BE') then |
| 614 |
c |
| 615 |
c %------------------------------------------------% |
| 616 |
c | Sort the "converged" Ritz values in increasing | |
| 617 |
c | order. The "threshold" values are in the | |
| 618 |
c | middle. | |
| 619 |
c %------------------------------------------------% |
| 620 |
c |
| 621 |
wprime = 'LA' |
| 622 |
call dsortr(wprime, .true., nconv, ritz, bounds) |
| 623 |
c |
| 624 |
else |
| 625 |
c |
| 626 |
c %----------------------------------------------% |
| 627 |
c | In LM, SM, LA, SA case, sort the "converged" | |
| 628 |
c | Ritz values according to WHICH so that the | |
| 629 |
c | "threshold" value appears at the front of | |
| 630 |
c | ritz. | |
| 631 |
c %----------------------------------------------% |
| 632 |
|
| 633 |
call dsortr(which, .true., nconv, ritz, bounds) |
| 634 |
c |
| 635 |
end if |
| 636 |
c |
| 637 |
c %------------------------------------------% |
| 638 |
c | Use h( 1,1 ) as storage to communicate | |
| 639 |
c | rnorm to _seupd if needed | |
| 640 |
c %------------------------------------------% |
| 641 |
c |
| 642 |
h(1,1) = rnorm |
| 643 |
c |
| 644 |
c if (msglvl .gt. 1) then |
| 645 |
c call dvout (logfil, kplusp, ritz, ndigit, |
| 646 |
c & '_saup2: Sorted Ritz values.') |
| 647 |
c call dvout (logfil, kplusp, bounds, ndigit, |
| 648 |
c & '_saup2: Sorted ritz estimates.') |
| 649 |
c end if |
| 650 |
c |
| 651 |
c %------------------------------------% |
| 652 |
c | Max iterations have been exceeded. | |
| 653 |
c %------------------------------------% |
| 654 |
c |
| 655 |
if (iter .gt. mxiter .and. nconv .lt. nev) info = 1 |
| 656 |
c |
| 657 |
c %---------------------% |
| 658 |
c | No shifts to apply. | |
| 659 |
c %---------------------% |
| 660 |
c |
| 661 |
if (np .eq. 0 .and. nconv .lt. nev0) info = 2 |
| 662 |
c |
| 663 |
np = nconv |
| 664 |
go to 1100 |
| 665 |
c |
| 666 |
else if (nconv .lt. nev .and. ishift .eq. 1) then |
| 667 |
c |
| 668 |
c %---------------------------------------------------% |
| 669 |
c | Do not have all the requested eigenvalues yet. | |
| 670 |
c | To prevent possible stagnation, adjust the number | |
| 671 |
c | of Ritz values and the shifts. | |
| 672 |
c %---------------------------------------------------% |
| 673 |
c |
| 674 |
nevbef = nev |
| 675 |
nev = nev + min (nconv, np/2) |
| 676 |
if (nev .eq. 1 .and. kplusp .ge. 6) then |
| 677 |
nev = kplusp / 2 |
| 678 |
else if (nev .eq. 1 .and. kplusp .gt. 2) then |
| 679 |
nev = 2 |
| 680 |
end if |
| 681 |
np = kplusp - nev |
| 682 |
c |
| 683 |
c %---------------------------------------% |
| 684 |
c | If the size of NEV was just increased | |
| 685 |
c | resort the eigenvalues. | |
| 686 |
c %---------------------------------------% |
| 687 |
c |
| 688 |
if (nevbef .lt. nev) |
| 689 |
& call dsgets (ishift, which, nev, np, ritz, bounds, |
| 690 |
& workl) |
| 691 |
c |
| 692 |
end if |
| 693 |
c |
| 694 |
if (msglvl .gt. 0) then |
| 695 |
c call ivout (logfil, 1, nconv, ndigit, |
| 696 |
c & '_saup2: no. of "converged" Ritz values at this iter.') |
| 697 |
if (msglvl .gt. 1) then |
| 698 |
kp(1) = nev |
| 699 |
kp(2) = np |
| 700 |
c call ivout (logfil, 2, kp, ndigit, |
| 701 |
c & '_saup2: NEV and NP are') |
| 702 |
c call dvout (logfil, nev, ritz(np+1), ndigit, |
| 703 |
c & '_saup2: "wanted" Ritz values.') |
| 704 |
c call dvout (logfil, nev, bounds(np+1), ndigit, |
| 705 |
c & '_saup2: Ritz estimates of the "wanted" values ') |
| 706 |
end if |
| 707 |
end if |
| 708 |
|
| 709 |
c |
| 710 |
if (ishift .eq. 0) then |
| 711 |
c |
| 712 |
c %-----------------------------------------------------% |
| 713 |
c | User specified shifts: reverse communication to | |
| 714 |
c | compute the shifts. They are returned in the first | |
| 715 |
c | NP locations of WORKL. | |
| 716 |
c %-----------------------------------------------------% |
| 717 |
c |
| 718 |
ushift = .true. |
| 719 |
ido = 3 |
| 720 |
go to 9000 |
| 721 |
end if |
| 722 |
c |
| 723 |
50 continue |
| 724 |
c |
| 725 |
c %------------------------------------% |
| 726 |
c | Back from reverse communication; | |
| 727 |
c | User specified shifts are returned | |
| 728 |
c | in WORKL(1:*NP) | |
| 729 |
c %------------------------------------% |
| 730 |
c |
| 731 |
ushift = .false. |
| 732 |
c |
| 733 |
c |
| 734 |
c %---------------------------------------------------------% |
| 735 |
c | Move the NP shifts to the first NP locations of RITZ to | |
| 736 |
c | free up WORKL. This is for the non-exact shift case; | |
| 737 |
c | in the exact shift case, dsgets already handles this. | |
| 738 |
c %---------------------------------------------------------% |
| 739 |
c |
| 740 |
if (ishift .eq. 0) call dcopy (np, workl, 1, ritz, 1) |
| 741 |
c |
| 742 |
c if (msglvl .gt. 2) then |
| 743 |
c call ivout (logfil, 1, np, ndigit, |
| 744 |
c & '_saup2: The number of shifts to apply ') |
| 745 |
c call dvout (logfil, np, workl, ndigit, |
| 746 |
c & '_saup2: shifts selected') |
| 747 |
c if (ishift .eq. 1) then |
| 748 |
c call dvout (logfil, np, bounds, ndigit, |
| 749 |
c & '_saup2: corresponding Ritz estimates') |
| 750 |
c end if |
| 751 |
c end if |
| 752 |
c |
| 753 |
c %---------------------------------------------------------% |
| 754 |
c | Apply the NP0 implicit shifts by QR bulge chasing. | |
| 755 |
c | Each shift is applied to the entire tridiagonal matrix. | |
| 756 |
c | The first 2*N locations of WORKD are used as workspace. | |
| 757 |
c | After dsapps is done, we have a Lanczos | |
| 758 |
c | factorization of length NEV. | |
| 759 |
c %---------------------------------------------------------% |
| 760 |
c |
| 761 |
call dsapps (n, nev, np, ritz, v, ldv, h, ldh, resid, q, ldq, |
| 762 |
& workd) |
| 763 |
c |
| 764 |
c %---------------------------------------------% |
| 765 |
c | Compute the B-norm of the updated residual. | |
| 766 |
c | Keep B*RESID in WORKD(1:N) to be used in | |
| 767 |
c | the first step of the next call to dsaitr. | |
| 768 |
c %---------------------------------------------% |
| 769 |
c |
| 770 |
cnorm = .true. |
| 771 |
call second (t2) |
| 772 |
if (bmat .eq. 'G') then |
| 773 |
nbx = nbx + 1 |
| 774 |
call dcopy (n, resid, 1, workd(n+1), 1) |
| 775 |
ipntr(1) = n + 1 |
| 776 |
ipntr(2) = 1 |
| 777 |
ido = 2 |
| 778 |
c |
| 779 |
c %----------------------------------% |
| 780 |
c | Exit in order to compute B*RESID | |
| 781 |
c %----------------------------------% |
| 782 |
c |
| 783 |
go to 9000 |
| 784 |
else if (bmat .eq. 'I') then |
| 785 |
call dcopy (n, resid, 1, workd, 1) |
| 786 |
end if |
| 787 |
c |
| 788 |
100 continue |
| 789 |
c |
| 790 |
c %----------------------------------% |
| 791 |
c | Back from reverse communication; | |
| 792 |
c | WORKD(1:N) := B*RESID | |
| 793 |
c %----------------------------------% |
| 794 |
c |
| 795 |
if (bmat .eq. 'G') then |
| 796 |
call second (t3) |
| 797 |
tmvbx = tmvbx + (t3 - t2) |
| 798 |
end if |
| 799 |
c |
| 800 |
if (bmat .eq. 'G') then |
| 801 |
rnorm = ddot (n, resid, 1, workd, 1) |
| 802 |
rnorm = sqrt(abs(rnorm)) |
| 803 |
else if (bmat .eq. 'I') then |
| 804 |
rnorm = dnrm2(n, resid, 1) |
| 805 |
end if |
| 806 |
cnorm = .false. |
| 807 |
130 continue |
| 808 |
c |
| 809 |
c if (msglvl .gt. 2) then |
| 810 |
c call dvout (logfil, 1, rnorm, ndigit, |
| 811 |
c & '_saup2: B-norm of residual for NEV factorization') |
| 812 |
c call dvout (logfil, nev, h(1,2), ndigit, |
| 813 |
c & '_saup2: main diagonal of compressed H matrix') |
| 814 |
c call dvout (logfil, nev-1, h(2,1), ndigit, |
| 815 |
c & '_saup2: subdiagonal of compressed H matrix') |
| 816 |
c end if |
| 817 |
c |
| 818 |
go to 1000 |
| 819 |
c |
| 820 |
c %---------------------------------------------------------------% |
| 821 |
c | | |
| 822 |
c | E N D O F M A I N I T E R A T I O N L O O P | |
| 823 |
c | | |
| 824 |
c %---------------------------------------------------------------% |
| 825 |
c |
| 826 |
1100 continue |
| 827 |
c |
| 828 |
mxiter = iter |
| 829 |
nev = nconv |
| 830 |
c |
| 831 |
1200 continue |
| 832 |
ido = 99 |
| 833 |
c |
| 834 |
c %------------% |
| 835 |
c | Error exit | |
| 836 |
c %------------% |
| 837 |
c |
| 838 |
call second (t1) |
| 839 |
tsaup2 = t1 - t0 |
| 840 |
c |
| 841 |
9000 continue |
| 842 |
return |
| 843 |
c |
| 844 |
c %---------------% |
| 845 |
c | End of dsaup2 | |
| 846 |
c %---------------% |
| 847 |
c |
| 848 |
end |