1c\BeginDoc 2c 3c\Name: dneupd 4c 5c\Description: 6c 7c This subroutine returns the converged approximations to eigenvalues 8c of A*z = lambda*B*z and (optionally): 9c 10c (1) The corresponding approximate eigenvectors; 11c 12c (2) An orthonormal basis for the associated approximate 13c invariant subspace; 14c 15c (3) Both. 16c 17c There is negligible additional cost to obtain eigenvectors. An orthonormal 18c basis is always computed. There is an additional storage cost of n*nev 19c if both are requested (in this case a separate array Z must be supplied). 20c 21c The approximate eigenvalues and eigenvectors of A*z = lambda*B*z 22c are derived from approximate eigenvalues and eigenvectors of 23c of the linear operator OP prescribed by the MODE selection in the 24c call to DNAUPD . DNAUPD must be called before this routine is called. 25c These approximate eigenvalues and vectors are commonly called Ritz 26c values and Ritz vectors respectively. They are referred to as such 27c in the comments that follow. The computed orthonormal basis for the 28c invariant subspace corresponding to these Ritz values is referred to as a 29c Schur basis. 30c 31c See documentation in the header of the subroutine DNAUPD for 32c definition of OP as well as other terms and the relation of computed 33c Ritz values and Ritz vectors of OP with respect to the given problem 34c A*z = lambda*B*z. For a brief description, see definitions of 35c IPARAM(7), MODE and WHICH in the documentation of DNAUPD . 36c 37c\Usage: 38c call dneupd 39c ( RVEC, HOWMNY, SELECT, DR, DI, Z, LDZ, SIGMAR, SIGMAI, WORKEV, BMAT, 40c N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, WORKD, WORKL, 41c LWORKL, INFO ) 42c 43c\Arguments: 44c RVEC LOGICAL (INPUT) 45c Specifies whether a basis for the invariant subspace corresponding 46c to the converged Ritz value approximations for the eigenproblem 47c A*z = lambda*B*z is computed. 48c 49c RVEC = .FALSE. Compute Ritz values only. 50c 51c RVEC = .TRUE. Compute the Ritz vectors or Schur vectors. 52c See Remarks below. 53c 54c HOWMNY Character*1 (INPUT) 55c Specifies the form of the basis for the invariant subspace 56c corresponding to the converged Ritz values that is to be computed. 57c 58c = 'A': Compute NEV Ritz vectors; 59c = 'P': Compute NEV Schur vectors; 60c = 'S': compute some of the Ritz vectors, specified 61c by the logical array SELECT. 62c 63c SELECT Logical array of dimension NCV. (INPUT) 64c If HOWMNY = 'S', SELECT specifies the Ritz vectors to be 65c computed. To select the Ritz vector corresponding to a 66c Ritz value (DR(j), DI(j)), SELECT(j) must be set to .TRUE.. 67c If HOWMNY = 'A' or 'P', SELECT is used as internal workspace. 68c 69c DR Double precision array of dimension NEV+1. (OUTPUT) 70c If IPARAM(7) = 1,2 or 3 and SIGMAI=0.0 then on exit: DR contains 71c the real part of the Ritz approximations to the eigenvalues of 72c A*z = lambda*B*z. 73c If IPARAM(7) = 3, 4 and SIGMAI is not equal to zero, then on exit: 74c DR contains the real part of the Ritz values of OP computed by 75c DNAUPD . A further computation must be performed by the user 76c to transform the Ritz values computed for OP by DNAUPD to those 77c of the original system A*z = lambda*B*z. See remark 3 below. 78c 79c DI Double precision array of dimension NEV+1. (OUTPUT) 80c On exit, DI contains the imaginary part of the Ritz value 81c approximations to the eigenvalues of A*z = lambda*B*z associated 82c with DR. 83c 84c NOTE: When Ritz values are complex, they will come in complex 85c conjugate pairs. If eigenvectors are requested, the 86c corresponding Ritz vectors will also come in conjugate 87c pairs and the real and imaginary parts of these are 88c represented in two consecutive columns of the array Z 89c (see below). 90c 91c Z Double precision N by NEV+1 array if RVEC = .TRUE. and HOWMNY = 'A'. (OUTPUT) 92c On exit, if RVEC = .TRUE. and HOWMNY = 'A', then the columns of 93c Z represent approximate eigenvectors (Ritz vectors) corresponding 94c to the NCONV=IPARAM(5) Ritz values for eigensystem 95c A*z = lambda*B*z. 96c 97c The complex Ritz vector associated with the Ritz value 98c with positive imaginary part is stored in two consecutive 99c columns. The first column holds the real part of the Ritz 100c vector and the second column holds the imaginary part. The 101c Ritz vector associated with the Ritz value with negative 102c imaginary part is simply the complex conjugate of the Ritz vector 103c associated with the positive imaginary part. 104c 105c If RVEC = .FALSE. or HOWMNY = 'P', then Z is not referenced. 106c 107c NOTE: If if RVEC = .TRUE. and a Schur basis is not required, 108c the array Z may be set equal to first NEV+1 columns of the Arnoldi 109c basis array V computed by DNAUPD . In this case the Arnoldi basis 110c will be destroyed and overwritten with the eigenvector basis. 111c 112c LDZ Integer. (INPUT) 113c The leading dimension of the array Z. If Ritz vectors are 114c desired, then LDZ >= max( 1, N ). In any case, LDZ >= 1. 115c 116c SIGMAR Double precision (INPUT) 117c If IPARAM(7) = 3 or 4, represents the real part of the shift. 118c Not referenced if IPARAM(7) = 1 or 2. 119c 120c SIGMAI Double precision (INPUT) 121c If IPARAM(7) = 3 or 4, represents the imaginary part of the shift. 122c Not referenced if IPARAM(7) = 1 or 2. See remark 3 below. 123c 124c WORKEV Double precision work array of dimension 3*NCV. (WORKSPACE) 125c 126c **** The remaining arguments MUST be the same as for the **** 127c **** call to DNAUPD that was just completed. **** 128c 129c NOTE: The remaining arguments 130c 131c BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, 132c WORKD, WORKL, LWORKL, INFO 133c 134c must be passed directly to DNEUPD following the last call 135c to DNAUPD . These arguments MUST NOT BE MODIFIED between 136c the the last call to DNAUPD and the call to DNEUPD . 137c 138c Three of these parameters (V, WORKL, INFO) are also output parameters: 139c 140c V Double precision N by NCV array. (INPUT/OUTPUT) 141c 142c Upon INPUT: the NCV columns of V contain the Arnoldi basis 143c vectors for OP as constructed by DNAUPD . 144c 145c Upon OUTPUT: If RVEC = .TRUE. the first NCONV=IPARAM(5) columns 146c contain approximate Schur vectors that span the 147c desired invariant subspace. See Remark 2 below. 148c 149c NOTE: If the array Z has been set equal to first NEV+1 columns 150c of the array V and RVEC=.TRUE. and HOWMNY= 'A', then the 151c Arnoldi basis held by V has been overwritten by the desired 152c Ritz vectors. If a separate array Z has been passed then 153c the first NCONV=IPARAM(5) columns of V will contain approximate 154c Schur vectors that span the desired invariant subspace. 155c 156c WORKL Double precision work array of length LWORKL. (OUTPUT/WORKSPACE) 157c WORKL(1:ncv*ncv+3*ncv) contains information obtained in 158c dnaupd . They are not changed by dneupd . 159c WORKL(ncv*ncv+3*ncv+1:3*ncv*ncv+6*ncv) holds the 160c real and imaginary part of the untransformed Ritz values, 161c the upper quasi-triangular matrix for H, and the 162c associated matrix representation of the invariant subspace for H. 163c 164c Note: IPNTR(9:13) contains the pointer into WORKL for addresses 165c of the above information computed by dneupd . 166c ------------------------------------------------------------- 167c IPNTR(9): pointer to the real part of the NCV RITZ values of the 168c original system. 169c IPNTR(10): pointer to the imaginary part of the NCV RITZ values of 170c the original system. 171c IPNTR(11): pointer to the NCV corresponding error bounds. 172c IPNTR(12): pointer to the NCV by NCV upper quasi-triangular 173c Schur matrix for H. 174c IPNTR(13): pointer to the NCV by NCV matrix of eigenvectors 175c of the upper Hessenberg matrix H. Only referenced by 176c dneupd if RVEC = .TRUE. See Remark 2 below. 177c ------------------------------------------------------------- 178c 179c INFO Integer. (OUTPUT) 180c Error flag on output. 181c 182c = 0: Normal exit. 183c 184c = 1: The Schur form computed by LAPACK routine dlahqr 185c could not be reordered by LAPACK routine dtrsen . 186c Re-enter subroutine dneupd with IPARAM(5)=NCV and 187c increase the size of the arrays DR and DI to have 188c dimension at least dimension NCV and allocate at least NCV 189c columns for Z. NOTE: Not necessary if Z and V share 190c the same space. Please notify the authors if this error 191c occurs. 192c 193c = -1: N must be positive. 194c = -2: NEV must be positive. 195c = -3: NCV-NEV >= 2 and less than or equal to N. 196c = -5: WHICH must be one of 'LM', 'SM', 'LR', 'SR', 'LI', 'SI' 197c = -6: BMAT must be one of 'I' or 'G'. 198c = -7: Length of private work WORKL array is not sufficient. 199c = -8: Error return from calculation of a real Schur form. 200c Informational error from LAPACK routine dlahqr . 201c = -9: Error return from calculation of eigenvectors. 202c Informational error from LAPACK routine dtrevc . 203c = -10: IPARAM(7) must be 1,2,3,4. 204c = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatible. 205c = -12: HOWMNY = 'S' not yet implemented 206c = -13: HOWMNY must be one of 'A' or 'P' if RVEC = .true. 207c = -14: DNAUPD did not find any eigenvalues to sufficient 208c accuracy. 209c = -15: DNEUPD got a different count of the number of converged 210c Ritz values than DNAUPD got. This indicates the user 211c probably made an error in passing data from DNAUPD to 212c DNEUPD or that the data was modified before entering 213c DNEUPD 214c 215c\BeginLib 216c 217c\References: 218c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in 219c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), 220c pp 357-385. 221c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly 222c Restarted Arnoldi Iteration", Rice University Technical Report 223c TR95-13, Department of Computational and Applied Mathematics. 224c 3. B.N. Parlett & Y. Saad, "Complex Shift and Invert Strategies for 225c Real Matrices", Linear Algebra and its Applications, vol 88/89, 226c pp 575-595, (1987). 227c 228c\Routines called: 229c ivout ARPACK utility routine that prints integers. 230c dmout ARPACK utility routine that prints matrices 231c dvout ARPACK utility routine that prints vectors. 232c dgeqr2 LAPACK routine that computes the QR factorization of 233c a matrix. 234c dlacpy LAPACK matrix copy routine. 235c dlahqr LAPACK routine to compute the real Schur form of an 236c upper Hessenberg matrix. 237c dlamch LAPACK routine that determines machine constants. 238c dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. 239c dlaset LAPACK matrix initialization routine. 240c dorm2r LAPACK routine that applies an orthogonal matrix in 241c factored form. 242c dtrevc LAPACK routine to compute the eigenvectors of a matrix 243c in upper quasi-triangular form. 244c dtrsen LAPACK routine that re-orders the Schur form. 245c dtrmm Level 3 BLAS matrix times an upper triangular matrix. 246c dger Level 2 BLAS rank one update to a matrix. 247c dcopy Level 1 BLAS that copies one vector to another . 248c ddot Level 1 BLAS that computes the scalar product of two vectors. 249c dnrm2 Level 1 BLAS that computes the norm of a vector. 250c dscal Level 1 BLAS that scales a vector. 251c 252c\Remarks 253c 254c 1. Currently only HOWMNY = 'A' and 'P' are implemented. 255c 256c Let trans(X) denote the transpose of X. 257c 258c 2. Schur vectors are an orthogonal representation for the basis of 259c Ritz vectors. Thus, their numerical properties are often superior. 260c If RVEC = .TRUE. then the relationship 261c A * V(:,1:IPARAM(5)) = V(:,1:IPARAM(5)) * T, and 262c trans(V(:,1:IPARAM(5))) * V(:,1:IPARAM(5)) = I are approximately 263c satisfied. Here T is the leading submatrix of order IPARAM(5) of the 264c real upper quasi-triangular matrix stored workl(ipntr(12)). That is, 265c T is block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; 266c each 2-by-2 diagonal block has its diagonal elements equal and its 267c off-diagonal elements of opposite sign. Corresponding to each 2-by-2 268c diagonal block is a complex conjugate pair of Ritz values. The real 269c Ritz values are stored on the diagonal of T. 270c 271c 3. If IPARAM(7) = 3 or 4 and SIGMAI is not equal zero, then the user must 272c form the IPARAM(5) Rayleigh quotients in order to transform the Ritz 273c values computed by DNAUPD for OP to those of A*z = lambda*B*z. 274c Set RVEC = .true. and HOWMNY = 'A', and 275c compute 276c trans(Z(:,I)) * A * Z(:,I) if DI(I) = 0. 277c If DI(I) is not equal to zero and DI(I+1) = - D(I), 278c then the desired real and imaginary parts of the Ritz value are 279c trans(Z(:,I)) * A * Z(:,I) + trans(Z(:,I+1)) * A * Z(:,I+1), 280c trans(Z(:,I)) * A * Z(:,I+1) - trans(Z(:,I+1)) * A * Z(:,I), 281c respectively. 282c Another possibility is to set RVEC = .true. and HOWMNY = 'P' and 283c compute trans(V(:,1:IPARAM(5))) * A * V(:,1:IPARAM(5)) and then an upper 284c quasi-triangular matrix of order IPARAM(5) is computed. See remark 285c 2 above. 286c 287c\Authors 288c Danny Sorensen Phuong Vu 289c Richard Lehoucq CRPC / Rice University 290c Chao Yang Houston, Texas 291c Dept. of Computational & 292c Applied Mathematics 293c Rice University 294c Houston, Texas 295c 296c\SCCS Information: @(#) 297c FILE: neupd.F SID: 2.7 DATE OF SID: 09/20/00 RELEASE: 2 298c 299c\EndLib 300c 301c----------------------------------------------------------------------- 302 subroutine dneupd (rvec , howmny, select, dr , di, 303 & z , ldz , sigmar, sigmai, workev, 304 & bmat , n , which , nev , tol, 305 & resid, ncv , v , ldv , iparam, 306 & ipntr, workd , workl , lworkl, info) 307c 308c %----------------------------------------------------% 309c | Include files for debugging and timing information | 310c %----------------------------------------------------% 311c 312 include 'debug.h' 313 include 'stat.h' 314c 315c %------------------% 316c | Scalar Arguments | 317c %------------------% 318c 319 character bmat, howmny, which*2 320 logical rvec 321 integer info, ldz, ldv, lworkl, n, ncv, nev 322 Double precision 323 & sigmar, sigmai, tol 324c 325c %-----------------% 326c | Array Arguments | 327c %-----------------% 328c 329 integer iparam(11), ipntr(14) 330 logical select(ncv) 331 Double precision 332 & dr(nev+1) , di(nev+1), resid(n) , 333 & v(ldv,ncv) , z(ldz,*) , workd(3*n), 334 & workl(lworkl), workev(3*ncv) 335c 336c %------------% 337c | Parameters | 338c %------------% 339c 340 Double precision 341 & one, zero 342 parameter (one = 1.0D+0 , zero = 0.0D+0 ) 343c 344c %---------------% 345c | Local Scalars | 346c %---------------% 347c 348 character type*6 349 integer bounds, ierr , ih , ihbds , 350 & iheigr, iheigi, iconj , nconv , 351 & invsub, iuptri, iwev , iwork(1), 352 & j , k , ldh , ldq , 353 & mode , msglvl, outncv, ritzr , 354 & ritzi , wri , wrr , irr , 355 & iri , ibd , ishift, numcnv , 356 & np , jj 357 logical reord 358 Double precision 359 & conds , rnorm, sep , temp, 360 & vl(1,1), temp1, eps23 361c 362c %----------------------% 363c | External Subroutines | 364c %----------------------% 365c 366 external dcopy , dger , dgeqr2 , dlacpy , 367 & dlahqr , dlaset , dmout , dorm2r , 368 & dtrevc , dtrmm , dtrsen , dscal , 369 & dvout , ivout 370c 371c %--------------------% 372c | External Functions | 373c %--------------------% 374c 375 Double precision 376 & dlapy2 , dnrm2 , dlamch , ddot 377 external dlapy2 , dnrm2 , dlamch , ddot 378c 379c %---------------------% 380c | Intrinsic Functions | 381c %---------------------% 382c 383 intrinsic abs, min, sqrt 384c 385c %-----------------------% 386c | Executable Statements | 387c %-----------------------% 388c 389c %------------------------% 390c | Set default parameters | 391c %------------------------% 392c 393 msglvl = mneupd 394 mode = iparam(7) 395 nconv = iparam(5) 396 info = 0 397c 398c %---------------------------------% 399c | Get machine dependent constant. | 400c %---------------------------------% 401c 402 eps23 = dlamch ('Epsilon-Machine') 403 eps23 = eps23**(2.0D+0 / 3.0D+0 ) 404c 405c %--------------% 406c | Quick return | 407c %--------------% 408c 409 ierr = 0 410c 411 if (nconv .le. 0) then 412 ierr = -14 413 else if (n .le. 0) then 414 ierr = -1 415 else if (nev .le. 0) then 416 ierr = -2 417 else if (ncv .le. nev+1 .or. ncv .gt. n) then 418 ierr = -3 419 else if (which .ne. 'LM' .and. 420 & which .ne. 'SM' .and. 421 & which .ne. 'LR' .and. 422 & which .ne. 'SR' .and. 423 & which .ne. 'LI' .and. 424 & which .ne. 'SI') then 425 ierr = -5 426 else if (bmat .ne. 'I' .and. bmat .ne. 'G') then 427 ierr = -6 428 else if (lworkl .lt. 3*ncv**2 + 6*ncv) then 429 ierr = -7 430 else if ( (howmny .ne. 'A' .and. 431 & howmny .ne. 'P' .and. 432 & howmny .ne. 'S') .and. rvec ) then 433 ierr = -13 434 else if (howmny .eq. 'S' ) then 435 ierr = -12 436 end if 437c 438 if (mode .eq. 1 .or. mode .eq. 2) then 439 type = 'REGULR' 440 else if (mode .eq. 3 .and. sigmai .eq. zero) then 441 type = 'SHIFTI' 442 else if (mode .eq. 3 ) then 443 type = 'REALPT' 444 else if (mode .eq. 4 ) then 445 type = 'IMAGPT' 446 else 447 ierr = -10 448 end if 449 if (mode .eq. 1 .and. bmat .eq. 'G') ierr = -11 450c 451c %------------% 452c | Error Exit | 453c %------------% 454c 455 if (ierr .ne. 0) then 456 info = ierr 457 go to 9000 458 end if 459c 460c %--------------------------------------------------------% 461c | Pointer into WORKL for address of H, RITZ, BOUNDS, Q | 462c | etc... and the remaining workspace. | 463c | Also update pointer to be used on output. | 464c | Memory is laid out as follows: | 465c | workl(1:ncv*ncv) := generated Hessenberg matrix | 466c | workl(ncv*ncv+1:ncv*ncv+2*ncv) := real and imaginary | 467c | parts of ritz values | 468c | workl(ncv*ncv+2*ncv+1:ncv*ncv+3*ncv) := error bounds | 469c %--------------------------------------------------------% 470c 471c %-----------------------------------------------------------% 472c | The following is used and set by DNEUPD . | 473c | workl(ncv*ncv+3*ncv+1:ncv*ncv+4*ncv) := The untransformed | 474c | real part of the Ritz values. | 475c | workl(ncv*ncv+4*ncv+1:ncv*ncv+5*ncv) := The untransformed | 476c | imaginary part of the Ritz values. | 477c | workl(ncv*ncv+5*ncv+1:ncv*ncv+6*ncv) := The untransformed | 478c | error bounds of the Ritz values | 479c | workl(ncv*ncv+6*ncv+1:2*ncv*ncv+6*ncv) := Holds the upper | 480c | quasi-triangular matrix for H | 481c | workl(2*ncv*ncv+6*ncv+1: 3*ncv*ncv+6*ncv) := Holds the | 482c | associated matrix representation of the invariant | 483c | subspace for H. | 484c | GRAND total of NCV * ( 3 * NCV + 6 ) locations. | 485c %-----------------------------------------------------------% 486c 487 ih = ipntr(5) 488 ritzr = ipntr(6) 489 ritzi = ipntr(7) 490 bounds = ipntr(8) 491 ldh = ncv 492 ldq = ncv 493 iheigr = bounds + ldh 494 iheigi = iheigr + ldh 495 ihbds = iheigi + ldh 496 iuptri = ihbds + ldh 497 invsub = iuptri + ldh*ncv 498 ipntr(9) = iheigr 499 ipntr(10) = iheigi 500 ipntr(11) = ihbds 501 ipntr(12) = iuptri 502 ipntr(13) = invsub 503 wrr = 1 504 wri = ncv + 1 505 iwev = wri + ncv 506c 507c %-----------------------------------------% 508c | irr points to the REAL part of the Ritz | 509c | values computed by _neigh before | 510c | exiting _naup2. | 511c | iri points to the IMAGINARY part of the | 512c | Ritz values computed by _neigh | 513c | before exiting _naup2. | 514c | ibd points to the Ritz estimates | 515c | computed by _neigh before exiting | 516c | _naup2. | 517c %-----------------------------------------% 518c 519 irr = ipntr(14)+ncv*ncv 520 iri = irr+ncv 521 ibd = iri+ncv 522c 523c %------------------------------------% 524c | RNORM is B-norm of the RESID(1:N). | 525c %------------------------------------% 526c 527 rnorm = workl(ih+2) 528 workl(ih+2) = zero 529c 530 if (msglvl .gt. 2) then 531 call dvout (logfil, ncv, workl(irr), ndigit, 532 & '_neupd: Real part of Ritz values passed in from _NAUPD.') 533 call dvout (logfil, ncv, workl(iri), ndigit, 534 & '_neupd: Imag part of Ritz values passed in from _NAUPD.') 535 call dvout (logfil, ncv, workl(ibd), ndigit, 536 & '_neupd: Ritz estimates passed in from _NAUPD.') 537 end if 538c 539 if (rvec) then 540c 541 reord = .false. 542c 543c %---------------------------------------------------% 544c | Use the temporary bounds array to store indices | 545c | These will be used to mark the select array later | 546c %---------------------------------------------------% 547c 548 do 10 j = 1,ncv 549 workl(bounds+j-1) = j 550 select(j) = .false. 551 10 continue 552c 553c %-------------------------------------% 554c | Select the wanted Ritz values. | 555c | Sort the Ritz values so that the | 556c | wanted ones appear at the tailing | 557c | NEV positions of workl(irr) and | 558c | workl(iri). Move the corresponding | 559c | error estimates in workl(bound) | 560c | accordingly. | 561c %-------------------------------------% 562c 563 np = ncv - nev 564 ishift = 0 565 call dngets (ishift , which , nev , 566 & np , workl(irr), workl(iri), 567 & workl(bounds), workl , workl(np+1)) 568c 569 if (msglvl .gt. 2) then 570 call dvout (logfil, ncv, workl(irr), ndigit, 571 & '_neupd: Real part of Ritz values after calling _NGETS.') 572 call dvout (logfil, ncv, workl(iri), ndigit, 573 & '_neupd: Imag part of Ritz values after calling _NGETS.') 574 call dvout (logfil, ncv, workl(bounds), ndigit, 575 & '_neupd: Ritz value indices after calling _NGETS.') 576 end if 577c 578c %-----------------------------------------------------% 579c | Record indices of the converged wanted Ritz values | 580c | Mark the select array for possible reordering | 581c %-----------------------------------------------------% 582c 583 numcnv = 0 584 do 11 j = 1,ncv 585 temp1 = max(eps23, 586 & dlapy2 ( workl(irr+ncv-j), workl(iri+ncv-j) )) 587 jj = workl(bounds + ncv - j) 588 if (numcnv .lt. nconv .and. 589 & workl(ibd+jj-1) .le. tol*temp1) then 590 select(jj) = .true. 591 numcnv = numcnv + 1 592 if (jj .gt. nev) reord = .true. 593 endif 594 11 continue 595c 596c %-----------------------------------------------------------% 597c | Check the count (numcnv) of converged Ritz values with | 598c | the number (nconv) reported by dnaupd. If these two | 599c | are different then there has probably been an error | 600c | caused by incorrect passing of the dnaupd data. | 601c %-----------------------------------------------------------% 602c 603 if (msglvl .gt. 2) then 604 call ivout(logfil, 1, numcnv, ndigit, 605 & '_neupd: Number of specified eigenvalues') 606 call ivout(logfil, 1, nconv, ndigit, 607 & '_neupd: Number of "converged" eigenvalues') 608 end if 609c 610 if (numcnv .ne. nconv) then 611 info = -15 612 go to 9000 613 end if 614c 615c %-----------------------------------------------------------% 616c | Call LAPACK routine dlahqr to compute the real Schur form | 617c | of the upper Hessenberg matrix returned by DNAUPD . | 618c | Make a copy of the upper Hessenberg matrix. | 619c | Initialize the Schur vector matrix Q to the identity. | 620c %-----------------------------------------------------------% 621c 622 call dcopy (ldh*ncv, workl(ih), 1, workl(iuptri), 1) 623 call dlaset ('All', ncv, ncv, 624 & zero , one, workl(invsub), 625 & ldq) 626 call dlahqr (.true., .true. , ncv, 627 & 1 , ncv , workl(iuptri), 628 & ldh , workl(iheigr), workl(iheigi), 629 & 1 , ncv , workl(invsub), 630 & ldq , ierr) 631 call dcopy (ncv , workl(invsub+ncv-1), ldq, 632 & workl(ihbds), 1) 633c 634 if (ierr .ne. 0) then 635 info = -8 636 go to 9000 637 end if 638c 639 if (msglvl .gt. 1) then 640 call dvout (logfil, ncv, workl(iheigr), ndigit, 641 & '_neupd: Real part of the eigenvalues of H') 642 call dvout (logfil, ncv, workl(iheigi), ndigit, 643 & '_neupd: Imaginary part of the Eigenvalues of H') 644 call dvout (logfil, ncv, workl(ihbds), ndigit, 645 & '_neupd: Last row of the Schur vector matrix') 646 if (msglvl .gt. 3) then 647 call dmout (logfil , ncv, ncv , 648 & workl(iuptri), ldh, ndigit, 649 & '_neupd: The upper quasi-triangular matrix ') 650 end if 651 end if 652c 653 if (reord) then 654c 655c %-----------------------------------------------------% 656c | Reorder the computed upper quasi-triangular matrix. | 657c %-----------------------------------------------------% 658c 659 call dtrsen ('None' , 'V' , 660 & select , ncv , 661 & workl(iuptri), ldh , 662 & workl(invsub), ldq , 663 & workl(iheigr), workl(iheigi), 664 & nconv , conds , 665 & sep , workl(ihbds) , 666 & ncv , iwork , 667 & 1 , ierr) 668c 669 if (ierr .eq. 1) then 670 info = 1 671 go to 9000 672 end if 673c 674 if (msglvl .gt. 2) then 675 call dvout (logfil, ncv, workl(iheigr), ndigit, 676 & '_neupd: Real part of the eigenvalues of H--reordered') 677 call dvout (logfil, ncv, workl(iheigi), ndigit, 678 & '_neupd: Imag part of the eigenvalues of H--reordered') 679 if (msglvl .gt. 3) then 680 call dmout (logfil , ncv, ncv , 681 & workl(iuptri), ldq, ndigit, 682 & '_neupd: Quasi-triangular matrix after re-ordering') 683 end if 684 end if 685c 686 end if 687c 688c %---------------------------------------% 689c | Copy the last row of the Schur vector | 690c | into workl(ihbds). This will be used | 691c | to compute the Ritz estimates of | 692c | converged Ritz values. | 693c %---------------------------------------% 694c 695 call dcopy (ncv, workl(invsub+ncv-1), ldq, workl(ihbds), 1) 696c 697c %----------------------------------------------------% 698c | Place the computed eigenvalues of H into DR and DI | 699c | if a spectral transformation was not used. | 700c %----------------------------------------------------% 701c 702 if (type .eq. 'REGULR') then 703 call dcopy (nconv, workl(iheigr), 1, dr, 1) 704 call dcopy (nconv, workl(iheigi), 1, di, 1) 705 end if 706c 707c %----------------------------------------------------------% 708c | Compute the QR factorization of the matrix representing | 709c | the wanted invariant subspace located in the first NCONV | 710c | columns of workl(invsub,ldq). | 711c %----------------------------------------------------------% 712c 713 call dgeqr2 (ncv, nconv , workl(invsub), 714 & ldq, workev, workev(ncv+1), 715 & ierr) 716c 717c %---------------------------------------------------------% 718c | * Postmultiply V by Q using dorm2r . | 719c | * Copy the first NCONV columns of VQ into Z. | 720c | * Postmultiply Z by R. | 721c | The N by NCONV matrix Z is now a matrix representation | 722c | of the approximate invariant subspace associated with | 723c | the Ritz values in workl(iheigr) and workl(iheigi) | 724c | The first NCONV columns of V are now approximate Schur | 725c | vectors associated with the real upper quasi-triangular | 726c | matrix of order NCONV in workl(iuptri) | 727c %---------------------------------------------------------% 728c 729 call dorm2r ('Right', 'Notranspose', n , 730 & ncv , nconv , workl(invsub), 731 & ldq , workev , v , 732 & ldv , workd(n+1) , ierr) 733 call dlacpy ('All', n, nconv, v, ldv, z, ldz) 734c 735 do 20 j=1, nconv 736c 737c %---------------------------------------------------% 738c | Perform both a column and row scaling if the | 739c | diagonal element of workl(invsub,ldq) is negative | 740c | I'm lazy and don't take advantage of the upper | 741c | quasi-triangular form of workl(iuptri,ldq) | 742c | Note that since Q is orthogonal, R is a diagonal | 743c | matrix consisting of plus or minus ones | 744c %---------------------------------------------------% 745c 746 if (workl(invsub+(j-1)*ldq+j-1) .lt. zero) then 747 call dscal (nconv, -one, workl(iuptri+j-1), ldq) 748 call dscal (nconv, -one, workl(iuptri+(j-1)*ldq), 1) 749 end if 750c 751 20 continue 752c 753 if (howmny .eq. 'A') then 754c 755c %--------------------------------------------% 756c | Compute the NCONV wanted eigenvectors of T | 757c | located in workl(iuptri,ldq). | 758c %--------------------------------------------% 759c 760 do 30 j=1, ncv 761 if (j .le. nconv) then 762 select(j) = .true. 763 else 764 select(j) = .false. 765 end if 766 30 continue 767c 768 call dtrevc ('Right', 'Select' , select , 769 & ncv , workl(iuptri), ldq , 770 & vl , 1 , workl(invsub), 771 & ldq , ncv , outncv , 772 & workev , ierr) 773c 774 if (ierr .ne. 0) then 775 info = -9 776 go to 9000 777 end if 778c 779c %------------------------------------------------% 780c | Scale the returning eigenvectors so that their | 781c | Euclidean norms are all one. LAPACK subroutine | 782c | dtrevc returns each eigenvector normalized so | 783c | that the element of largest magnitude has | 784c | magnitude 1; | 785c %------------------------------------------------% 786c 787 iconj = 0 788 do 40 j=1, nconv 789c 790 if ( workl(iheigi+j-1) .eq. zero ) then 791c 792c %----------------------% 793c | real eigenvalue case | 794c %----------------------% 795c 796 temp = dnrm2 ( ncv, workl(invsub+(j-1)*ldq), 1 ) 797 call dscal ( ncv, one / temp, 798 & workl(invsub+(j-1)*ldq), 1 ) 799c 800 else 801c 802c %-------------------------------------------% 803c | Complex conjugate pair case. Note that | 804c | since the real and imaginary part of | 805c | the eigenvector are stored in consecutive | 806c | columns, we further normalize by the | 807c | square root of two. | 808c %-------------------------------------------% 809c 810 if (iconj .eq. 0) then 811 temp = dlapy2 (dnrm2 (ncv, 812 & workl(invsub+(j-1)*ldq), 813 & 1), 814 & dnrm2 (ncv, 815 & workl(invsub+j*ldq), 816 & 1)) 817 call dscal (ncv, one/temp, 818 & workl(invsub+(j-1)*ldq), 1 ) 819 call dscal (ncv, one/temp, 820 & workl(invsub+j*ldq), 1 ) 821 iconj = 1 822 else 823 iconj = 0 824 end if 825c 826 end if 827c 828 40 continue 829c 830 call dgemv ('T', ncv, nconv, one, workl(invsub), 831 & ldq, workl(ihbds), 1, zero, workev, 1) 832c 833 iconj = 0 834 do 45 j=1, nconv 835 if (workl(iheigi+j-1) .ne. zero) then 836c 837c %-------------------------------------------% 838c | Complex conjugate pair case. Note that | 839c | since the real and imaginary part of | 840c | the eigenvector are stored in consecutive | 841c %-------------------------------------------% 842c 843 if (iconj .eq. 0) then 844 workev(j) = dlapy2 (workev(j), workev(j+1)) 845 workev(j+1) = workev(j) 846 iconj = 1 847 else 848 iconj = 0 849 end if 850 end if 851 45 continue 852c 853 if (msglvl .gt. 2) then 854 call dcopy (ncv, workl(invsub+ncv-1), ldq, 855 & workl(ihbds), 1) 856 call dvout (logfil, ncv, workl(ihbds), ndigit, 857 & '_neupd: Last row of the eigenvector matrix for T') 858 if (msglvl .gt. 3) then 859 call dmout (logfil, ncv, ncv, workl(invsub), ldq, 860 & ndigit, '_neupd: The eigenvector matrix for T') 861 end if 862 end if 863c 864c %---------------------------------------% 865c | Copy Ritz estimates into workl(ihbds) | 866c %---------------------------------------% 867c 868 call dcopy (nconv, workev, 1, workl(ihbds), 1) 869c 870c %---------------------------------------------------------% 871c | Compute the QR factorization of the eigenvector matrix | 872c | associated with leading portion of T in the first NCONV | 873c | columns of workl(invsub,ldq). | 874c %---------------------------------------------------------% 875c 876 call dgeqr2 (ncv, nconv , workl(invsub), 877 & ldq, workev, workev(ncv+1), 878 & ierr) 879c 880c %----------------------------------------------% 881c | * Postmultiply Z by Q. | 882c | * Postmultiply Z by R. | 883c | The N by NCONV matrix Z is now contains the | 884c | Ritz vectors associated with the Ritz values | 885c | in workl(iheigr) and workl(iheigi). | 886c %----------------------------------------------% 887c 888 call dorm2r ('Right', 'Notranspose', n , 889 & ncv , nconv , workl(invsub), 890 & ldq , workev , z , 891 & ldz , workd(n+1) , ierr) 892c 893 call dtrmm ('Right' , 'Upper' , 'No transpose', 894 & 'Non-unit', n , nconv , 895 & one , workl(invsub), ldq , 896 & z , ldz) 897c 898 end if 899c 900 else 901c 902c %------------------------------------------------------% 903c | An approximate invariant subspace is not needed. | 904c | Place the Ritz values computed DNAUPD into DR and DI | 905c %------------------------------------------------------% 906c 907 call dcopy (nconv, workl(ritzr), 1, dr, 1) 908 call dcopy (nconv, workl(ritzi), 1, di, 1) 909 call dcopy (nconv, workl(ritzr), 1, workl(iheigr), 1) 910 call dcopy (nconv, workl(ritzi), 1, workl(iheigi), 1) 911 call dcopy (nconv, workl(bounds), 1, workl(ihbds), 1) 912 end if 913c 914c %------------------------------------------------% 915c | Transform the Ritz values and possibly vectors | 916c | and corresponding error bounds of OP to those | 917c | of A*x = lambda*B*x. | 918c %------------------------------------------------% 919c 920 if (type .eq. 'REGULR') then 921c 922 if (rvec) 923 & call dscal (ncv, rnorm, workl(ihbds), 1) 924c 925 else 926c 927c %---------------------------------------% 928c | A spectral transformation was used. | 929c | * Determine the Ritz estimates of the | 930c | Ritz values in the original system. | 931c %---------------------------------------% 932c 933 if (type .eq. 'SHIFTI') then 934c 935 if (rvec) 936 & call dscal (ncv, rnorm, workl(ihbds), 1) 937c 938 do 50 k=1, ncv 939 temp = dlapy2 ( workl(iheigr+k-1), 940 & workl(iheigi+k-1) ) 941 workl(ihbds+k-1) = abs( workl(ihbds+k-1) ) 942 & / temp / temp 943 50 continue 944c 945 else if (type .eq. 'REALPT') then 946c 947 do 60 k=1, ncv 948 60 continue 949c 950 else if (type .eq. 'IMAGPT') then 951c 952 do 70 k=1, ncv 953 70 continue 954c 955 end if 956c 957c %-----------------------------------------------------------% 958c | * Transform the Ritz values back to the original system. | 959c | For TYPE = 'SHIFTI' the transformation is | 960c | lambda = 1/theta + sigma | 961c | For TYPE = 'REALPT' or 'IMAGPT' the user must from | 962c | Rayleigh quotients or a projection. See remark 3 above.| 963c | NOTES: | 964c | *The Ritz vectors are not affected by the transformation. | 965c %-----------------------------------------------------------% 966c 967 if (type .eq. 'SHIFTI') then 968c 969 do 80 k=1, ncv 970 temp = dlapy2 ( workl(iheigr+k-1), 971 & workl(iheigi+k-1) ) 972 workl(iheigr+k-1) = workl(iheigr+k-1)/temp/temp 973 & + sigmar 974 workl(iheigi+k-1) = -workl(iheigi+k-1)/temp/temp 975 & + sigmai 976 80 continue 977c 978 call dcopy (nconv, workl(iheigr), 1, dr, 1) 979 call dcopy (nconv, workl(iheigi), 1, di, 1) 980c 981 else if (type .eq. 'REALPT' .or. type .eq. 'IMAGPT') then 982c 983 call dcopy (nconv, workl(iheigr), 1, dr, 1) 984 call dcopy (nconv, workl(iheigi), 1, di, 1) 985c 986 end if 987c 988 end if 989c 990 if (type .eq. 'SHIFTI' .and. msglvl .gt. 1) then 991 call dvout (logfil, nconv, dr, ndigit, 992 & '_neupd: Untransformed real part of the Ritz valuess.') 993 call dvout (logfil, nconv, di, ndigit, 994 & '_neupd: Untransformed imag part of the Ritz valuess.') 995 call dvout (logfil, nconv, workl(ihbds), ndigit, 996 & '_neupd: Ritz estimates of untransformed Ritz values.') 997 else if (type .eq. 'REGULR' .and. msglvl .gt. 1) then 998 call dvout (logfil, nconv, dr, ndigit, 999 & '_neupd: Real parts of converged Ritz values.') 1000 call dvout (logfil, nconv, di, ndigit, 1001 & '_neupd: Imag parts of converged Ritz values.') 1002 call dvout (logfil, nconv, workl(ihbds), ndigit, 1003 & '_neupd: Associated Ritz estimates.') 1004 end if 1005c 1006c %-------------------------------------------------% 1007c | Eigenvector Purification step. Formally perform | 1008c | one of inverse subspace iteration. Only used | 1009c | for MODE = 2. | 1010c %-------------------------------------------------% 1011c 1012 if (rvec .and. howmny .eq. 'A' .and. type .eq. 'SHIFTI') then 1013c 1014c %------------------------------------------------% 1015c | Purify the computed Ritz vectors by adding a | 1016c | little bit of the residual vector: | 1017c | T | 1018c | resid(:)*( e s ) / theta | 1019c | NCV | 1020c | where H s = s theta. Remember that when theta | 1021c | has nonzero imaginary part, the corresponding | 1022c | Ritz vector is stored across two columns of Z. | 1023c %------------------------------------------------% 1024c 1025 iconj = 0 1026 do 110 j=1, nconv 1027 if (workl(iheigi+j-1) .eq. zero) then 1028 workev(j) = workl(invsub+(j-1)*ldq+ncv-1) / 1029 & workl(iheigr+j-1) 1030 else if (iconj .eq. 0) then 1031 temp = dlapy2 ( workl(iheigr+j-1), workl(iheigi+j-1) ) 1032 workev(j) = ( workl(invsub+(j-1)*ldq+ncv-1) * 1033 & workl(iheigr+j-1) + 1034 & workl(invsub+j*ldq+ncv-1) * 1035 & workl(iheigi+j-1) ) / temp / temp 1036 workev(j+1) = ( workl(invsub+j*ldq+ncv-1) * 1037 & workl(iheigr+j-1) - 1038 & workl(invsub+(j-1)*ldq+ncv-1) * 1039 & workl(iheigi+j-1) ) / temp / temp 1040 iconj = 1 1041 else 1042 iconj = 0 1043 end if 1044 110 continue 1045c 1046c %---------------------------------------% 1047c | Perform a rank one update to Z and | 1048c | purify all the Ritz vectors together. | 1049c %---------------------------------------% 1050c 1051 call dger (n, nconv, one, resid, 1, workev, 1, z, ldz) 1052c 1053 end if 1054c 1055 9000 continue 1056c 1057 return 1058c 1059c %---------------% 1060c | End of DNEUPD | 1061c %---------------% 1062c 1063 end 1064