| 1 |
/* ./src_f77/sstqrb.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 |
/* Table of constant values */ |
| 9 |
|
| 10 |
static integer c__0 = 0; |
| 11 |
static integer c__1 = 1; |
| 12 |
static real c_b31 = 1.f; |
| 13 |
|
| 14 |
/* ----------------------------------------------------------------------- */ |
| 15 |
/* \BeginDoc */ |
| 16 |
|
| 17 |
/* \Name: sstqrb */ |
| 18 |
|
| 19 |
/* \Description: */ |
| 20 |
/* Computes all eigenvalues and the last component of the eigenvectors */ |
| 21 |
/* of a symmetric tridiagonal matrix using the implicit QL or QR method. */ |
| 22 |
|
| 23 |
/* This is mostly a modification of the LAPACK routine ssteqr. */ |
| 24 |
/* See Remarks. */ |
| 25 |
|
| 26 |
/* \Usage: */ |
| 27 |
/* call sstqrb */ |
| 28 |
/* ( N, D, E, Z, WORK, INFO ) */ |
| 29 |
|
| 30 |
/* \Arguments */ |
| 31 |
/* N Integer. (INPUT) */ |
| 32 |
/* The number of rows and columns in the matrix. N >= 0. */ |
| 33 |
|
| 34 |
/* D Real array, dimension (N). (INPUT/OUTPUT) */ |
| 35 |
/* On entry, D contains the diagonal elements of the */ |
| 36 |
/* tridiagonal matrix. */ |
| 37 |
/* On exit, D contains the eigenvalues, in ascending order. */ |
| 38 |
/* If an error exit is made, the eigenvalues are correct */ |
| 39 |
/* for indices 1,2,...,INFO-1, but they are unordered and */ |
| 40 |
/* may not be the smallest eigenvalues of the matrix. */ |
| 41 |
|
| 42 |
/* E Real array, dimension (N-1). (INPUT/OUTPUT) */ |
| 43 |
/* On entry, E contains the subdiagonal elements of the */ |
| 44 |
/* tridiagonal matrix in positions 1 through N-1. */ |
| 45 |
/* On exit, E has been destroyed. */ |
| 46 |
|
| 47 |
/* Z Real array, dimension (N). (OUTPUT) */ |
| 48 |
/* On exit, Z contains the last row of the orthonormal */ |
| 49 |
/* eigenvector matrix of the symmetric tridiagonal matrix. */ |
| 50 |
/* If an error exit is made, Z contains the last row of the */ |
| 51 |
/* eigenvector matrix associated with the stored eigenvalues. */ |
| 52 |
|
| 53 |
/* WORK Real array, dimension (max(1,2*N-2)). (WORKSPACE) */ |
| 54 |
/* Workspace used in accumulating the transformation for */ |
| 55 |
/* computing the last components of the eigenvectors. */ |
| 56 |
|
| 57 |
/* INFO Integer. (OUTPUT) */ |
| 58 |
/* = 0: normal return. */ |
| 59 |
/* < 0: if INFO = -i, the i-th argument had an illegal value. */ |
| 60 |
/* > 0: if INFO = +i, the i-th eigenvalue has not converged */ |
| 61 |
/* after a total of 30*N iterations. */ |
| 62 |
|
| 63 |
/* \Remarks */ |
| 64 |
/* 1. None. */ |
| 65 |
|
| 66 |
/* ----------------------------------------------------------------------- */ |
| 67 |
|
| 68 |
/* \BeginLib */ |
| 69 |
|
| 70 |
/* \Local variables: */ |
| 71 |
/* xxxxxx real */ |
| 72 |
|
| 73 |
/* \Routines called: */ |
| 74 |
/* saxpy Level 1 BLAS that computes a vector triad. */ |
| 75 |
/* scopy Level 1 BLAS that copies one vector to another. */ |
| 76 |
/* sswap Level 1 BLAS that swaps the contents of two vectors. */ |
| 77 |
/* lsame LAPACK character comparison routine. */ |
| 78 |
/* slae2 LAPACK routine that computes the eigenvalues of a 2-by-2 */ |
| 79 |
/* symmetric matrix. */ |
| 80 |
/* slaev2 LAPACK routine that eigendecomposition of a 2-by-2 symmetric */ |
| 81 |
/* matrix. */ |
| 82 |
/* slamch LAPACK routine that determines machine constants. */ |
| 83 |
/* slanst LAPACK routine that computes the norm of a matrix. */ |
| 84 |
/* slapy2 LAPACK routine to compute sqrt(x**2+y**2) carefully. */ |
| 85 |
/* slartg LAPACK Givens rotation construction routine. */ |
| 86 |
/* slascl LAPACK routine for careful scaling of a matrix. */ |
| 87 |
/* slaset LAPACK matrix initialization routine. */ |
| 88 |
/* slasr LAPACK routine that applies an orthogonal transformation to */ |
| 89 |
/* a matrix. */ |
| 90 |
/* slasrt LAPACK sorting routine. */ |
| 91 |
/* ssteqr LAPACK routine that computes eigenvalues and eigenvectors */ |
| 92 |
/* of a symmetric tridiagonal matrix. */ |
| 93 |
/* xerbla LAPACK error handler routine. */ |
| 94 |
|
| 95 |
/* \Authors */ |
| 96 |
/* Danny Sorensen Phuong Vu */ |
| 97 |
/* Richard Lehoucq CRPC / Rice University */ |
| 98 |
/* Dept. of Computational & Houston, Texas */ |
| 99 |
/* Applied Mathematics */ |
| 100 |
/* Rice University */ |
| 101 |
/* Houston, Texas */ |
| 102 |
|
| 103 |
/* \SCCS Information: @(#) */ |
| 104 |
/* FILE: stqrb.F SID: 2.5 DATE OF SID: 8/27/96 RELEASE: 2 */ |
| 105 |
|
| 106 |
/* \Remarks */ |
| 107 |
/* 1. Starting with version 2.5, this routine is a modified version */ |
| 108 |
/* of LAPACK version 2.0 subroutine SSTEQR. No lines are deleted, */ |
| 109 |
/* only commeted out and new lines inserted. */ |
| 110 |
/* All lines commented out have "c$$$" at the beginning. */ |
| 111 |
/* Note that the LAPACK version 1.0 subroutine SSTEQR contained */ |
| 112 |
/* bugs. */ |
| 113 |
|
| 114 |
/* \EndLib */ |
| 115 |
|
| 116 |
/* ----------------------------------------------------------------------- */ |
| 117 |
|
| 118 |
/* Subroutine */ int sstqrb_(integer *n, real *d__, real *e, real *z__, real * |
| 119 |
work, integer *info) |
| 120 |
{ |
| 121 |
/* System generated locals */ |
| 122 |
integer i__1, i__2; |
| 123 |
real r__1, r__2; |
| 124 |
|
| 125 |
/* Builtin functions */ |
| 126 |
double sqrt(doublereal), r_sign(real *, real *); |
| 127 |
|
| 128 |
/* Local variables */ |
| 129 |
static real b, c__, f, g; |
| 130 |
static integer i__, j, k, l, m; |
| 131 |
static real p, r__, s; |
| 132 |
static integer l1, ii, mm, lm1, mm1, nm1; |
| 133 |
static real rt1, rt2, eps; |
| 134 |
static integer lsv; |
| 135 |
static real tst, eps2; |
| 136 |
static integer lend, jtot; |
| 137 |
extern /* Subroutine */ int slae2_(real *, real *, real *, real *, real *) |
| 138 |
; |
| 139 |
static real anorm; |
| 140 |
extern /* Subroutine */ int slasr_(char *, char *, char *, integer *, |
| 141 |
integer *, real *, real *, real *, integer *, ftnlen, ftnlen, |
| 142 |
ftnlen); |
| 143 |
static integer lendm1, lendp1; |
| 144 |
extern /* Subroutine */ int slaev2_(real *, real *, real *, real *, real * |
| 145 |
, real *, real *); |
| 146 |
extern doublereal slapy2_(real *, real *); |
| 147 |
static integer iscale; |
| 148 |
extern doublereal slamch_(char *, ftnlen); |
| 149 |
static real safmin, safmax; |
| 150 |
extern /* Subroutine */ int slascl_(char *, integer *, integer *, real *, |
| 151 |
real *, integer *, integer *, real *, integer *, integer *, |
| 152 |
ftnlen); |
| 153 |
static integer lendsv; |
| 154 |
extern /* Subroutine */ int slartg_(real *, real *, real *, real *, real * |
| 155 |
); |
| 156 |
static real ssfmin; |
| 157 |
static integer nmaxit, icompz; |
| 158 |
static real ssfmax; |
| 159 |
extern doublereal slanst_(char *, integer *, real *, real *, ftnlen); |
| 160 |
extern /* Subroutine */ int slasrt_(char *, integer *, real *, integer *, |
| 161 |
ftnlen); |
| 162 |
|
| 163 |
|
| 164 |
/* %------------------% */ |
| 165 |
/* | Scalar Arguments | */ |
| 166 |
/* %------------------% */ |
| 167 |
|
| 168 |
|
| 169 |
/* %-----------------% */ |
| 170 |
/* | Array Arguments | */ |
| 171 |
/* %-----------------% */ |
| 172 |
|
| 173 |
|
| 174 |
/* .. parameters .. */ |
| 175 |
/* .. */ |
| 176 |
/* .. local scalars .. */ |
| 177 |
/* .. */ |
| 178 |
/* .. external functions .. */ |
| 179 |
/* .. */ |
| 180 |
/* .. external subroutines .. */ |
| 181 |
/* .. */ |
| 182 |
/* .. intrinsic functions .. */ |
| 183 |
/* .. */ |
| 184 |
/* .. executable statements .. */ |
| 185 |
|
| 186 |
/* test the input parameters. */ |
| 187 |
|
| 188 |
/* Parameter adjustments */ |
| 189 |
--work; |
| 190 |
--z__; |
| 191 |
--e; |
| 192 |
--d__; |
| 193 |
|
| 194 |
/* Function Body */ |
| 195 |
*info = 0; |
| 196 |
|
| 197 |
/* $$$ IF( LSAME( COMPZ, 'N' ) ) THEN */ |
| 198 |
/* $$$ ICOMPZ = 0 */ |
| 199 |
/* $$$ ELSE IF( LSAME( COMPZ, 'V' ) ) THEN */ |
| 200 |
/* $$$ ICOMPZ = 1 */ |
| 201 |
/* $$$ ELSE IF( LSAME( COMPZ, 'I' ) ) THEN */ |
| 202 |
/* $$$ ICOMPZ = 2 */ |
| 203 |
/* $$$ ELSE */ |
| 204 |
/* $$$ ICOMPZ = -1 */ |
| 205 |
/* $$$ END IF */ |
| 206 |
/* $$$ IF( ICOMPZ.LT.0 ) THEN */ |
| 207 |
/* $$$ INFO = -1 */ |
| 208 |
/* $$$ ELSE IF( N.LT.0 ) THEN */ |
| 209 |
/* $$$ INFO = -2 */ |
| 210 |
/* $$$ ELSE IF( ( LDZ.LT.1 ) .OR. ( ICOMPZ.GT.0 .AND. LDZ.LT.MAX( 1, */ |
| 211 |
/* $$$ $ N ) ) ) THEN */ |
| 212 |
/* $$$ INFO = -6 */ |
| 213 |
/* $$$ END IF */ |
| 214 |
/* $$$ IF( INFO.NE.0 ) THEN */ |
| 215 |
/* $$$ CALL XERBLA( 'SSTEQR', -INFO ) */ |
| 216 |
/* $$$ RETURN */ |
| 217 |
/* $$$ END IF */ |
| 218 |
|
| 219 |
/* *** New starting with version 2.5 *** */ |
| 220 |
|
| 221 |
icompz = 2; |
| 222 |
/* ************************************* */ |
| 223 |
|
| 224 |
/* quick return if possible */ |
| 225 |
|
| 226 |
if (*n == 0) { |
| 227 |
return 0; |
| 228 |
} |
| 229 |
|
| 230 |
if (*n == 1) { |
| 231 |
if (icompz == 2) { |
| 232 |
z__[1] = 1.f; |
| 233 |
} |
| 234 |
return 0; |
| 235 |
} |
| 236 |
|
| 237 |
/* determine the unit roundoff and over/underflow thresholds. */ |
| 238 |
|
| 239 |
eps = slamch_("e", (ftnlen)1); |
| 240 |
/* Computing 2nd power */ |
| 241 |
r__1 = eps; |
| 242 |
eps2 = r__1 * r__1; |
| 243 |
safmin = slamch_("s", (ftnlen)1); |
| 244 |
safmax = 1.f / safmin; |
| 245 |
ssfmax = sqrt(safmax) / 3.f; |
| 246 |
ssfmin = sqrt(safmin) / eps2; |
| 247 |
|
| 248 |
/* compute the eigenvalues and eigenvectors of the tridiagonal */ |
| 249 |
/* matrix. */ |
| 250 |
|
| 251 |
/* $$ if( icompz.eq.2 ) */ |
| 252 |
/* $$$ $ call slaset( 'full', n, n, zero, one, z, ldz ) */ |
| 253 |
|
| 254 |
/* *** New starting with version 2.5 *** */ |
| 255 |
|
| 256 |
if (icompz == 2) { |
| 257 |
i__1 = *n - 1; |
| 258 |
for (j = 1; j <= i__1; ++j) { |
| 259 |
z__[j] = 0.f; |
| 260 |
/* L5: */ |
| 261 |
} |
| 262 |
z__[*n] = 1.f; |
| 263 |
} |
| 264 |
/* ************************************* */ |
| 265 |
|
| 266 |
nmaxit = *n * 30; |
| 267 |
jtot = 0; |
| 268 |
|
| 269 |
/* determine where the matrix splits and choose ql or qr iteration */ |
| 270 |
/* for each block, according to whether top or bottom diagonal */ |
| 271 |
/* element is smaller. */ |
| 272 |
|
| 273 |
l1 = 1; |
| 274 |
nm1 = *n - 1; |
| 275 |
|
| 276 |
L10: |
| 277 |
if (l1 > *n) { |
| 278 |
goto L160; |
| 279 |
} |
| 280 |
if (l1 > 1) { |
| 281 |
e[l1 - 1] = 0.f; |
| 282 |
} |
| 283 |
if (l1 <= nm1) { |
| 284 |
i__1 = nm1; |
| 285 |
for (m = l1; m <= i__1; ++m) { |
| 286 |
tst = (r__1 = e[m], dabs(r__1)); |
| 287 |
if (tst == 0.f) { |
| 288 |
goto L30; |
| 289 |
} |
| 290 |
if (tst <= sqrt((r__1 = d__[m], dabs(r__1))) * sqrt((r__2 = d__[m |
| 291 |
+ 1], dabs(r__2))) * eps) { |
| 292 |
e[m] = 0.f; |
| 293 |
goto L30; |
| 294 |
} |
| 295 |
/* L20: */ |
| 296 |
} |
| 297 |
} |
| 298 |
m = *n; |
| 299 |
|
| 300 |
L30: |
| 301 |
l = l1; |
| 302 |
lsv = l; |
| 303 |
lend = m; |
| 304 |
lendsv = lend; |
| 305 |
l1 = m + 1; |
| 306 |
if (lend == l) { |
| 307 |
goto L10; |
| 308 |
} |
| 309 |
|
| 310 |
/* scale submatrix in rows and columns l to lend */ |
| 311 |
|
| 312 |
i__1 = lend - l + 1; |
| 313 |
anorm = slanst_("i", &i__1, &d__[l], &e[l], (ftnlen)1); |
| 314 |
iscale = 0; |
| 315 |
if (anorm == 0.f) { |
| 316 |
goto L10; |
| 317 |
} |
| 318 |
if (anorm > ssfmax) { |
| 319 |
iscale = 1; |
| 320 |
i__1 = lend - l + 1; |
| 321 |
slascl_("g", &c__0, &c__0, &anorm, &ssfmax, &i__1, &c__1, &d__[l], n, |
| 322 |
info, (ftnlen)1); |
| 323 |
i__1 = lend - l; |
| 324 |
slascl_("g", &c__0, &c__0, &anorm, &ssfmax, &i__1, &c__1, &e[l], n, |
| 325 |
info, (ftnlen)1); |
| 326 |
} else if (anorm < ssfmin) { |
| 327 |
iscale = 2; |
| 328 |
i__1 = lend - l + 1; |
| 329 |
slascl_("g", &c__0, &c__0, &anorm, &ssfmin, &i__1, &c__1, &d__[l], n, |
| 330 |
info, (ftnlen)1); |
| 331 |
i__1 = lend - l; |
| 332 |
slascl_("g", &c__0, &c__0, &anorm, &ssfmin, &i__1, &c__1, &e[l], n, |
| 333 |
info, (ftnlen)1); |
| 334 |
} |
| 335 |
|
| 336 |
/* choose between ql and qr iteration */ |
| 337 |
|
| 338 |
if ((r__1 = d__[lend], dabs(r__1)) < (r__2 = d__[l], dabs(r__2))) { |
| 339 |
lend = lsv; |
| 340 |
l = lendsv; |
| 341 |
} |
| 342 |
|
| 343 |
if (lend > l) { |
| 344 |
|
| 345 |
/* ql iteration */ |
| 346 |
|
| 347 |
/* look for small subdiagonal element. */ |
| 348 |
|
| 349 |
L40: |
| 350 |
if (l != lend) { |
| 351 |
lendm1 = lend - 1; |
| 352 |
i__1 = lendm1; |
| 353 |
for (m = l; m <= i__1; ++m) { |
| 354 |
/* Computing 2nd power */ |
| 355 |
r__2 = (r__1 = e[m], dabs(r__1)); |
| 356 |
tst = r__2 * r__2; |
| 357 |
if (tst <= eps2 * (r__1 = d__[m], dabs(r__1)) * (r__2 = d__[m |
| 358 |
+ 1], dabs(r__2)) + safmin) { |
| 359 |
goto L60; |
| 360 |
} |
| 361 |
/* L50: */ |
| 362 |
} |
| 363 |
} |
| 364 |
|
| 365 |
m = lend; |
| 366 |
|
| 367 |
L60: |
| 368 |
if (m < lend) { |
| 369 |
e[m] = 0.f; |
| 370 |
} |
| 371 |
p = d__[l]; |
| 372 |
if (m == l) { |
| 373 |
goto L80; |
| 374 |
} |
| 375 |
|
| 376 |
/* if remaining matrix is 2-by-2, use slae2 or slaev2 */ |
| 377 |
/* to compute its eigensystem. */ |
| 378 |
|
| 379 |
if (m == l + 1) { |
| 380 |
if (icompz > 0) { |
| 381 |
slaev2_(&d__[l], &e[l], &d__[l + 1], &rt1, &rt2, &c__, &s); |
| 382 |
work[l] = c__; |
| 383 |
work[*n - 1 + l] = s; |
| 384 |
/* $$$ call slasr( 'r', 'v', 'b', n, 2, work( l ), */ |
| 385 |
/* $$$ $ work( n-1+l ), z( 1, l ), ldz ) */ |
| 386 |
|
| 387 |
/* *** New starting with version 2.5 *** */ |
| 388 |
|
| 389 |
tst = z__[l + 1]; |
| 390 |
z__[l + 1] = c__ * tst - s * z__[l]; |
| 391 |
z__[l] = s * tst + c__ * z__[l]; |
| 392 |
/* ************************************* */ |
| 393 |
} else { |
| 394 |
slae2_(&d__[l], &e[l], &d__[l + 1], &rt1, &rt2); |
| 395 |
} |
| 396 |
d__[l] = rt1; |
| 397 |
d__[l + 1] = rt2; |
| 398 |
e[l] = 0.f; |
| 399 |
l += 2; |
| 400 |
if (l <= lend) { |
| 401 |
goto L40; |
| 402 |
} |
| 403 |
goto L140; |
| 404 |
} |
| 405 |
|
| 406 |
if (jtot == nmaxit) { |
| 407 |
goto L140; |
| 408 |
} |
| 409 |
++jtot; |
| 410 |
|
| 411 |
/* form shift. */ |
| 412 |
|
| 413 |
g = (d__[l + 1] - p) / (e[l] * 2.f); |
| 414 |
r__ = slapy2_(&g, &c_b31); |
| 415 |
g = d__[m] - p + e[l] / (g + r_sign(&r__, &g)); |
| 416 |
|
| 417 |
s = 1.f; |
| 418 |
c__ = 1.f; |
| 419 |
p = 0.f; |
| 420 |
|
| 421 |
/* inner loop */ |
| 422 |
|
| 423 |
mm1 = m - 1; |
| 424 |
i__1 = l; |
| 425 |
for (i__ = mm1; i__ >= i__1; --i__) { |
| 426 |
f = s * e[i__]; |
| 427 |
b = c__ * e[i__]; |
| 428 |
slartg_(&g, &f, &c__, &s, &r__); |
| 429 |
if (i__ != m - 1) { |
| 430 |
e[i__ + 1] = r__; |
| 431 |
} |
| 432 |
g = d__[i__ + 1] - p; |
| 433 |
r__ = (d__[i__] - g) * s + c__ * 2.f * b; |
| 434 |
p = s * r__; |
| 435 |
d__[i__ + 1] = g + p; |
| 436 |
g = c__ * r__ - b; |
| 437 |
|
| 438 |
/* if eigenvectors are desired, then save rotations. */ |
| 439 |
|
| 440 |
if (icompz > 0) { |
| 441 |
work[i__] = c__; |
| 442 |
work[*n - 1 + i__] = -s; |
| 443 |
} |
| 444 |
|
| 445 |
/* L70: */ |
| 446 |
} |
| 447 |
|
| 448 |
/* if eigenvectors are desired, then apply saved rotations. */ |
| 449 |
|
| 450 |
if (icompz > 0) { |
| 451 |
mm = m - l + 1; |
| 452 |
/* $$$ call slasr( 'r', 'v', 'b', n, mm, work( l ), work( n-1+l ), */ |
| 453 |
/* $$$ $ z( 1, l ), ldz ) */ |
| 454 |
|
| 455 |
/* *** New starting with version 2.5 *** */ |
| 456 |
|
| 457 |
slasr_("r", "v", "b", &c__1, &mm, &work[l], &work[*n - 1 + l], & |
| 458 |
z__[l], &c__1, (ftnlen)1, (ftnlen)1, (ftnlen)1); |
| 459 |
/* ************************************* */ |
| 460 |
} |
| 461 |
|
| 462 |
d__[l] -= p; |
| 463 |
e[l] = g; |
| 464 |
goto L40; |
| 465 |
|
| 466 |
/* eigenvalue found. */ |
| 467 |
|
| 468 |
L80: |
| 469 |
d__[l] = p; |
| 470 |
|
| 471 |
++l; |
| 472 |
if (l <= lend) { |
| 473 |
goto L40; |
| 474 |
} |
| 475 |
goto L140; |
| 476 |
|
| 477 |
} else { |
| 478 |
|
| 479 |
/* qr iteration */ |
| 480 |
|
| 481 |
/* look for small superdiagonal element. */ |
| 482 |
|
| 483 |
L90: |
| 484 |
if (l != lend) { |
| 485 |
lendp1 = lend + 1; |
| 486 |
i__1 = lendp1; |
| 487 |
for (m = l; m >= i__1; --m) { |
| 488 |
/* Computing 2nd power */ |
| 489 |
r__2 = (r__1 = e[m - 1], dabs(r__1)); |
| 490 |
tst = r__2 * r__2; |
| 491 |
if (tst <= eps2 * (r__1 = d__[m], dabs(r__1)) * (r__2 = d__[m |
| 492 |
- 1], dabs(r__2)) + safmin) { |
| 493 |
goto L110; |
| 494 |
} |
| 495 |
/* L100: */ |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
m = lend; |
| 500 |
|
| 501 |
L110: |
| 502 |
if (m > lend) { |
| 503 |
e[m - 1] = 0.f; |
| 504 |
} |
| 505 |
p = d__[l]; |
| 506 |
if (m == l) { |
| 507 |
goto L130; |
| 508 |
} |
| 509 |
|
| 510 |
/* if remaining matrix is 2-by-2, use slae2 or slaev2 */ |
| 511 |
/* to compute its eigensystem. */ |
| 512 |
|
| 513 |
if (m == l - 1) { |
| 514 |
if (icompz > 0) { |
| 515 |
slaev2_(&d__[l - 1], &e[l - 1], &d__[l], &rt1, &rt2, &c__, &s) |
| 516 |
; |
| 517 |
/* $$$ work( m ) = c */ |
| 518 |
/* $$$ work( n-1+m ) = s */ |
| 519 |
/* $$$ call slasr( 'r', 'v', 'f', n, 2, work( m ), */ |
| 520 |
/* $$$ $ work( n-1+m ), z( 1, l-1 ), ldz ) */ |
| 521 |
|
| 522 |
/* *** New starting with version 2.5 *** */ |
| 523 |
|
| 524 |
tst = z__[l]; |
| 525 |
z__[l] = c__ * tst - s * z__[l - 1]; |
| 526 |
z__[l - 1] = s * tst + c__ * z__[l - 1]; |
| 527 |
/* ************************************* */ |
| 528 |
} else { |
| 529 |
slae2_(&d__[l - 1], &e[l - 1], &d__[l], &rt1, &rt2); |
| 530 |
} |
| 531 |
d__[l - 1] = rt1; |
| 532 |
d__[l] = rt2; |
| 533 |
e[l - 1] = 0.f; |
| 534 |
l += -2; |
| 535 |
if (l >= lend) { |
| 536 |
goto L90; |
| 537 |
} |
| 538 |
goto L140; |
| 539 |
} |
| 540 |
|
| 541 |
if (jtot == nmaxit) { |
| 542 |
goto L140; |
| 543 |
} |
| 544 |
++jtot; |
| 545 |
|
| 546 |
/* form shift. */ |
| 547 |
|
| 548 |
g = (d__[l - 1] - p) / (e[l - 1] * 2.f); |
| 549 |
r__ = slapy2_(&g, &c_b31); |
| 550 |
g = d__[m] - p + e[l - 1] / (g + r_sign(&r__, &g)); |
| 551 |
|
| 552 |
s = 1.f; |
| 553 |
c__ = 1.f; |
| 554 |
p = 0.f; |
| 555 |
|
| 556 |
/* inner loop */ |
| 557 |
|
| 558 |
lm1 = l - 1; |
| 559 |
i__1 = lm1; |
| 560 |
for (i__ = m; i__ <= i__1; ++i__) { |
| 561 |
f = s * e[i__]; |
| 562 |
b = c__ * e[i__]; |
| 563 |
slartg_(&g, &f, &c__, &s, &r__); |
| 564 |
if (i__ != m) { |
| 565 |
e[i__ - 1] = r__; |
| 566 |
} |
| 567 |
g = d__[i__] - p; |
| 568 |
r__ = (d__[i__ + 1] - g) * s + c__ * 2.f * b; |
| 569 |
p = s * r__; |
| 570 |
d__[i__] = g + p; |
| 571 |
g = c__ * r__ - b; |
| 572 |
|
| 573 |
/* if eigenvectors are desired, then save rotations. */ |
| 574 |
|
| 575 |
if (icompz > 0) { |
| 576 |
work[i__] = c__; |
| 577 |
work[*n - 1 + i__] = s; |
| 578 |
} |
| 579 |
|
| 580 |
/* L120: */ |
| 581 |
} |
| 582 |
|
| 583 |
/* if eigenvectors are desired, then apply saved rotations. */ |
| 584 |
|
| 585 |
if (icompz > 0) { |
| 586 |
mm = l - m + 1; |
| 587 |
/* $$$ call slasr( 'r', 'v', 'f', n, mm, work( m ), work( n-1+m ), */ |
| 588 |
/* $$$ $ z( 1, m ), ldz ) */ |
| 589 |
|
| 590 |
/* *** New starting with version 2.5 *** */ |
| 591 |
|
| 592 |
slasr_("r", "v", "f", &c__1, &mm, &work[m], &work[*n - 1 + m], & |
| 593 |
z__[m], &c__1, (ftnlen)1, (ftnlen)1, (ftnlen)1); |
| 594 |
/* ************************************* */ |
| 595 |
} |
| 596 |
|
| 597 |
d__[l] -= p; |
| 598 |
e[lm1] = g; |
| 599 |
goto L90; |
| 600 |
|
| 601 |
/* eigenvalue found. */ |
| 602 |
|
| 603 |
L130: |
| 604 |
d__[l] = p; |
| 605 |
|
| 606 |
--l; |
| 607 |
if (l >= lend) { |
| 608 |
goto L90; |
| 609 |
} |
| 610 |
goto L140; |
| 611 |
|
| 612 |
} |
| 613 |
|
| 614 |
/* undo scaling if necessary */ |
| 615 |
|
| 616 |
L140: |
| 617 |
if (iscale == 1) { |
| 618 |
i__1 = lendsv - lsv + 1; |
| 619 |
slascl_("g", &c__0, &c__0, &ssfmax, &anorm, &i__1, &c__1, &d__[lsv], |
| 620 |
n, info, (ftnlen)1); |
| 621 |
i__1 = lendsv - lsv; |
| 622 |
slascl_("g", &c__0, &c__0, &ssfmax, &anorm, &i__1, &c__1, &e[lsv], n, |
| 623 |
info, (ftnlen)1); |
| 624 |
} else if (iscale == 2) { |
| 625 |
i__1 = lendsv - lsv + 1; |
| 626 |
slascl_("g", &c__0, &c__0, &ssfmin, &anorm, &i__1, &c__1, &d__[lsv], |
| 627 |
n, info, (ftnlen)1); |
| 628 |
i__1 = lendsv - lsv; |
| 629 |
slascl_("g", &c__0, &c__0, &ssfmin, &anorm, &i__1, &c__1, &e[lsv], n, |
| 630 |
info, (ftnlen)1); |
| 631 |
} |
| 632 |
|
| 633 |
/* check for no convergence to an eigenvalue after a total */ |
| 634 |
/* of n*maxit iterations. */ |
| 635 |
|
| 636 |
if (jtot < nmaxit) { |
| 637 |
goto L10; |
| 638 |
} |
| 639 |
i__1 = *n - 1; |
| 640 |
for (i__ = 1; i__ <= i__1; ++i__) { |
| 641 |
if (e[i__] != 0.f) { |
| 642 |
++(*info); |
| 643 |
} |
| 644 |
/* L150: */ |
| 645 |
} |
| 646 |
goto L190; |
| 647 |
|
| 648 |
/* order eigenvalues and eigenvectors. */ |
| 649 |
|
| 650 |
L160: |
| 651 |
if (icompz == 0) { |
| 652 |
|
| 653 |
/* use quick sort */ |
| 654 |
|
| 655 |
slasrt_("i", n, &d__[1], info, (ftnlen)1); |
| 656 |
|
| 657 |
} else { |
| 658 |
|
| 659 |
/* use selection sort to minimize swaps of eigenvectors */ |
| 660 |
|
| 661 |
i__1 = *n; |
| 662 |
for (ii = 2; ii <= i__1; ++ii) { |
| 663 |
i__ = ii - 1; |
| 664 |
k = i__; |
| 665 |
p = d__[i__]; |
| 666 |
i__2 = *n; |
| 667 |
for (j = ii; j <= i__2; ++j) { |
| 668 |
if (d__[j] < p) { |
| 669 |
k = j; |
| 670 |
p = d__[j]; |
| 671 |
} |
| 672 |
/* L170: */ |
| 673 |
} |
| 674 |
if (k != i__) { |
| 675 |
d__[k] = d__[i__]; |
| 676 |
d__[i__] = p; |
| 677 |
/* $$$ call sswap( n, z( 1, i ), 1, z( 1, k ), 1 ) */ |
| 678 |
/* *** New starting with version 2.5 *** */ |
| 679 |
|
| 680 |
p = z__[k]; |
| 681 |
z__[k] = z__[i__]; |
| 682 |
z__[i__] = p; |
| 683 |
/* ************************************* */ |
| 684 |
} |
| 685 |
/* L180: */ |
| 686 |
} |
| 687 |
} |
| 688 |
|
| 689 |
L190: |
| 690 |
return 0; |
| 691 |
|
| 692 |
/* %---------------% */ |
| 693 |
/* | End of sstqrb | */ |
| 694 |
/* %---------------% */ |
| 695 |
|
| 696 |
} /* sstqrb_ */ |
| 697 |
|