7
c This subroutine returns the converged approximations to eigenvalues
8
c of A*z = lambda*B*z and (optionally):
10
c (1) The corresponding approximate eigenvectors;
12
c (2) An orthonormal basis for the associated approximate
17
c There is negligible additional cost to obtain eigenvectors. An orthonormal
18
c basis is always computed. There is an additional storage cost of n*nev
19
c if both are requested (in this case a separate array Z must be supplied).
21
c The approximate eigenvalues and eigenvectors of A*z = lambda*B*z
22
c are derived from approximate eigenvalues and eigenvectors of
23
c of the linear operator OP prescribed by the MODE selection in the
24
c call to SNAUPD. SNAUPD must be called before this routine is called.
25
c These approximate eigenvalues and vectors are commonly called Ritz
26
c values and Ritz vectors respectively. They are referred to as such
27
c in the comments that follow. The computed orthonormal basis for the
28
c invariant subspace corresponding to these Ritz values is referred to as a
31
c See documentation in the header of the subroutine SNAUPD for
32
c definition of OP as well as other terms and the relation of computed
33
c Ritz values and Ritz vectors of OP with respect to the given problem
34
c A*z = lambda*B*z. For a brief description, see definitions of
35
c IPARAM(7), MODE and WHICH in the documentation of SNAUPD.
39
c ( RVEC, HOWMNY, SELECT, DR, DI, Z, LDZ, SIGMAR, SIGMAI, WORKEV, BMAT,
40
c N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR, WORKD, WORKL,
44
c RVEC LOGICAL (INPUT)
45
c Specifies whether a basis for the invariant subspace corresponding
46
c to the converged Ritz value approximations for the eigenproblem
47
c A*z = lambda*B*z is computed.
49
c RVEC = .FALSE. Compute Ritz values only.
51
c RVEC = .TRUE. Compute the Ritz vectors or Schur vectors.
54
c HOWMNY Character*1 (INPUT)
55
c Specifies the form of the basis for the invariant subspace
56
c corresponding to the converged Ritz values that is to be computed.
58
c = 'A': Compute NEV Ritz vectors;
59
c = 'P': Compute NEV Schur vectors;
60
c = 'S': compute some of the Ritz vectors, specified
61
c by the logical array SELECT.
63
c SELECT Logical array of dimension NCV. (INPUT)
64
c If HOWMNY = 'S', SELECT specifies the Ritz vectors to be
65
c computed. To select the Ritz vector corresponding to a
66
c Ritz value (DR(j), DI(j)), SELECT(j) must be set to .TRUE..
67
c If HOWMNY = 'A' or 'P', SELECT is used as internal workspace.
69
c DR Real array of dimension NEV+1. (OUTPUT)
70
c If IPARAM(7) = 1,2 or 3 and SIGMAI=0.0 then on exit: DR contains
71
c the real part of the Ritz approximations to the eigenvalues of
73
c If IPARAM(7) = 3, 4 and SIGMAI is not equal to zero, then on exit:
74
c DR contains the real part of the Ritz values of OP computed by
75
c SNAUPD. A further computation must be performed by the user
76
c to transform the Ritz values computed for OP by SNAUPD to those
77
c of the original system A*z = lambda*B*z. See remark 3 below.
79
c DI Real array of dimension NEV+1. (OUTPUT)
80
c On exit, DI contains the imaginary part of the Ritz value
81
c approximations to the eigenvalues of A*z = lambda*B*z associated
84
c NOTE: When Ritz values are complex, they will come in complex
85
c conjugate pairs. If eigenvectors are requested, the
86
c corresponding Ritz vectors will also come in conjugate
87
c pairs and the real and imaginary parts of these are
88
c represented in two consecutive columns of the array Z
91
c Z Real N by NEV+1 array if RVEC = .TRUE. and HOWMNY = 'A'. (OUTPUT)
92
c On exit, if RVEC = .TRUE. and HOWMNY = 'A', then the columns of
93
c Z represent approximate eigenvectors (Ritz vectors) corresponding
94
c to the NCONV=IPARAM(5) Ritz values for eigensystem
97
c The complex Ritz vector associated with the Ritz value
98
c with positive imaginary part is stored in two consecutive
99
c columns. The first column holds the real part of the Ritz
100
c vector and the second column holds the imaginary part. The
101
c Ritz vector associated with the Ritz value with negative
102
c imaginary part is simply the complex conjugate of the Ritz vector
103
c associated with the positive imaginary part.
105
c If RVEC = .FALSE. or HOWMNY = 'P', then Z is not referenced.
107
c NOTE: If if RVEC = .TRUE. and a Schur basis is not required,
108
c the array Z may be set equal to first NEV+1 columns of the Arnoldi
109
c basis array V computed by SNAUPD. In this case the Arnoldi basis
110
c will be destroyed and overwritten with the eigenvector basis.
112
c LDZ Integer. (INPUT)
113
c The leading dimension of the array Z. If Ritz vectors are
114
c desired, then LDZ >= max( 1, N ). In any case, LDZ >= 1.
116
c SIGMAR Real (INPUT)
117
c If IPARAM(7) = 3 or 4, represents the real part of the shift.
118
c Not referenced if IPARAM(7) = 1 or 2.
120
c SIGMAI Real (INPUT)
121
c If IPARAM(7) = 3 or 4, represents the imaginary part of the shift.
122
c Not referenced if IPARAM(7) = 1 or 2. See remark 3 below.
124
c WORKEV Real work array of dimension 3*NCV. (WORKSPACE)
126
c **** The remaining arguments MUST be the same as for the ****
127
c **** call to SNAUPD that was just completed. ****
129
c NOTE: The remaining arguments
131
c BMAT, N, WHICH, NEV, TOL, RESID, NCV, V, LDV, IPARAM, IPNTR,
132
c WORKD, WORKL, LWORKL, INFO
134
c must be passed directly to SNEUPD following the last call
135
c to SNAUPD. These arguments MUST NOT BE MODIFIED between
136
c the the last call to SNAUPD and the call to SNEUPD.
138
c Three of these parameters (V, WORKL, INFO) are also output parameters:
140
c V Real N by NCV array. (INPUT/OUTPUT)
142
c Upon INPUT: the NCV columns of V contain the Arnoldi basis
143
c vectors for OP as constructed by SNAUPD .
145
c Upon OUTPUT: If RVEC = .TRUE. the first NCONV=IPARAM(5) columns
146
c contain approximate Schur vectors that span the
147
c desired invariant subspace. See Remark 2 below.
149
c NOTE: If the array Z has been set equal to first NEV+1 columns
150
c of the array V and RVEC=.TRUE. and HOWMNY= 'A', then the
151
c Arnoldi basis held by V has been overwritten by the desired
152
c Ritz vectors. If a separate array Z has been passed then
153
c the first NCONV=IPARAM(5) columns of V will contain approximate
154
c Schur vectors that span the desired invariant subspace.
156
c WORKL Real work array of length LWORKL. (OUTPUT/WORKSPACE)
157
c WORKL(1:ncv*ncv+3*ncv) contains information obtained in
158
c snaupd. They are not changed by sneupd.
159
c WORKL(ncv*ncv+3*ncv+1:3*ncv*ncv+6*ncv) holds the
160
c real and imaginary part of the untransformed Ritz values,
161
c the upper quasi-triangular matrix for H, and the
162
c associated matrix representation of the invariant subspace for H.
164
c Note: IPNTR(9:13) contains the pointer into WORKL for addresses
165
c of the above information computed by sneupd.
166
c -------------------------------------------------------------
167
c IPNTR(9): pointer to the real part of the NCV RITZ values of the
169
c IPNTR(10): pointer to the imaginary part of the NCV RITZ values of
170
c the original system.
171
c IPNTR(11): pointer to the NCV corresponding error bounds.
172
c IPNTR(12): pointer to the NCV by NCV upper quasi-triangular
173
c Schur matrix for H.
174
c IPNTR(13): pointer to the NCV by NCV matrix of eigenvectors
175
c of the upper Hessenberg matrix H. Only referenced by
176
c sneupd if RVEC = .TRUE. See Remark 2 below.
177
c -------------------------------------------------------------
179
c INFO Integer. (OUTPUT)
180
c Error flag on output.
184
c = 1: The Schur form computed by LAPACK routine slahqr
185
c could not be reordered by LAPACK routine strsen.
186
c Re-enter subroutine sneupd with IPARAM(5)=NCV and
187
c increase the size of the arrays DR and DI to have
188
c dimension at least dimension NCV and allocate at least NCV
189
c columns for Z. NOTE: Not necessary if Z and V share
190
c the same space. Please notify the authors if this error
193
c = -1: N must be positive.
194
c = -2: NEV must be positive.
195
c = -3: NCV-NEV >= 2 and less than or equal to N.
196
c = -5: WHICH must be one of 'LM', 'SM', 'LR', 'SR', 'LI', 'SI'
197
c = -6: BMAT must be one of 'I' or 'G'.
198
c = -7: Length of private work WORKL array is not sufficient.
199
c = -8: Error return from calculation of a real Schur form.
200
c Informational error from LAPACK routine slahqr.
201
c = -9: Error return from calculation of eigenvectors.
202
c Informational error from LAPACK routine strevc.
203
c = -10: IPARAM(7) must be 1,2,3,4.
204
c = -11: IPARAM(7) = 1 and BMAT = 'G' are incompatible.
205
c = -12: HOWMNY = 'S' not yet implemented
206
c = -13: HOWMNY must be one of 'A' or 'P' if RVEC = .true.
207
c = -14: SNAUPD did not find any eigenvalues to sufficient
209
c = -15: DNEUPD got a different count of the number of converged
210
c Ritz values than DNAUPD got. This indicates the user
211
c probably made an error in passing data from DNAUPD to
212
c DNEUPD or that the data was modified before entering
218
c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
219
c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
221
c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
222
c Restarted Arnoldi Iteration", Rice University Technical Report
223
c TR95-13, Department of Computational and Applied Mathematics.
224
c 3. B.N. Parlett & Y. Saad, "Complex Shift and Invert Strategies for
225
c Real Matrices", Linear Algebra and its Applications, vol 88/89,
226
c pp 575-595, (1987).
229
c ivout ARPACK utility routine that prints integers.
230
c smout ARPACK utility routine that prints matrices
231
c svout ARPACK utility routine that prints vectors.
232
c sgeqr2 LAPACK routine that computes the QR factorization of
234
c slacpy LAPACK matrix copy routine.
235
c slahqr LAPACK routine to compute the real Schur form of an
236
c upper Hessenberg matrix.
237
c slamch LAPACK routine that determines machine constants.
238
c slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully.
239
c slaset LAPACK matrix initialization routine.
240
c sorm2r LAPACK routine that applies an orthogonal matrix in
242
c strevc LAPACK routine to compute the eigenvectors of a matrix
243
c in upper quasi-triangular form.
244
c strsen LAPACK routine that re-orders the Schur form.
245
c strmm Level 3 BLAS matrix times an upper triangular matrix.
246
c sger Level 2 BLAS rank one update to a matrix.
247
c scopy Level 1 BLAS that copies one vector to another .
248
c sdot Level 1 BLAS that computes the scalar product of two vectors.
249
c snrm2 Level 1 BLAS that computes the norm of a vector.
250
c sscal Level 1 BLAS that scales a vector.
254
c 1. Currently only HOWMNY = 'A' and 'P' are implemented.
256
c Let trans(X) denote the transpose of X.
258
c 2. Schur vectors are an orthogonal representation for the basis of
259
c Ritz vectors. Thus, their numerical properties are often superior.
260
c If RVEC = .TRUE. then the relationship
261
c A * V(:,1:IPARAM(5)) = V(:,1:IPARAM(5)) * T, and
262
c trans(V(:,1:IPARAM(5))) * V(:,1:IPARAM(5)) = I are approximately
263
c satisfied. Here T is the leading submatrix of order IPARAM(5) of the
264
c real upper quasi-triangular matrix stored workl(ipntr(12)). That is,
265
c T is block upper triangular with 1-by-1 and 2-by-2 diagonal blocks;
266
c each 2-by-2 diagonal block has its diagonal elements equal and its
267
c off-diagonal elements of opposite sign. Corresponding to each 2-by-2
268
c diagonal block is a complex conjugate pair of Ritz values. The real
269
c Ritz values are stored on the diagonal of T.
271
c 3. If IPARAM(7) = 3 or 4 and SIGMAI is not equal zero, then the user must
272
c form the IPARAM(5) Rayleigh quotients in order to transform the Ritz
273
c values computed by SNAUPD for OP to those of A*z = lambda*B*z.
274
c Set RVEC = .true. and HOWMNY = 'A', and
276
c trans(Z(:,I)) * A * Z(:,I) if DI(I) = 0.
277
c If DI(I) is not equal to zero and DI(I+1) = - D(I),
278
c then the desired real and imaginary parts of the Ritz value are
279
c trans(Z(:,I)) * A * Z(:,I) + trans(Z(:,I+1)) * A * Z(:,I+1),
280
c trans(Z(:,I)) * A * Z(:,I+1) - trans(Z(:,I+1)) * A * Z(:,I),
282
c Another possibility is to set RVEC = .true. and HOWMNY = 'P' and
283
c compute trans(V(:,1:IPARAM(5))) * A * V(:,1:IPARAM(5)) and then an upper
284
c quasi-triangular matrix of order IPARAM(5) is computed. See remark
288
c Danny Sorensen Phuong Vu
289
c Richard Lehoucq CRPC / Rice University
290
c Chao Yang Houston, Texas
291
c Dept. of Computational &
292
c Applied Mathematics
296
c\SCCS Information: @(#)
297
c FILE: neupd.F SID: 2.7 DATE OF SID: 09/20/00 RELEASE: 2
301
c-----------------------------------------------------------------------
302
subroutine sneupd(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)
308
c %----------------------------------------------------%
309
c | Include files for debugging and timing information |
310
c %----------------------------------------------------%
315
c %------------------%
316
c | Scalar Arguments |
317
c %------------------%
319
character bmat, howmny, which*2
321
integer info, ldz, ldv, lworkl, n, ncv, nev
323
& sigmar, sigmai, tol
325
c %-----------------%
326
c | Array Arguments |
327
c %-----------------%
329
integer iparam(11), ipntr(14)
332
& dr(nev+1) , di(nev+1), resid(n) ,
333
& v(ldv,ncv) , z(ldz,*) , workd(3*n),
334
& workl(lworkl), workev(3*ncv)
342
parameter (one = 1.0E+0 , zero = 0.0E+0 )
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 ,
359
& conds , rnorm, sep , temp,
360
& vl(1,1), temp1, eps23
362
c %----------------------%
363
c | External Subroutines |
364
c %----------------------%
366
external scopy , sger , sgeqr2, slacpy,
367
& slahqr, slaset, smout , sorm2r,
368
& strevc, strmm , strsen, sscal ,
371
c %--------------------%
372
c | External Functions |
373
c %--------------------%
376
& slapy2, snrm2, slamch, sdot
377
external slapy2, snrm2, slamch, sdot
379
c %---------------------%
380
c | Intrinsic Functions |
381
c %---------------------%
383
intrinsic abs, min, sqrt
385
c %-----------------------%
386
c | Executable Statements |
387
c %-----------------------%
389
c %------------------------%
390
c | Set default parameters |
391
c %------------------------%
398
c %---------------------------------%
399
c | Get machine dependent constant. |
400
c %---------------------------------%
402
eps23 = slamch('Epsilon-Machine')
403
eps23 = eps23**(2.0E+0 / 3.0E+0 )
411
if (nconv .le. 0) then
413
else if (n .le. 0) then
415
else if (nev .le. 0) then
417
else if (ncv .le. nev+1 .or. ncv .gt. n) then
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
426
else if (bmat .ne. 'I' .and. bmat .ne. 'G') then
428
else if (lworkl .lt. 3*ncv**2 + 6*ncv) then
430
else if ( (howmny .ne. 'A' .and.
431
& howmny .ne. 'P' .and.
432
& howmny .ne. 'S') .and. rvec ) then
434
else if (howmny .eq. 'S' ) then
438
if (mode .eq. 1 .or. mode .eq. 2) then
440
else if (mode .eq. 3 .and. sigmai .eq. zero) then
442
else if (mode .eq. 3 ) then
444
else if (mode .eq. 4 ) then
449
if (mode .eq. 1 .and. bmat .eq. 'G') ierr = -11
455
if (ierr .ne. 0) then
460
c %--------------------------------------------------------%
461
c | Pointer into WORKL for address of H, RITZ, BOUNDS, Q |
462
c | etc... and the remaining workspace. |
463
c | Also update pointer to be used on output. |
464
c | Memory is laid out as follows: |
465
c | workl(1:ncv*ncv) := generated Hessenberg matrix |
466
c | workl(ncv*ncv+1:ncv*ncv+2*ncv) := real and imaginary |
467
c | parts of ritz values |
468
c | workl(ncv*ncv+2*ncv+1:ncv*ncv+3*ncv) := error bounds |
469
c %--------------------------------------------------------%
471
c %-----------------------------------------------------------%
472
c | The following is used and set by SNEUPD. |
473
c | workl(ncv*ncv+3*ncv+1:ncv*ncv+4*ncv) := The untransformed |
474
c | real part of the Ritz values. |
475
c | workl(ncv*ncv+4*ncv+1:ncv*ncv+5*ncv) := The untransformed |
476
c | imaginary part of the Ritz values. |
477
c | workl(ncv*ncv+5*ncv+1:ncv*ncv+6*ncv) := The untransformed |
478
c | error bounds of the Ritz values |
479
c | workl(ncv*ncv+6*ncv+1:2*ncv*ncv+6*ncv) := Holds the upper |
480
c | quasi-triangular matrix for H |
481
c | workl(2*ncv*ncv+6*ncv+1: 3*ncv*ncv+6*ncv) := Holds the |
482
c | associated matrix representation of the invariant |
483
c | subspace for H. |
484
c | GRAND total of NCV * ( 3 * NCV + 6 ) locations. |
485
c %-----------------------------------------------------------%
493
iheigr = bounds + ldh
494
iheigi = iheigr + ldh
497
invsub = iuptri + ldh*ncv
507
c %-----------------------------------------%
508
c | irr points to the REAL part of the Ritz |
509
c | values computed by _neigh before |
510
c | exiting _naup2. |
511
c | iri points to the IMAGINARY part of the |
512
c | Ritz values computed by _neigh |
513
c | before exiting _naup2. |
514
c | ibd points to the Ritz estimates |
515
c | computed by _neigh before exiting |
517
c %-----------------------------------------%
519
irr = ipntr(14)+ncv*ncv
523
c %------------------------------------%
524
c | RNORM is B-norm of the RESID(1:N). |
525
c %------------------------------------%
530
if (msglvl .gt. 2) then
531
call svout(logfil, ncv, workl(irr), ndigit,
532
& '_neupd: Real part of Ritz values passed in from _NAUPD.')
533
call svout(logfil, ncv, workl(iri), ndigit,
534
& '_neupd: Imag part of Ritz values passed in from _NAUPD.')
535
call svout(logfil, ncv, workl(ibd), ndigit,
536
& '_neupd: Ritz estimates passed in from _NAUPD.')
543
c %---------------------------------------------------%
544
c | Use the temporary bounds array to store indices |
545
c | These will be used to mark the select array later |
546
c %---------------------------------------------------%
549
workl(bounds+j-1) = j
553
c %-------------------------------------%
554
c | Select the wanted Ritz values. |
555
c | Sort the Ritz values so that the |
556
c | wanted ones appear at the tailing |
557
c | NEV positions of workl(irr) and |
558
c | workl(iri). Move the corresponding |
559
c | error estimates in workl(bound) |
561
c %-------------------------------------%
565
call sngets(ishift , which , nev ,
566
& np , workl(irr), workl(iri),
567
& workl(bounds), workl , workl(np+1))
569
if (msglvl .gt. 2) then
570
call svout(logfil, ncv, workl(irr), ndigit,
571
& '_neupd: Real part of Ritz values after calling _NGETS.')
572
call svout(logfil, ncv, workl(iri), ndigit,
573
& '_neupd: Imag part of Ritz values after calling _NGETS.')
574
call svout(logfil, ncv, workl(bounds), ndigit,
575
& '_neupd: Ritz value indices after calling _NGETS.')
578
c %-----------------------------------------------------%
579
c | Record indices of the converged wanted Ritz values |
580
c | Mark the select array for possible reordering |
581
c %-----------------------------------------------------%
586
& slapy2( 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
592
if (jj .gt. nev) reord = .true.
596
c %-----------------------------------------------------------%
597
c | Check the count (numcnv) of converged Ritz values with |
598
c | the number (nconv) reported by dnaupd. If these two |
599
c | are different then there has probably been an error |
600
c | caused by incorrect passing of the dnaupd data. |
601
c %-----------------------------------------------------------%
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')
610
if (numcnv .ne. nconv) then
615
c %-----------------------------------------------------------%
616
c | Call LAPACK routine slahqr to compute the real Schur form |
617
c | of the upper Hessenberg matrix returned by SNAUPD. |
618
c | Make a copy of the upper Hessenberg matrix. |
619
c | Initialize the Schur vector matrix Q to the identity. |
620
c %-----------------------------------------------------------%
622
call scopy(ldh*ncv, workl(ih), 1, workl(iuptri), 1)
623
call slaset('All', ncv, ncv,
624
& zero , one, workl(invsub),
626
call slahqr(.true., .true. , ncv,
627
& 1 , ncv , workl(iuptri),
628
& ldh , workl(iheigr), workl(iheigi),
629
& 1 , ncv , workl(invsub),
631
call scopy(ncv , workl(invsub+ncv-1), ldq,
634
if (ierr .ne. 0) then
639
if (msglvl .gt. 1) then
640
call svout(logfil, ncv, workl(iheigr), ndigit,
641
& '_neupd: Real part of the eigenvalues of H')
642
call svout(logfil, ncv, workl(iheigi), ndigit,
643
& '_neupd: Imaginary part of the Eigenvalues of H')
644
call svout(logfil, ncv, workl(ihbds), ndigit,
645
& '_neupd: Last row of the Schur vector matrix')
646
if (msglvl .gt. 3) then
647
call smout(logfil , ncv, ncv ,
648
& workl(iuptri), ldh, ndigit,
649
& '_neupd: The upper quasi-triangular matrix ')
655
c %-----------------------------------------------------%
656
c | Reorder the computed upper quasi-triangular matrix. |
657
c %-----------------------------------------------------%
659
call strsen('None' , 'V' ,
661
& workl(iuptri), ldh ,
662
& workl(invsub), ldq ,
663
& workl(iheigr), workl(iheigi),
665
& sep , workl(ihbds) ,
669
if (nconv2 .lt. nconv) then
673
if (ierr .eq. 1) then
678
if (msglvl .gt. 2) then
679
call svout(logfil, ncv, workl(iheigr), ndigit,
680
& '_neupd: Real part of the eigenvalues of H--reordered')
681
call svout(logfil, ncv, workl(iheigi), ndigit,
682
& '_neupd: Imag part of the eigenvalues of H--reordered')
683
if (msglvl .gt. 3) then
684
call smout(logfil , ncv, ncv ,
685
& workl(iuptri), ldq, ndigit,
686
& '_neupd: Quasi-triangular matrix after re-ordering')
692
c %---------------------------------------%
693
c | Copy the last row of the Schur vector |
694
c | into workl(ihbds). This will be used |
695
c | to compute the Ritz estimates of |
696
c | converged Ritz values. |
697
c %---------------------------------------%
699
call scopy(ncv, workl(invsub+ncv-1), ldq, workl(ihbds), 1)
701
c %----------------------------------------------------%
702
c | Place the computed eigenvalues of H into DR and DI |
703
c | if a spectral transformation was not used. |
704
c %----------------------------------------------------%
706
if (type .eq. 'REGULR') then
707
call scopy(nconv, workl(iheigr), 1, dr, 1)
708
call scopy(nconv, workl(iheigi), 1, di, 1)
711
c %----------------------------------------------------------%
712
c | Compute the QR factorization of the matrix representing |
713
c | the wanted invariant subspace located in the first NCONV |
714
c | columns of workl(invsub,ldq). |
715
c %----------------------------------------------------------%
717
call sgeqr2(ncv, nconv , workl(invsub),
718
& ldq, workev, workev(ncv+1),
721
c %---------------------------------------------------------%
722
c | * Postmultiply V by Q using sorm2r. |
723
c | * Copy the first NCONV columns of VQ into Z. |
724
c | * Postmultiply Z by R. |
725
c | The N by NCONV matrix Z is now a matrix representation |
726
c | of the approximate invariant subspace associated with |
727
c | the Ritz values in workl(iheigr) and workl(iheigi) |
728
c | The first NCONV columns of V are now approximate Schur |
729
c | vectors associated with the real upper quasi-triangular |
730
c | matrix of order NCONV in workl(iuptri) |
731
c %---------------------------------------------------------%
733
call sorm2r('Right', 'Notranspose', n ,
734
& ncv , nconv , workl(invsub),
736
& ldv , workd(n+1) , ierr)
737
call slacpy('All', n, nconv, v, ldv, z, ldz)
741
c %---------------------------------------------------%
742
c | Perform both a column and row scaling if the |
743
c | diagonal element of workl(invsub,ldq) is negative |
744
c | I'm lazy and don't take advantage of the upper |
745
c | quasi-triangular form of workl(iuptri,ldq) |
746
c | Note that since Q is orthogonal, R is a diagonal |
747
c | matrix consisting of plus or minus ones |
748
c %---------------------------------------------------%
750
if (workl(invsub+(j-1)*ldq+j-1) .lt. zero) then
751
call sscal(nconv, -one, workl(iuptri+j-1), ldq)
752
call sscal(nconv, -one, workl(iuptri+(j-1)*ldq), 1)
757
if (howmny .eq. 'A') then
759
c %--------------------------------------------%
760
c | Compute the NCONV wanted eigenvectors of T |
761
c | located in workl(iuptri,ldq). |
762
c %--------------------------------------------%
765
if (j .le. nconv) then
772
call strevc('Right', 'Select' , select ,
773
& ncv , workl(iuptri), ldq ,
774
& vl , 1 , workl(invsub),
775
& ldq , ncv , outncv ,
778
if (ierr .ne. 0) then
783
c %------------------------------------------------%
784
c | Scale the returning eigenvectors so that their |
785
c | Euclidean norms are all one. LAPACK subroutine |
786
c | strevc returns each eigenvector normalized so |
787
c | that the element of largest magnitude has |
789
c %------------------------------------------------%
794
if ( workl(iheigi+j-1) .eq. zero ) then
796
c %----------------------%
797
c | real eigenvalue case |
798
c %----------------------%
800
temp = snrm2( ncv, workl(invsub+(j-1)*ldq), 1 )
801
call sscal( ncv, one / temp,
802
& workl(invsub+(j-1)*ldq), 1 )
806
c %-------------------------------------------%
807
c | Complex conjugate pair case. Note that |
808
c | since the real and imaginary part of |
809
c | the eigenvector are stored in consecutive |
810
c | columns, we further normalize by the |
811
c | square root of two. |
812
c %-------------------------------------------%
814
if (iconj .eq. 0) then
815
temp = slapy2(snrm2(ncv,
816
& workl(invsub+(j-1)*ldq),
819
& workl(invsub+j*ldq),
821
call sscal(ncv, one/temp,
822
& workl(invsub+(j-1)*ldq), 1 )
823
call sscal(ncv, one/temp,
824
& workl(invsub+j*ldq), 1 )
834
call sgemv('T', ncv, nconv, one, workl(invsub),
835
& ldq, workl(ihbds), 1, zero, workev, 1)
839
if (workl(iheigi+j-1) .ne. zero) then
841
c %-------------------------------------------%
842
c | Complex conjugate pair case. Note that |
843
c | since the real and imaginary part of |
844
c | the eigenvector are stored in consecutive |
845
c %-------------------------------------------%
847
if (iconj .eq. 0) then
848
workev(j) = slapy2(workev(j), workev(j+1))
849
workev(j+1) = workev(j)
857
if (msglvl .gt. 2) then
858
call scopy(ncv, workl(invsub+ncv-1), ldq,
860
call svout(logfil, ncv, workl(ihbds), ndigit,
861
& '_neupd: Last row of the eigenvector matrix for T')
862
if (msglvl .gt. 3) then
863
call smout(logfil, ncv, ncv, workl(invsub), ldq,
864
& ndigit, '_neupd: The eigenvector matrix for T')
868
c %---------------------------------------%
869
c | Copy Ritz estimates into workl(ihbds) |
870
c %---------------------------------------%
872
call scopy(nconv, workev, 1, workl(ihbds), 1)
874
c %---------------------------------------------------------%
875
c | Compute the QR factorization of the eigenvector matrix |
876
c | associated with leading portion of T in the first NCONV |
877
c | columns of workl(invsub,ldq). |
878
c %---------------------------------------------------------%
880
call sgeqr2(ncv, nconv , workl(invsub),
881
& ldq, workev, workev(ncv+1),
884
c %----------------------------------------------%
885
c | * Postmultiply Z by Q. |
886
c | * Postmultiply Z by R. |
887
c | The N by NCONV matrix Z is now contains the |
888
c | Ritz vectors associated with the Ritz values |
889
c | in workl(iheigr) and workl(iheigi). |
890
c %----------------------------------------------%
892
call sorm2r('Right', 'Notranspose', n ,
893
& ncv , nconv , workl(invsub),
895
& ldz , workd(n+1) , ierr)
897
call strmm('Right' , 'Upper' , 'No transpose',
898
& 'Non-unit', n , nconv ,
899
& one , workl(invsub), ldq ,
906
c %------------------------------------------------------%
907
c | An approximate invariant subspace is not needed. |
908
c | Place the Ritz values computed SNAUPD into DR and DI |
909
c %------------------------------------------------------%
911
call scopy(nconv, workl(ritzr), 1, dr, 1)
912
call scopy(nconv, workl(ritzi), 1, di, 1)
913
call scopy(nconv, workl(ritzr), 1, workl(iheigr), 1)
914
call scopy(nconv, workl(ritzi), 1, workl(iheigi), 1)
915
call scopy(nconv, workl(bounds), 1, workl(ihbds), 1)
918
c %------------------------------------------------%
919
c | Transform the Ritz values and possibly vectors |
920
c | and corresponding error bounds of OP to those |
921
c | of A*x = lambda*B*x. |
922
c %------------------------------------------------%
924
if (type .eq. 'REGULR') then
927
& call sscal(ncv, rnorm, workl(ihbds), 1)
931
c %---------------------------------------%
932
c | A spectral transformation was used. |
933
c | * Determine the Ritz estimates of the |
934
c | Ritz values in the original system. |
935
c %---------------------------------------%
937
if (type .eq. 'SHIFTI') then
940
& call sscal(ncv, rnorm, workl(ihbds), 1)
943
temp = slapy2( workl(iheigr+k-1),
944
& workl(iheigi+k-1) )
945
workl(ihbds+k-1) = abs( workl(ihbds+k-1) )
949
else if (type .eq. 'REALPT') then
954
else if (type .eq. 'IMAGPT') then
961
c %-----------------------------------------------------------%
962
c | * Transform the Ritz values back to the original system. |
963
c | For TYPE = 'SHIFTI' the transformation is |
964
c | lambda = 1/theta + sigma |
965
c | For TYPE = 'REALPT' or 'IMAGPT' the user must from |
966
c | Rayleigh quotients or a projection. See remark 3 above.|
968
c | *The Ritz vectors are not affected by the transformation. |
969
c %-----------------------------------------------------------%
971
if (type .eq. 'SHIFTI') then
974
temp = slapy2( workl(iheigr+k-1),
975
& workl(iheigi+k-1) )
976
workl(iheigr+k-1) = workl(iheigr+k-1)/temp/temp
978
workl(iheigi+k-1) = -workl(iheigi+k-1)/temp/temp
982
call scopy(nconv, workl(iheigr), 1, dr, 1)
983
call scopy(nconv, workl(iheigi), 1, di, 1)
985
else if (type .eq. 'REALPT' .or. type .eq. 'IMAGPT') then
987
call scopy(nconv, workl(iheigr), 1, dr, 1)
988
call scopy(nconv, workl(iheigi), 1, di, 1)
994
if (type .eq. 'SHIFTI' .and. msglvl .gt. 1) then
995
call svout(logfil, nconv, dr, ndigit,
996
& '_neupd: Untransformed real part of the Ritz valuess.')
997
call svout (logfil, nconv, di, ndigit,
998
& '_neupd: Untransformed imag part of the Ritz valuess.')
999
call svout(logfil, nconv, workl(ihbds), ndigit,
1000
& '_neupd: Ritz estimates of untransformed Ritz values.')
1001
else if (type .eq. 'REGULR' .and. msglvl .gt. 1) then
1002
call svout(logfil, nconv, dr, ndigit,
1003
& '_neupd: Real parts of converged Ritz values.')
1004
call svout (logfil, nconv, di, ndigit,
1005
& '_neupd: Imag parts of converged Ritz values.')
1006
call svout(logfil, nconv, workl(ihbds), ndigit,
1007
& '_neupd: Associated Ritz estimates.')
1010
c %-------------------------------------------------%
1011
c | Eigenvector Purification step. Formally perform |
1012
c | one of inverse subspace iteration. Only used |
1014
c %-------------------------------------------------%
1016
if (rvec .and. howmny .eq. 'A' .and. type .eq. 'SHIFTI') then
1018
c %------------------------------------------------%
1019
c | Purify the computed Ritz vectors by adding a |
1020
c | little bit of the residual vector: |
1022
c | resid(:)*( e s ) / theta |
1024
c | where H s = s theta. Remember that when theta |
1025
c | has nonzero imaginary part, the corresponding |
1026
c | Ritz vector is stored across two columns of Z. |
1027
c %------------------------------------------------%
1031
if (workl(iheigi+j-1) .eq. zero) then
1032
workev(j) = workl(invsub+(j-1)*ldq+ncv-1) /
1034
else if (iconj .eq. 0) then
1035
temp = slapy2( workl(iheigr+j-1), workl(iheigi+j-1) )
1036
workev(j) = ( workl(invsub+(j-1)*ldq+ncv-1) *
1037
& workl(iheigr+j-1) +
1038
& workl(invsub+j*ldq+ncv-1) *
1039
& workl(iheigi+j-1) ) / temp / temp
1040
workev(j+1) = ( workl(invsub+j*ldq+ncv-1) *
1041
& workl(iheigr+j-1) -
1042
& workl(invsub+(j-1)*ldq+ncv-1) *
1043
& workl(iheigi+j-1) ) / temp / temp
1050
c %---------------------------------------%
1051
c | Perform a rank one update to Z and |
1052
c | purify all the Ritz vectors together. |
1053
c %---------------------------------------%
1055
call sger(n, nconv, one, resid, 1, workev, 1, z, ldz)