| 1 |
/* ./src_f77/dneigh.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_DNEIGH; |
| 15 |
|
| 16 |
#define debug_1 debug_DNEIGH |
| 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_DNEIGH; |
| 25 |
|
| 26 |
#define timing_1 timing_DNEIGH |
| 27 |
|
| 28 |
/* Table of constant values */ |
| 29 |
|
| 30 |
static logical c_true = TRUE_; |
| 31 |
static integer c__1 = 1; |
| 32 |
static doublereal c_b18 = 1.; |
| 33 |
static doublereal c_b20 = 0.; |
| 34 |
|
| 35 |
/* ----------------------------------------------------------------------- */ |
| 36 |
/* \BeginDoc */ |
| 37 |
|
| 38 |
/* \Name: dneigh */ |
| 39 |
|
| 40 |
/* \Description: */ |
| 41 |
/* Compute the eigenvalues of the current upper Hessenberg matrix */ |
| 42 |
/* and the corresponding Ritz estimates given the current residual norm. */ |
| 43 |
|
| 44 |
/* \Usage: */ |
| 45 |
/* call dneigh */ |
| 46 |
/* ( RNORM, N, H, LDH, RITZR, RITZI, BOUNDS, Q, LDQ, WORKL, IERR ) */ |
| 47 |
|
| 48 |
/* \Arguments */ |
| 49 |
/* RNORM Double precision scalar. (INPUT) */ |
| 50 |
/* Residual norm corresponding to the current upper Hessenberg */ |
| 51 |
/* matrix H. */ |
| 52 |
|
| 53 |
/* N Integer. (INPUT) */ |
| 54 |
/* Size of the matrix H. */ |
| 55 |
|
| 56 |
/* H Double precision N by N array. (INPUT) */ |
| 57 |
/* H contains the current upper Hessenberg matrix. */ |
| 58 |
|
| 59 |
/* LDH Integer. (INPUT) */ |
| 60 |
/* Leading dimension of H exactly as declared in the calling */ |
| 61 |
/* program. */ |
| 62 |
|
| 63 |
/* RITZR, Double precision arrays of length N. (OUTPUT) */ |
| 64 |
/* RITZI On output, RITZR(1:N) (resp. RITZI(1:N)) contains the real */ |
| 65 |
/* (respectively imaginary) parts of the eigenvalues of H. */ |
| 66 |
|
| 67 |
/* BOUNDS Double precision array of length N. (OUTPUT) */ |
| 68 |
/* On output, BOUNDS contains the Ritz estimates associated with */ |
| 69 |
/* the eigenvalues RITZR and RITZI. This is equal to RNORM */ |
| 70 |
/* times the last components of the eigenvectors corresponding */ |
| 71 |
/* to the eigenvalues in RITZR and RITZI. */ |
| 72 |
|
| 73 |
/* Q Double precision N by N array. (WORKSPACE) */ |
| 74 |
/* Workspace needed to store the eigenvectors of H. */ |
| 75 |
|
| 76 |
/* LDQ Integer. (INPUT) */ |
| 77 |
/* Leading dimension of Q exactly as declared in the calling */ |
| 78 |
/* program. */ |
| 79 |
|
| 80 |
/* WORKL Double precision work array of length N**2 + 3*N. (WORKSPACE) */ |
| 81 |
/* Private (replicated) array on each PE or array allocated on */ |
| 82 |
/* the front end. This is needed to keep the full Schur form */ |
| 83 |
/* of H and also in the calculation of the eigenvectors of H. */ |
| 84 |
|
| 85 |
/* IERR Integer. (OUTPUT) */ |
| 86 |
/* Error exit flag from dlaqrb or dtrevc. */ |
| 87 |
|
| 88 |
/* \EndDoc */ |
| 89 |
|
| 90 |
/* ----------------------------------------------------------------------- */ |
| 91 |
|
| 92 |
/* \BeginLib */ |
| 93 |
|
| 94 |
/* \Local variables: */ |
| 95 |
/* xxxxxx real */ |
| 96 |
|
| 97 |
/* \Routines called: */ |
| 98 |
/* dlaqrb ARPACK routine to compute the real Schur form of an */ |
| 99 |
/* upper Hessenberg matrix and last row of the Schur vectors. */ |
| 100 |
/* second ARPACK utility routine for timing. */ |
| 101 |
/* dmout ARPACK utility routine that prints matrices */ |
| 102 |
/* dvout ARPACK utility routine that prints vectors. */ |
| 103 |
/* dlacpy LAPACK matrix copy routine. */ |
| 104 |
/* dlapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */ |
| 105 |
/* dtrevc LAPACK routine to compute the eigenvectors of a matrix */ |
| 106 |
/* in upper quasi-triangular form */ |
| 107 |
/* dgemv Level 2 BLAS routine for matrix vector multiplication. */ |
| 108 |
/* dcopy Level 1 BLAS that copies one vector to another . */ |
| 109 |
/* dnrm2 Level 1 BLAS that computes the norm of a vector. */ |
| 110 |
/* dscal Level 1 BLAS that scales a vector. */ |
| 111 |
|
| 112 |
|
| 113 |
/* \Author */ |
| 114 |
/* Danny Sorensen Phuong Vu */ |
| 115 |
/* Richard Lehoucq CRPC / Rice University */ |
| 116 |
/* Dept. of Computational & Houston, Texas */ |
| 117 |
/* Applied Mathematics */ |
| 118 |
/* Rice University */ |
| 119 |
/* Houston, Texas */ |
| 120 |
|
| 121 |
/* \Revision history: */ |
| 122 |
/* xx/xx/92: Version ' 2.1' */ |
| 123 |
|
| 124 |
/* \SCCS Information: @(#) */ |
| 125 |
/* FILE: neigh.F SID: 2.3 DATE OF SID: 4/20/96 RELEASE: 2 */ |
| 126 |
|
| 127 |
/* \Remarks */ |
| 128 |
/* None */ |
| 129 |
|
| 130 |
/* \EndLib */ |
| 131 |
|
| 132 |
/* ----------------------------------------------------------------------- */ |
| 133 |
|
| 134 |
/* Subroutine */ int dneigh_(doublereal *rnorm, integer *n, doublereal *h__, |
| 135 |
integer *ldh, doublereal *ritzr, doublereal *ritzi, doublereal * |
| 136 |
bounds, doublereal *q, integer *ldq, doublereal *workl, integer *ierr) |
| 137 |
{ |
| 138 |
/* System generated locals */ |
| 139 |
integer h_dim1, h_offset, q_dim1, q_offset, i__1; |
| 140 |
doublereal d__1, d__2; |
| 141 |
|
| 142 |
/* Local variables */ |
| 143 |
static integer i__; |
| 144 |
static real t0, t1; |
| 145 |
static doublereal vl[1], temp; |
| 146 |
extern doublereal dnrm2_(integer *, doublereal *, integer *); |
| 147 |
extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, |
| 148 |
integer *); |
| 149 |
static integer iconj; |
| 150 |
extern /* Subroutine */ int dgemv_(char *, integer *, integer *, |
| 151 |
doublereal *, doublereal *, integer *, doublereal *, integer *, |
| 152 |
doublereal *, doublereal *, integer *, ftnlen), dmout_(integer *, |
| 153 |
integer *, integer *, doublereal *, integer *, integer *, char *, |
| 154 |
ftnlen), dvout_(integer *, integer *, doublereal *, integer *, |
| 155 |
char *, ftnlen); |
| 156 |
extern doublereal dlapy2_(doublereal *, doublereal *); |
| 157 |
extern /* Subroutine */ int dlaqrb_(logical *, integer *, integer *, |
| 158 |
integer *, doublereal *, integer *, doublereal *, doublereal *, |
| 159 |
doublereal *, integer *), second_(real *); |
| 160 |
static logical select[1]; |
| 161 |
static integer msglvl; |
| 162 |
extern /* Subroutine */ int dlacpy_(char *, integer *, integer *, |
| 163 |
doublereal *, integer *, doublereal *, integer *, ftnlen), |
| 164 |
dtrevc_(char *, char *, logical *, integer *, doublereal *, |
| 165 |
integer *, doublereal *, integer *, doublereal *, integer *, |
| 166 |
integer *, integer *, doublereal *, integer *, ftnlen, ftnlen); |
| 167 |
|
| 168 |
|
| 169 |
/* %----------------------------------------------------% */ |
| 170 |
/* | Include files for debugging and timing information | */ |
| 171 |
/* %----------------------------------------------------% */ |
| 172 |
|
| 173 |
|
| 174 |
/* \SCCS Information: @(#) */ |
| 175 |
/* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 176 |
|
| 177 |
/* %---------------------------------% */ |
| 178 |
/* | See debug.doc for documentation | */ |
| 179 |
/* %---------------------------------% */ |
| 180 |
|
| 181 |
/* %------------------% */ |
| 182 |
/* | Scalar Arguments | */ |
| 183 |
/* %------------------% */ |
| 184 |
|
| 185 |
/* %--------------------------------% */ |
| 186 |
/* | See stat.doc for documentation | */ |
| 187 |
/* %--------------------------------% */ |
| 188 |
|
| 189 |
/* \SCCS Information: @(#) */ |
| 190 |
/* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
/* %-----------------% */ |
| 195 |
/* | Array Arguments | */ |
| 196 |
/* %-----------------% */ |
| 197 |
|
| 198 |
|
| 199 |
/* %------------% */ |
| 200 |
/* | Parameters | */ |
| 201 |
/* %------------% */ |
| 202 |
|
| 203 |
|
| 204 |
/* %------------------------% */ |
| 205 |
/* | Local Scalars & Arrays | */ |
| 206 |
/* %------------------------% */ |
| 207 |
|
| 208 |
|
| 209 |
/* %----------------------% */ |
| 210 |
/* | External Subroutines | */ |
| 211 |
/* %----------------------% */ |
| 212 |
|
| 213 |
|
| 214 |
/* %--------------------% */ |
| 215 |
/* | External Functions | */ |
| 216 |
/* %--------------------% */ |
| 217 |
|
| 218 |
|
| 219 |
/* %---------------------% */ |
| 220 |
/* | Intrinsic Functions | */ |
| 221 |
/* %---------------------% */ |
| 222 |
|
| 223 |
|
| 224 |
/* %-----------------------% */ |
| 225 |
/* | Executable Statements | */ |
| 226 |
/* %-----------------------% */ |
| 227 |
|
| 228 |
|
| 229 |
/* %-------------------------------% */ |
| 230 |
/* | Initialize timing statistics | */ |
| 231 |
/* | & message level for debugging | */ |
| 232 |
/* %-------------------------------% */ |
| 233 |
|
| 234 |
/* Parameter adjustments */ |
| 235 |
--workl; |
| 236 |
--bounds; |
| 237 |
--ritzi; |
| 238 |
--ritzr; |
| 239 |
h_dim1 = *ldh; |
| 240 |
h_offset = 1 + h_dim1; |
| 241 |
h__ -= h_offset; |
| 242 |
q_dim1 = *ldq; |
| 243 |
q_offset = 1 + q_dim1; |
| 244 |
q -= q_offset; |
| 245 |
|
| 246 |
/* Function Body */ |
| 247 |
second_(&t0); |
| 248 |
msglvl = debug_1.mneigh; |
| 249 |
|
| 250 |
if (msglvl > 2) { |
| 251 |
dmout_(&debug_1.logfil, n, n, &h__[h_offset], ldh, &debug_1.ndigit, |
| 252 |
"_neigh: Entering upper Hessenberg matrix H ", (ftnlen)43); |
| 253 |
} |
| 254 |
|
| 255 |
/* %-----------------------------------------------------------% */ |
| 256 |
/* | 1. Compute the eigenvalues, the last components of the | */ |
| 257 |
/* | corresponding Schur vectors and the full Schur form T | */ |
| 258 |
/* | of the current upper Hessenberg matrix H. | */ |
| 259 |
/* | dlaqrb returns the full Schur form of H in WORKL(1:N**2) | */ |
| 260 |
/* | and the last components of the Schur vectors in BOUNDS. | */ |
| 261 |
/* %-----------------------------------------------------------% */ |
| 262 |
|
| 263 |
dlacpy_("All", n, n, &h__[h_offset], ldh, &workl[1], n, (ftnlen)3); |
| 264 |
dlaqrb_(&c_true, n, &c__1, n, &workl[1], n, &ritzr[1], &ritzi[1], &bounds[ |
| 265 |
1], ierr); |
| 266 |
if (*ierr != 0) { |
| 267 |
goto L9000; |
| 268 |
} |
| 269 |
|
| 270 |
if (msglvl > 1) { |
| 271 |
dvout_(&debug_1.logfil, n, &bounds[1], &debug_1.ndigit, "_neigh: las" |
| 272 |
"t row of the Schur matrix for H", (ftnlen)42); |
| 273 |
} |
| 274 |
|
| 275 |
/* %-----------------------------------------------------------% */ |
| 276 |
/* | 2. Compute the eigenvectors of the full Schur form T and | */ |
| 277 |
/* | apply the last components of the Schur vectors to get | */ |
| 278 |
/* | the last components of the corresponding eigenvectors. | */ |
| 279 |
/* | Remember that if the i-th and (i+1)-st eigenvalues are | */ |
| 280 |
/* | complex conjugate pairs, then the real & imaginary part | */ |
| 281 |
/* | of the eigenvector components are split across adjacent | */ |
| 282 |
/* | columns of Q. | */ |
| 283 |
/* %-----------------------------------------------------------% */ |
| 284 |
|
| 285 |
dtrevc_("R", "A", select, n, &workl[1], n, vl, n, &q[q_offset], ldq, n, n, |
| 286 |
&workl[*n * *n + 1], ierr, (ftnlen)1, (ftnlen)1); |
| 287 |
|
| 288 |
if (*ierr != 0) { |
| 289 |
goto L9000; |
| 290 |
} |
| 291 |
|
| 292 |
/* %------------------------------------------------% */ |
| 293 |
/* | Scale the returning eigenvectors so that their | */ |
| 294 |
/* | euclidean norms are all one. LAPACK subroutine | */ |
| 295 |
/* | dtrevc returns each eigenvector normalized so | */ |
| 296 |
/* | that the element of largest magnitude has | */ |
| 297 |
/* | magnitude 1; here the magnitude of a complex | */ |
| 298 |
/* | number (x,y) is taken to be |x| + |y|. | */ |
| 299 |
/* %------------------------------------------------% */ |
| 300 |
|
| 301 |
iconj = 0; |
| 302 |
i__1 = *n; |
| 303 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 304 |
if ((d__1 = ritzi[i__], abs(d__1)) <= 0.) { |
| 305 |
|
| 306 |
/* %----------------------% */ |
| 307 |
/* | Real eigenvalue case | */ |
| 308 |
/* %----------------------% */ |
| 309 |
|
| 310 |
temp = dnrm2_(n, &q[i__ * q_dim1 + 1], &c__1); |
| 311 |
d__1 = 1. / temp; |
| 312 |
dscal_(n, &d__1, &q[i__ * q_dim1 + 1], &c__1); |
| 313 |
} else { |
| 314 |
|
| 315 |
/* %-------------------------------------------% */ |
| 316 |
/* | Complex conjugate pair case. Note that | */ |
| 317 |
/* | since the real and imaginary part of | */ |
| 318 |
/* | the eigenvector are stored in consecutive | */ |
| 319 |
/* | columns, we further normalize by the | */ |
| 320 |
/* | square root of two. | */ |
| 321 |
/* %-------------------------------------------% */ |
| 322 |
|
| 323 |
if (iconj == 0) { |
| 324 |
d__1 = dnrm2_(n, &q[i__ * q_dim1 + 1], &c__1); |
| 325 |
d__2 = dnrm2_(n, &q[(i__ + 1) * q_dim1 + 1], &c__1); |
| 326 |
temp = dlapy2_(&d__1, &d__2); |
| 327 |
d__1 = 1. / temp; |
| 328 |
dscal_(n, &d__1, &q[i__ * q_dim1 + 1], &c__1); |
| 329 |
d__1 = 1. / temp; |
| 330 |
dscal_(n, &d__1, &q[(i__ + 1) * q_dim1 + 1], &c__1); |
| 331 |
iconj = 1; |
| 332 |
} else { |
| 333 |
iconj = 0; |
| 334 |
} |
| 335 |
} |
| 336 |
/* L10: */ |
| 337 |
} |
| 338 |
|
| 339 |
dgemv_("T", n, n, &c_b18, &q[q_offset], ldq, &bounds[1], &c__1, &c_b20, & |
| 340 |
workl[1], &c__1, (ftnlen)1); |
| 341 |
|
| 342 |
if (msglvl > 1) { |
| 343 |
dvout_(&debug_1.logfil, n, &workl[1], &debug_1.ndigit, "_neigh: Last" |
| 344 |
" row of the eigenvector matrix for H", (ftnlen)48); |
| 345 |
} |
| 346 |
|
| 347 |
/* %----------------------------% */ |
| 348 |
/* | Compute the Ritz estimates | */ |
| 349 |
/* %----------------------------% */ |
| 350 |
|
| 351 |
iconj = 0; |
| 352 |
i__1 = *n; |
| 353 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 354 |
if ((d__1 = ritzi[i__], abs(d__1)) <= 0.) { |
| 355 |
|
| 356 |
/* %----------------------% */ |
| 357 |
/* | Real eigenvalue case | */ |
| 358 |
/* %----------------------% */ |
| 359 |
|
| 360 |
bounds[i__] = *rnorm * (d__1 = workl[i__], abs(d__1)); |
| 361 |
} else { |
| 362 |
|
| 363 |
/* %-------------------------------------------% */ |
| 364 |
/* | Complex conjugate pair case. Note that | */ |
| 365 |
/* | since the real and imaginary part of | */ |
| 366 |
/* | the eigenvector are stored in consecutive | */ |
| 367 |
/* | columns, we need to take the magnitude | */ |
| 368 |
/* | of the last components of the two vectors | */ |
| 369 |
/* %-------------------------------------------% */ |
| 370 |
|
| 371 |
if (iconj == 0) { |
| 372 |
bounds[i__] = *rnorm * dlapy2_(&workl[i__], &workl[i__ + 1]); |
| 373 |
bounds[i__ + 1] = bounds[i__]; |
| 374 |
iconj = 1; |
| 375 |
} else { |
| 376 |
iconj = 0; |
| 377 |
} |
| 378 |
} |
| 379 |
/* L20: */ |
| 380 |
} |
| 381 |
|
| 382 |
if (msglvl > 2) { |
| 383 |
dvout_(&debug_1.logfil, n, &ritzr[1], &debug_1.ndigit, "_neigh: Real" |
| 384 |
" part of the eigenvalues of H", (ftnlen)41); |
| 385 |
dvout_(&debug_1.logfil, n, &ritzi[1], &debug_1.ndigit, "_neigh: Imag" |
| 386 |
"inary part of the eigenvalues of H", (ftnlen)46); |
| 387 |
dvout_(&debug_1.logfil, n, &bounds[1], &debug_1.ndigit, "_neigh: Rit" |
| 388 |
"z estimates for the eigenvalues of H", (ftnlen)47); |
| 389 |
} |
| 390 |
|
| 391 |
second_(&t1); |
| 392 |
timing_1.tneigh += t1 - t0; |
| 393 |
|
| 394 |
L9000: |
| 395 |
return 0; |
| 396 |
|
| 397 |
/* %---------------% */ |
| 398 |
/* | End of dneigh | */ |
| 399 |
/* %---------------% */ |
| 400 |
|
| 401 |
} /* dneigh_ */ |
| 402 |
|