1 /* slaneg.f -- translated by f2c (version 20061008).
2 You must link the resulting object file with libf2c:
3 on Microsoft Windows system, link with libf2c.lib;
4 on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5 or, if you install libf2c.a in a standard place, with -lf2c -lm
6 -- in that order, at the end of the command line, as in
8 Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
10 http://www.netlib.org/f2c/libf2c.zip
16 integer slaneg_(integer *n, real *d__, real *lld, real *sigma, real *pivmin,
19 /* System generated locals */
20 integer ret_val, i__1, i__2, i__3, i__4;
28 real bsav, gamma, dplus;
31 extern logical sisnan_(real *);
35 /* -- LAPACK auxiliary routine (version 3.2) -- */
36 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
39 /* .. Scalar Arguments .. */
41 /* .. Array Arguments .. */
47 /* SLANEG computes the Sturm count, the number of negative pivots */
48 /* encountered while factoring tridiagonal T - sigma I = L D L^T. */
49 /* This implementation works directly on the factors without forming */
50 /* the tridiagonal matrix T. The Sturm count is also the number of */
51 /* eigenvalues of T less than sigma. */
53 /* This routine is called from SLARRB. */
55 /* The current routine does not use the PIVMIN parameter but rather */
56 /* requires IEEE-754 propagation of Infinities and NaNs. This */
57 /* routine also has no input range restrictions but does require */
58 /* default exception handling such that x/0 produces Inf when x is */
59 /* non-zero, and Inf/Inf produces NaN. For more information, see: */
61 /* Marques, Riedy, and Voemel, "Benefits of IEEE-754 Features in */
62 /* Modern Symmetric Tridiagonal Eigensolvers," SIAM Journal on */
63 /* Scientific Computing, v28, n5, 2006. DOI 10.1137/050641624 */
64 /* (Tech report version in LAWN 172 with the same title.) */
69 /* N (input) INTEGER */
70 /* The order of the matrix. */
72 /* D (input) REAL array, dimension (N) */
73 /* The N diagonal elements of the diagonal matrix D. */
75 /* LLD (input) REAL array, dimension (N-1) */
76 /* The (N-1) elements L(i)*L(i)*D(i). */
78 /* SIGMA (input) REAL */
79 /* Shift amount in T - sigma I = L D L^T. */
81 /* PIVMIN (input) REAL */
82 /* The minimum pivot in the Sturm sequence. May be used */
83 /* when zero pivots are encountered on non-IEEE-754 */
86 /* R (input) INTEGER */
87 /* The twist index for the twisted factorization that is used */
88 /* for the negcount. */
93 /* Based on contributions by */
94 /* Osni Marques, LBNL/NERSC, USA */
95 /* Christof Voemel, University of California, Berkeley, USA */
96 /* Jason Riedy, University of California, Berkeley, USA */
98 /* ===================================================================== */
100 /* .. Parameters .. */
101 /* Some architectures propagate Infinities and NaNs very slowly, so */
102 /* the code computes counts in BLKLEN chunks. Then a NaN can */
103 /* propagate at most BLKLEN columns before being detected. This is */
104 /* not a general tuning parameter; it needs only to be just large */
105 /* enough that the overhead is tiny in common cases. */
107 /* .. Local Scalars .. */
109 /* .. Intrinsic Functions .. */
111 /* .. External Functions .. */
113 /* .. Executable Statements .. */
114 /* Parameter adjustments */
120 /* I) upper part: L D L^T - SIGMA I = L+ D+ L+^T */
123 for (bj = 1; bj <= i__1; bj += 128) {
127 i__3 = bj + 127, i__4 = *r__ - 1;
128 i__2 = min(i__3,i__4);
129 for (j = bj; j <= i__2; ++j) {
135 t = tmp * lld[j] - *sigma;
138 sawnan = sisnan_(&t);
139 /* Run a slower version of the above loop if a NaN is detected. */
140 /* A NaN should occur only with a zero pivot after an infinite */
141 /* pivot. In that case, substituting 1 for T/DPLUS is the */
147 i__3 = bj + 127, i__4 = *r__ - 1;
148 i__2 = min(i__3,i__4);
149 for (j = bj; j <= i__2; ++j) {
158 t = tmp * lld[j] - *sigma;
166 /* II) lower part: L D L^T - SIGMA I = U- D- U-^T */
167 p = d__[*n] - *sigma;
169 for (bj = *n - 1; bj >= i__1; bj += -128) {
174 i__2 = max(i__3,*r__);
175 for (j = bj; j >= i__2; --j) {
181 p = tmp * d__[j] - *sigma;
184 sawnan = sisnan_(&p);
185 /* As above, run a slower version that substitutes 1 for Inf/Inf. */
192 i__2 = max(i__3,*r__);
193 for (j = bj; j >= i__2; --j) {
202 p = tmp * d__[j] - *sigma;
210 /* III) Twist index */
211 /* T was shifted by SIGMA initially. */
212 gamma = t + *sigma + p;