| 1 |
/* ./src_f77/ssapps.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_SSAPPS; |
| 15 |
|
| 16 |
#define debug_1 debug_SSAPPS |
| 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_SSAPPS; |
| 25 |
|
| 26 |
#define timing_1 timing_SSAPPS |
| 27 |
|
| 28 |
/* Table of constant values */ |
| 29 |
|
| 30 |
static real c_b4 = 0.f; |
| 31 |
static real c_b5 = 1.f; |
| 32 |
static integer c__1 = 1; |
| 33 |
static real c_b20 = -1.f; |
| 34 |
|
| 35 |
/* ----------------------------------------------------------------------- */ |
| 36 |
/* \BeginDoc */ |
| 37 |
|
| 38 |
/* \Name: ssapps */ |
| 39 |
|
| 40 |
/* \Description: */ |
| 41 |
/* Given the Arnoldi factorization */ |
| 42 |
|
| 43 |
/* A*V_{k} - V_{k}*H_{k} = r_{k+p}*e_{k+p}^T, */ |
| 44 |
|
| 45 |
/* apply NP shifts implicitly resulting in */ |
| 46 |
|
| 47 |
/* A*(V_{k}*Q) - (V_{k}*Q)*(Q^T* H_{k}*Q) = r_{k+p}*e_{k+p}^T * Q */ |
| 48 |
|
| 49 |
/* where Q is an orthogonal matrix of order KEV+NP. Q is the product of */ |
| 50 |
/* rotations resulting from the NP bulge chasing sweeps. The updated Arnoldi */ |
| 51 |
/* factorization becomes: */ |
| 52 |
|
| 53 |
/* A*VNEW_{k} - VNEW_{k}*HNEW_{k} = rnew_{k}*e_{k}^T. */ |
| 54 |
|
| 55 |
/* \Usage: */ |
| 56 |
/* call ssapps */ |
| 57 |
/* ( N, KEV, NP, SHIFT, V, LDV, H, LDH, RESID, Q, LDQ, WORKD ) */ |
| 58 |
|
| 59 |
/* \Arguments */ |
| 60 |
/* N Integer. (INPUT) */ |
| 61 |
/* Problem size, i.e. dimension of matrix A. */ |
| 62 |
|
| 63 |
/* KEV Integer. (INPUT) */ |
| 64 |
/* INPUT: KEV+NP is the size of the input matrix H. */ |
| 65 |
/* OUTPUT: KEV is the size of the updated matrix HNEW. */ |
| 66 |
|
| 67 |
/* NP Integer. (INPUT) */ |
| 68 |
/* Number of implicit shifts to be applied. */ |
| 69 |
|
| 70 |
/* SHIFT Real array of length NP. (INPUT) */ |
| 71 |
/* The shifts to be applied. */ |
| 72 |
|
| 73 |
/* V Real N by (KEV+NP) array. (INPUT/OUTPUT) */ |
| 74 |
/* INPUT: V contains the current KEV+NP Arnoldi vectors. */ |
| 75 |
/* OUTPUT: VNEW = V(1:n,1:KEV); the updated Arnoldi vectors */ |
| 76 |
/* are in the first KEV columns of V. */ |
| 77 |
|
| 78 |
/* LDV Integer. (INPUT) */ |
| 79 |
/* Leading dimension of V exactly as declared in the calling */ |
| 80 |
/* program. */ |
| 81 |
|
| 82 |
/* H Real (KEV+NP) by 2 array. (INPUT/OUTPUT) */ |
| 83 |
/* INPUT: H contains the symmetric tridiagonal matrix of the */ |
| 84 |
/* Arnoldi factorization with the subdiagonal in the 1st column */ |
| 85 |
/* starting at H(2,1) and the main diagonal in the 2nd column. */ |
| 86 |
/* OUTPUT: H contains the updated tridiagonal matrix in the */ |
| 87 |
/* KEV leading submatrix. */ |
| 88 |
|
| 89 |
/* LDH Integer. (INPUT) */ |
| 90 |
/* Leading dimension of H exactly as declared in the calling */ |
| 91 |
/* program. */ |
| 92 |
|
| 93 |
/* RESID Real array of length (N). (INPUT/OUTPUT) */ |
| 94 |
/* INPUT: RESID contains the the residual vector r_{k+p}. */ |
| 95 |
/* OUTPUT: RESID is the updated residual vector rnew_{k}. */ |
| 96 |
|
| 97 |
/* Q Real KEV+NP by KEV+NP work array. (WORKSPACE) */ |
| 98 |
/* Work array used to accumulate the rotations during the bulge */ |
| 99 |
/* chase sweep. */ |
| 100 |
|
| 101 |
/* LDQ Integer. (INPUT) */ |
| 102 |
/* Leading dimension of Q exactly as declared in the calling */ |
| 103 |
/* program. */ |
| 104 |
|
| 105 |
/* WORKD Real work array of length 2*N. (WORKSPACE) */ |
| 106 |
/* Distributed array used in the application of the accumulated */ |
| 107 |
/* orthogonal matrix Q. */ |
| 108 |
|
| 109 |
/* \EndDoc */ |
| 110 |
|
| 111 |
/* ----------------------------------------------------------------------- */ |
| 112 |
|
| 113 |
/* \BeginLib */ |
| 114 |
|
| 115 |
/* \Local variables: */ |
| 116 |
/* xxxxxx real */ |
| 117 |
|
| 118 |
/* \References: */ |
| 119 |
/* 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in */ |
| 120 |
/* a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992), */ |
| 121 |
/* pp 357-385. */ |
| 122 |
/* 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly */ |
| 123 |
/* Restarted Arnoldi Iteration", Rice University Technical Report */ |
| 124 |
/* TR95-13, Department of Computational and Applied Mathematics. */ |
| 125 |
|
| 126 |
/* \Routines called: */ |
| 127 |
/* ivout ARPACK utility routine that prints integers. */ |
| 128 |
/* second ARPACK utility routine for timing. */ |
| 129 |
/* svout ARPACK utility routine that prints vectors. */ |
| 130 |
/* slamch LAPACK routine that determines machine constants. */ |
| 131 |
/* slartg LAPACK Givens rotation construction routine. */ |
| 132 |
/* slacpy LAPACK matrix copy routine. */ |
| 133 |
/* slaset LAPACK matrix initialization routine. */ |
| 134 |
/* sgemv Level 2 BLAS routine for matrix vector multiplication. */ |
| 135 |
/* saxpy Level 1 BLAS that computes a vector triad. */ |
| 136 |
/* scopy Level 1 BLAS that copies one vector to another. */ |
| 137 |
/* sscal Level 1 BLAS that scales a vector. */ |
| 138 |
|
| 139 |
/* \Author */ |
| 140 |
/* Danny Sorensen Phuong Vu */ |
| 141 |
/* Richard Lehoucq CRPC / Rice University */ |
| 142 |
/* Dept. of Computational & Houston, Texas */ |
| 143 |
/* Applied Mathematics */ |
| 144 |
/* Rice University */ |
| 145 |
/* Houston, Texas */ |
| 146 |
|
| 147 |
/* \Revision history: */ |
| 148 |
/* 12/16/93: Version ' 2.4' */ |
| 149 |
|
| 150 |
/* \SCCS Information: @(#) */ |
| 151 |
/* FILE: sapps.F SID: 2.6 DATE OF SID: 3/28/97 RELEASE: 2 */ |
| 152 |
|
| 153 |
/* \Remarks */ |
| 154 |
/* 1. In this version, each shift is applied to all the subblocks of */ |
| 155 |
/* the tridiagonal matrix H and not just to the submatrix that it */ |
| 156 |
/* comes from. This routine assumes that the subdiagonal elements */ |
| 157 |
/* of H that are stored in h(1:kev+np,1) are nonegative upon input */ |
| 158 |
/* and enforce this condition upon output. This version incorporates */ |
| 159 |
/* deflation. See code for documentation. */ |
| 160 |
|
| 161 |
/* \EndLib */ |
| 162 |
|
| 163 |
/* ----------------------------------------------------------------------- */ |
| 164 |
|
| 165 |
/* Subroutine */ int ssapps_(integer *n, integer *kev, integer *np, real * |
| 166 |
shift, real *v, integer *ldv, real *h__, integer *ldh, real *resid, |
| 167 |
real *q, integer *ldq, real *workd) |
| 168 |
{ |
| 169 |
/* Initialized data */ |
| 170 |
|
| 171 |
static logical first = TRUE_; |
| 172 |
|
| 173 |
/* System generated locals */ |
| 174 |
integer h_dim1, h_offset, q_dim1, q_offset, v_dim1, v_offset, i__1, i__2, |
| 175 |
i__3, i__4; |
| 176 |
real r__1, r__2; |
| 177 |
|
| 178 |
/* Local variables */ |
| 179 |
static real c__, f, g; |
| 180 |
static integer i__, j; |
| 181 |
static real r__, s, a1, a2, a3, a4, t0, t1; |
| 182 |
static integer jj; |
| 183 |
static real big; |
| 184 |
static integer iend, itop; |
| 185 |
extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), |
| 186 |
sgemv_(char *, integer *, integer *, real *, real *, integer *, |
| 187 |
real *, integer *, real *, real *, integer *, ftnlen), scopy_( |
| 188 |
integer *, real *, integer *, real *, integer *), saxpy_(integer * |
| 189 |
, real *, real *, integer *, real *, integer *), ivout_(integer *, |
| 190 |
integer *, integer *, integer *, char *, ftnlen), svout_(integer |
| 191 |
*, integer *, real *, integer *, char *, ftnlen); |
| 192 |
extern doublereal slamch_(char *, ftnlen); |
| 193 |
extern /* Subroutine */ int second_(real *); |
| 194 |
static real epsmch; |
| 195 |
static integer istart, kplusp, msglvl; |
| 196 |
extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, |
| 197 |
integer *, real *, integer *, ftnlen), slartg_(real *, real *, |
| 198 |
real *, real *, real *), slaset_(char *, integer *, integer *, |
| 199 |
real *, real *, real *, integer *, ftnlen); |
| 200 |
|
| 201 |
|
| 202 |
/* %----------------------------------------------------% */ |
| 203 |
/* | Include files for debugging and timing information | */ |
| 204 |
/* %----------------------------------------------------% */ |
| 205 |
|
| 206 |
|
| 207 |
/* \SCCS Information: @(#) */ |
| 208 |
/* FILE: debug.h SID: 2.3 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 209 |
|
| 210 |
/* %---------------------------------% */ |
| 211 |
/* | See debug.doc for documentation | */ |
| 212 |
/* %---------------------------------% */ |
| 213 |
|
| 214 |
/* %------------------% */ |
| 215 |
/* | Scalar Arguments | */ |
| 216 |
/* %------------------% */ |
| 217 |
|
| 218 |
/* %--------------------------------% */ |
| 219 |
/* | See stat.doc for documentation | */ |
| 220 |
/* %--------------------------------% */ |
| 221 |
|
| 222 |
/* \SCCS Information: @(#) */ |
| 223 |
/* FILE: stat.h SID: 2.2 DATE OF SID: 11/16/95 RELEASE: 2 */ |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
/* %-----------------% */ |
| 228 |
/* | Array Arguments | */ |
| 229 |
/* %-----------------% */ |
| 230 |
|
| 231 |
|
| 232 |
/* %------------% */ |
| 233 |
/* | Parameters | */ |
| 234 |
/* %------------% */ |
| 235 |
|
| 236 |
|
| 237 |
/* %---------------% */ |
| 238 |
/* | Local Scalars | */ |
| 239 |
/* %---------------% */ |
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
/* %----------------------% */ |
| 244 |
/* | External Subroutines | */ |
| 245 |
/* %----------------------% */ |
| 246 |
|
| 247 |
|
| 248 |
/* %--------------------% */ |
| 249 |
/* | External Functions | */ |
| 250 |
/* %--------------------% */ |
| 251 |
|
| 252 |
|
| 253 |
/* %----------------------% */ |
| 254 |
/* | Intrinsics Functions | */ |
| 255 |
/* %----------------------% */ |
| 256 |
|
| 257 |
|
| 258 |
/* %----------------% */ |
| 259 |
/* | Data statments | */ |
| 260 |
/* %----------------% */ |
| 261 |
|
| 262 |
/* Parameter adjustments */ |
| 263 |
--workd; |
| 264 |
--resid; |
| 265 |
--shift; |
| 266 |
v_dim1 = *ldv; |
| 267 |
v_offset = 1 + v_dim1; |
| 268 |
v -= v_offset; |
| 269 |
h_dim1 = *ldh; |
| 270 |
h_offset = 1 + h_dim1; |
| 271 |
h__ -= h_offset; |
| 272 |
q_dim1 = *ldq; |
| 273 |
q_offset = 1 + q_dim1; |
| 274 |
q -= q_offset; |
| 275 |
|
| 276 |
/* Function Body */ |
| 277 |
|
| 278 |
/* %-----------------------% */ |
| 279 |
/* | Executable Statements | */ |
| 280 |
/* %-----------------------% */ |
| 281 |
|
| 282 |
if (first) { |
| 283 |
epsmch = slamch_("Epsilon-Machine", (ftnlen)15); |
| 284 |
first = FALSE_; |
| 285 |
} |
| 286 |
itop = 1; |
| 287 |
|
| 288 |
/* %-------------------------------% */ |
| 289 |
/* | Initialize timing statistics | */ |
| 290 |
/* | & message level for debugging | */ |
| 291 |
/* %-------------------------------% */ |
| 292 |
|
| 293 |
second_(&t0); |
| 294 |
msglvl = debug_1.msapps; |
| 295 |
|
| 296 |
kplusp = *kev + *np; |
| 297 |
|
| 298 |
/* %----------------------------------------------% */ |
| 299 |
/* | Initialize Q to the identity matrix of order | */ |
| 300 |
/* | kplusp used to accumulate the rotations. | */ |
| 301 |
/* %----------------------------------------------% */ |
| 302 |
|
| 303 |
slaset_("All", &kplusp, &kplusp, &c_b4, &c_b5, &q[q_offset], ldq, (ftnlen) |
| 304 |
3); |
| 305 |
|
| 306 |
/* %----------------------------------------------% */ |
| 307 |
/* | Quick return if there are no shifts to apply | */ |
| 308 |
/* %----------------------------------------------% */ |
| 309 |
|
| 310 |
if (*np == 0) { |
| 311 |
goto L9000; |
| 312 |
} |
| 313 |
|
| 314 |
/* %----------------------------------------------------------% */ |
| 315 |
/* | Apply the np shifts implicitly. Apply each shift to the | */ |
| 316 |
/* | whole matrix and not just to the submatrix from which it | */ |
| 317 |
/* | comes. | */ |
| 318 |
/* %----------------------------------------------------------% */ |
| 319 |
|
| 320 |
i__1 = *np; |
| 321 |
for (jj = 1; jj <= i__1; ++jj) { |
| 322 |
|
| 323 |
istart = itop; |
| 324 |
|
| 325 |
/* %----------------------------------------------------------% */ |
| 326 |
/* | Check for splitting and deflation. Currently we consider | */ |
| 327 |
/* | an off-diagonal element h(i+1,1) negligible if | */ |
| 328 |
/* | h(i+1,1) .le. epsmch*( |h(i,2)| + |h(i+1,2)| ) | */ |
| 329 |
/* | for i=1:KEV+NP-1. | */ |
| 330 |
/* | If above condition tests true then we set h(i+1,1) = 0. | */ |
| 331 |
/* | Note that h(1:KEV+NP,1) are assumed to be non negative. | */ |
| 332 |
/* %----------------------------------------------------------% */ |
| 333 |
|
| 334 |
L20: |
| 335 |
|
| 336 |
/* %------------------------------------------------% */ |
| 337 |
/* | The following loop exits early if we encounter | */ |
| 338 |
/* | a negligible off diagonal element. | */ |
| 339 |
/* %------------------------------------------------% */ |
| 340 |
|
| 341 |
i__2 = kplusp - 1; |
| 342 |
for (i__ = istart; i__ <= i__2; ++i__) { |
| 343 |
big = (r__1 = h__[i__ + (h_dim1 << 1)], dabs(r__1)) + (r__2 = h__[ |
| 344 |
i__ + 1 + (h_dim1 << 1)], dabs(r__2)); |
| 345 |
if (h__[i__ + 1 + h_dim1] <= epsmch * big) { |
| 346 |
if (msglvl > 0) { |
| 347 |
ivout_(&debug_1.logfil, &c__1, &i__, &debug_1.ndigit, |
| 348 |
"_sapps: deflation at row/column no.", (ftnlen)35) |
| 349 |
; |
| 350 |
ivout_(&debug_1.logfil, &c__1, &jj, &debug_1.ndigit, |
| 351 |
"_sapps: occured before shift number.", (ftnlen) |
| 352 |
36); |
| 353 |
svout_(&debug_1.logfil, &c__1, &h__[i__ + 1 + h_dim1], & |
| 354 |
debug_1.ndigit, "_sapps: the corresponding off d" |
| 355 |
"iagonal element", (ftnlen)46); |
| 356 |
} |
| 357 |
h__[i__ + 1 + h_dim1] = 0.f; |
| 358 |
iend = i__; |
| 359 |
goto L40; |
| 360 |
} |
| 361 |
/* L30: */ |
| 362 |
} |
| 363 |
iend = kplusp; |
| 364 |
L40: |
| 365 |
|
| 366 |
if (istart < iend) { |
| 367 |
|
| 368 |
/* %--------------------------------------------------------% */ |
| 369 |
/* | Construct the plane rotation G'(istart,istart+1,theta) | */ |
| 370 |
/* | that attempts to drive h(istart+1,1) to zero. | */ |
| 371 |
/* %--------------------------------------------------------% */ |
| 372 |
|
| 373 |
f = h__[istart + (h_dim1 << 1)] - shift[jj]; |
| 374 |
g = h__[istart + 1 + h_dim1]; |
| 375 |
slartg_(&f, &g, &c__, &s, &r__); |
| 376 |
|
| 377 |
/* %-------------------------------------------------------% */ |
| 378 |
/* | Apply rotation to the left and right of H; | */ |
| 379 |
/* | H <- G' * H * G, where G = G(istart,istart+1,theta). | */ |
| 380 |
/* | This will create a "bulge". | */ |
| 381 |
/* %-------------------------------------------------------% */ |
| 382 |
|
| 383 |
a1 = c__ * h__[istart + (h_dim1 << 1)] + s * h__[istart + 1 + |
| 384 |
h_dim1]; |
| 385 |
a2 = c__ * h__[istart + 1 + h_dim1] + s * h__[istart + 1 + ( |
| 386 |
h_dim1 << 1)]; |
| 387 |
a4 = c__ * h__[istart + 1 + (h_dim1 << 1)] - s * h__[istart + 1 + |
| 388 |
h_dim1]; |
| 389 |
a3 = c__ * h__[istart + 1 + h_dim1] - s * h__[istart + (h_dim1 << |
| 390 |
1)]; |
| 391 |
h__[istart + (h_dim1 << 1)] = c__ * a1 + s * a2; |
| 392 |
h__[istart + 1 + (h_dim1 << 1)] = c__ * a4 - s * a3; |
| 393 |
h__[istart + 1 + h_dim1] = c__ * a3 + s * a4; |
| 394 |
|
| 395 |
/* %----------------------------------------------------% */ |
| 396 |
/* | Accumulate the rotation in the matrix Q; Q <- Q*G | */ |
| 397 |
/* %----------------------------------------------------% */ |
| 398 |
|
| 399 |
/* Computing MIN */ |
| 400 |
i__3 = istart + jj; |
| 401 |
i__2 = min(i__3,kplusp); |
| 402 |
for (j = 1; j <= i__2; ++j) { |
| 403 |
a1 = c__ * q[j + istart * q_dim1] + s * q[j + (istart + 1) * |
| 404 |
q_dim1]; |
| 405 |
q[j + (istart + 1) * q_dim1] = -s * q[j + istart * q_dim1] + |
| 406 |
c__ * q[j + (istart + 1) * q_dim1]; |
| 407 |
q[j + istart * q_dim1] = a1; |
| 408 |
/* L60: */ |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
/* %----------------------------------------------% */ |
| 413 |
/* | The following loop chases the bulge created. | */ |
| 414 |
/* | Note that the previous rotation may also be | */ |
| 415 |
/* | done within the following loop. But it is | */ |
| 416 |
/* | kept separate to make the distinction among | */ |
| 417 |
/* | the bulge chasing sweeps and the first plane | */ |
| 418 |
/* | rotation designed to drive h(istart+1,1) to | */ |
| 419 |
/* | zero. | */ |
| 420 |
/* %----------------------------------------------% */ |
| 421 |
|
| 422 |
i__2 = iend - 1; |
| 423 |
for (i__ = istart + 1; i__ <= i__2; ++i__) { |
| 424 |
|
| 425 |
/* %----------------------------------------------% */ |
| 426 |
/* | Construct the plane rotation G'(i,i+1,theta) | */ |
| 427 |
/* | that zeros the i-th bulge that was created | */ |
| 428 |
/* | by G(i-1,i,theta). g represents the bulge. | */ |
| 429 |
/* %----------------------------------------------% */ |
| 430 |
|
| 431 |
f = h__[i__ + h_dim1]; |
| 432 |
g = s * h__[i__ + 1 + h_dim1]; |
| 433 |
|
| 434 |
/* %----------------------------------% */ |
| 435 |
/* | Final update with G(i-1,i,theta) | */ |
| 436 |
/* %----------------------------------% */ |
| 437 |
|
| 438 |
h__[i__ + 1 + h_dim1] = c__ * h__[i__ + 1 + h_dim1]; |
| 439 |
slartg_(&f, &g, &c__, &s, &r__); |
| 440 |
|
| 441 |
/* %-------------------------------------------% */ |
| 442 |
/* | The following ensures that h(1:iend-1,1), | */ |
| 443 |
/* | the first iend-2 off diagonal of elements | */ |
| 444 |
/* | H, remain non negative. | */ |
| 445 |
/* %-------------------------------------------% */ |
| 446 |
|
| 447 |
if (r__ < 0.f) { |
| 448 |
r__ = -r__; |
| 449 |
c__ = -c__; |
| 450 |
s = -s; |
| 451 |
} |
| 452 |
|
| 453 |
/* %--------------------------------------------% */ |
| 454 |
/* | Apply rotation to the left and right of H; | */ |
| 455 |
/* | H <- G * H * G', where G = G(i,i+1,theta) | */ |
| 456 |
/* %--------------------------------------------% */ |
| 457 |
|
| 458 |
h__[i__ + h_dim1] = r__; |
| 459 |
|
| 460 |
a1 = c__ * h__[i__ + (h_dim1 << 1)] + s * h__[i__ + 1 + |
| 461 |
h_dim1]; |
| 462 |
a2 = c__ * h__[i__ + 1 + h_dim1] + s * h__[i__ + 1 + (h_dim1 |
| 463 |
<< 1)]; |
| 464 |
a3 = c__ * h__[i__ + 1 + h_dim1] - s * h__[i__ + (h_dim1 << 1) |
| 465 |
]; |
| 466 |
a4 = c__ * h__[i__ + 1 + (h_dim1 << 1)] - s * h__[i__ + 1 + |
| 467 |
h_dim1]; |
| 468 |
|
| 469 |
h__[i__ + (h_dim1 << 1)] = c__ * a1 + s * a2; |
| 470 |
h__[i__ + 1 + (h_dim1 << 1)] = c__ * a4 - s * a3; |
| 471 |
h__[i__ + 1 + h_dim1] = c__ * a3 + s * a4; |
| 472 |
|
| 473 |
/* %----------------------------------------------------% */ |
| 474 |
/* | Accumulate the rotation in the matrix Q; Q <- Q*G | */ |
| 475 |
/* %----------------------------------------------------% */ |
| 476 |
|
| 477 |
/* Computing MIN */ |
| 478 |
i__4 = i__ + jj; |
| 479 |
i__3 = min(i__4,kplusp); |
| 480 |
for (j = 1; j <= i__3; ++j) { |
| 481 |
a1 = c__ * q[j + i__ * q_dim1] + s * q[j + (i__ + 1) * |
| 482 |
q_dim1]; |
| 483 |
q[j + (i__ + 1) * q_dim1] = -s * q[j + i__ * q_dim1] + |
| 484 |
c__ * q[j + (i__ + 1) * q_dim1]; |
| 485 |
q[j + i__ * q_dim1] = a1; |
| 486 |
/* L50: */ |
| 487 |
} |
| 488 |
|
| 489 |
/* L70: */ |
| 490 |
} |
| 491 |
|
| 492 |
} |
| 493 |
|
| 494 |
/* %--------------------------% */ |
| 495 |
/* | Update the block pointer | */ |
| 496 |
/* %--------------------------% */ |
| 497 |
|
| 498 |
istart = iend + 1; |
| 499 |
|
| 500 |
/* %------------------------------------------% */ |
| 501 |
/* | Make sure that h(iend,1) is non-negative | */ |
| 502 |
/* | If not then set h(iend,1) <-- -h(iend,1) | */ |
| 503 |
/* | and negate the last column of Q. | */ |
| 504 |
/* | We have effectively carried out a | */ |
| 505 |
/* | similarity on transformation H | */ |
| 506 |
/* %------------------------------------------% */ |
| 507 |
|
| 508 |
if (h__[iend + h_dim1] < 0.f) { |
| 509 |
h__[iend + h_dim1] = -h__[iend + h_dim1]; |
| 510 |
sscal_(&kplusp, &c_b20, &q[iend * q_dim1 + 1], &c__1); |
| 511 |
} |
| 512 |
|
| 513 |
/* %--------------------------------------------------------% */ |
| 514 |
/* | Apply the same shift to the next block if there is any | */ |
| 515 |
/* %--------------------------------------------------------% */ |
| 516 |
|
| 517 |
if (iend < kplusp) { |
| 518 |
goto L20; |
| 519 |
} |
| 520 |
|
| 521 |
/* %-----------------------------------------------------% */ |
| 522 |
/* | Check if we can increase the the start of the block | */ |
| 523 |
/* %-----------------------------------------------------% */ |
| 524 |
|
| 525 |
i__2 = kplusp - 1; |
| 526 |
for (i__ = itop; i__ <= i__2; ++i__) { |
| 527 |
if (h__[i__ + 1 + h_dim1] > 0.f) { |
| 528 |
goto L90; |
| 529 |
} |
| 530 |
++itop; |
| 531 |
/* L80: */ |
| 532 |
} |
| 533 |
|
| 534 |
/* %-----------------------------------% */ |
| 535 |
/* | Finished applying the jj-th shift | */ |
| 536 |
/* %-----------------------------------% */ |
| 537 |
|
| 538 |
L90: |
| 539 |
; |
| 540 |
} |
| 541 |
|
| 542 |
/* %------------------------------------------% */ |
| 543 |
/* | All shifts have been applied. Check for | */ |
| 544 |
/* | more possible deflation that might occur | */ |
| 545 |
/* | after the last shift is applied. | */ |
| 546 |
/* %------------------------------------------% */ |
| 547 |
|
| 548 |
i__1 = kplusp - 1; |
| 549 |
for (i__ = itop; i__ <= i__1; ++i__) { |
| 550 |
big = (r__1 = h__[i__ + (h_dim1 << 1)], dabs(r__1)) + (r__2 = h__[i__ |
| 551 |
+ 1 + (h_dim1 << 1)], dabs(r__2)); |
| 552 |
if (h__[i__ + 1 + h_dim1] <= epsmch * big) { |
| 553 |
if (msglvl > 0) { |
| 554 |
ivout_(&debug_1.logfil, &c__1, &i__, &debug_1.ndigit, "_sapp" |
| 555 |
"s: deflation at row/column no.", (ftnlen)35); |
| 556 |
svout_(&debug_1.logfil, &c__1, &h__[i__ + 1 + h_dim1], & |
| 557 |
debug_1.ndigit, "_sapps: the corresponding off diago" |
| 558 |
"nal element", (ftnlen)46); |
| 559 |
} |
| 560 |
h__[i__ + 1 + h_dim1] = 0.f; |
| 561 |
} |
| 562 |
/* L100: */ |
| 563 |
} |
| 564 |
|
| 565 |
/* %-------------------------------------------------% */ |
| 566 |
/* | Compute the (kev+1)-st column of (V*Q) and | */ |
| 567 |
/* | temporarily store the result in WORKD(N+1:2*N). | */ |
| 568 |
/* | This is not necessary if h(kev+1,1) = 0. | */ |
| 569 |
/* %-------------------------------------------------% */ |
| 570 |
|
| 571 |
if (h__[*kev + 1 + h_dim1] > 0.f) { |
| 572 |
sgemv_("N", n, &kplusp, &c_b5, &v[v_offset], ldv, &q[(*kev + 1) * |
| 573 |
q_dim1 + 1], &c__1, &c_b4, &workd[*n + 1], &c__1, (ftnlen)1); |
| 574 |
} |
| 575 |
|
| 576 |
/* %-------------------------------------------------------% */ |
| 577 |
/* | Compute column 1 to kev of (V*Q) in backward order | */ |
| 578 |
/* | taking advantage that Q is an upper triangular matrix | */ |
| 579 |
/* | with lower bandwidth np. | */ |
| 580 |
/* | Place results in v(:,kplusp-kev:kplusp) temporarily. | */ |
| 581 |
/* %-------------------------------------------------------% */ |
| 582 |
|
| 583 |
i__1 = *kev; |
| 584 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 585 |
i__2 = kplusp - i__ + 1; |
| 586 |
sgemv_("N", n, &i__2, &c_b5, &v[v_offset], ldv, &q[(*kev - i__ + 1) * |
| 587 |
q_dim1 + 1], &c__1, &c_b4, &workd[1], &c__1, (ftnlen)1); |
| 588 |
scopy_(n, &workd[1], &c__1, &v[(kplusp - i__ + 1) * v_dim1 + 1], & |
| 589 |
c__1); |
| 590 |
/* L130: */ |
| 591 |
} |
| 592 |
|
| 593 |
/* %-------------------------------------------------% */ |
| 594 |
/* | Move v(:,kplusp-kev+1:kplusp) into v(:,1:kev). | */ |
| 595 |
/* %-------------------------------------------------% */ |
| 596 |
|
| 597 |
slacpy_("All", n, kev, &v[(*np + 1) * v_dim1 + 1], ldv, &v[v_offset], ldv, |
| 598 |
(ftnlen)3); |
| 599 |
|
| 600 |
/* %--------------------------------------------% */ |
| 601 |
/* | Copy the (kev+1)-st column of (V*Q) in the | */ |
| 602 |
/* | appropriate place if h(kev+1,1) .ne. zero. | */ |
| 603 |
/* %--------------------------------------------% */ |
| 604 |
|
| 605 |
if (h__[*kev + 1 + h_dim1] > 0.f) { |
| 606 |
scopy_(n, &workd[*n + 1], &c__1, &v[(*kev + 1) * v_dim1 + 1], &c__1); |
| 607 |
} |
| 608 |
|
| 609 |
/* %-------------------------------------% */ |
| 610 |
/* | Update the residual vector: | */ |
| 611 |
/* | r <- sigmak*r + betak*v(:,kev+1) | */ |
| 612 |
/* | where | */ |
| 613 |
/* | sigmak = (e_{kev+p}'*Q)*e_{kev} | */ |
| 614 |
/* | betak = e_{kev+1}'*H*e_{kev} | */ |
| 615 |
/* %-------------------------------------% */ |
| 616 |
|
| 617 |
sscal_(n, &q[kplusp + *kev * q_dim1], &resid[1], &c__1); |
| 618 |
if (h__[*kev + 1 + h_dim1] > 0.f) { |
| 619 |
saxpy_(n, &h__[*kev + 1 + h_dim1], &v[(*kev + 1) * v_dim1 + 1], &c__1, |
| 620 |
&resid[1], &c__1); |
| 621 |
} |
| 622 |
|
| 623 |
if (msglvl > 1) { |
| 624 |
svout_(&debug_1.logfil, &c__1, &q[kplusp + *kev * q_dim1], & |
| 625 |
debug_1.ndigit, "_sapps: sigmak of the updated residual vect" |
| 626 |
"or", (ftnlen)45); |
| 627 |
svout_(&debug_1.logfil, &c__1, &h__[*kev + 1 + h_dim1], & |
| 628 |
debug_1.ndigit, "_sapps: betak of the updated residual vector" |
| 629 |
, (ftnlen)44); |
| 630 |
svout_(&debug_1.logfil, kev, &h__[(h_dim1 << 1) + 1], &debug_1.ndigit, |
| 631 |
"_sapps: updated main diagonal of H for next iteration", ( |
| 632 |
ftnlen)53); |
| 633 |
if (*kev > 1) { |
| 634 |
i__1 = *kev - 1; |
| 635 |
svout_(&debug_1.logfil, &i__1, &h__[h_dim1 + 2], &debug_1.ndigit, |
| 636 |
"_sapps: updated sub diagonal of H for next iteration", ( |
| 637 |
ftnlen)52); |
| 638 |
} |
| 639 |
} |
| 640 |
|
| 641 |
second_(&t1); |
| 642 |
timing_1.tsapps += t1 - t0; |
| 643 |
|
| 644 |
L9000: |
| 645 |
return 0; |
| 646 |
|
| 647 |
/* %---------------% */ |
| 648 |
/* | End of ssapps | */ |
| 649 |
/* %---------------% */ |
| 650 |
|
| 651 |
} /* ssapps_ */ |
| 652 |
|