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