3 /* Subroutine */ int slazq3_(integer *i0, integer *n0, real *z__, integer *pp,
4 real *dmin__, real *sigma, real *desig, real *qmax, integer *nfail,
5 integer *iter, integer *ndiv, logical *ieee, integer *ttype, real *
6 dmin1, real *dmin2, real *dn, real *dn1, real *dn2, real *tau)
8 /* System generated locals */
12 /* Builtin functions */
13 double sqrt(doublereal);
21 extern /* Subroutine */ int slasq5_(integer *, integer *, real *, integer
22 *, real *, real *, real *, real *, real *, real *, real *,
23 logical *), slasq6_(integer *, integer *, real *, integer *, real
24 *, real *, real *, real *, real *, real *), slazq4_(integer *,
25 integer *, real *, integer *, integer *, real *, real *, real *,
26 real *, real *, real *, real *, integer *, real *);
27 extern doublereal slamch_(char *);
31 /* -- LAPACK auxiliary routine (version 3.1) -- */
32 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
35 /* .. Scalar Arguments .. */
37 /* .. Array Arguments .. */
43 /* SLAZQ3 checks for deflation, computes a shift (TAU) and calls dqds. */
44 /* In case of failure it changes shifts, and tries again until output */
50 /* I0 (input) INTEGER */
53 /* N0 (input) INTEGER */
56 /* Z (input) REAL array, dimension ( 4*N ) */
57 /* Z holds the qd array. */
59 /* PP (input) INTEGER */
60 /* PP=0 for ping, PP=1 for pong. */
62 /* DMIN (output) REAL */
63 /* Minimum value of d. */
65 /* SIGMA (output) REAL */
66 /* Sum of shifts used in current segment. */
68 /* DESIG (input/output) REAL */
69 /* Lower order part of SIGMA */
71 /* QMAX (input) REAL */
72 /* Maximum value of q. */
74 /* NFAIL (output) INTEGER */
75 /* Number of times shift was too big. */
77 /* ITER (output) INTEGER */
78 /* Number of iterations. */
80 /* NDIV (output) INTEGER */
81 /* Number of divisions. */
83 /* IEEE (input) LOGICAL */
84 /* Flag for IEEE or non IEEE arithmetic (passed to SLASQ5). */
86 /* TTYPE (input/output) INTEGER */
87 /* Shift type. TTYPE is passed as an argument in order to save */
88 /* its value between calls to SLAZQ3 */
90 /* DMIN1 (input/output) REAL */
91 /* DMIN2 (input/output) REAL */
92 /* DN (input/output) REAL */
93 /* DN1 (input/output) REAL */
94 /* DN2 (input/output) REAL */
95 /* TAU (input/output) REAL */
96 /* These are passed as arguments in order to save their values */
97 /* between calls to SLAZQ3 */
99 /* This is a thread safe version of SLASQ3, which passes TTYPE, DMIN1, */
100 /* DMIN2, DN, DN1. DN2 and TAU through the argument list in place of */
101 /* declaring them in a SAVE statment. */
103 /* ===================================================================== */
105 /* .. Parameters .. */
107 /* .. Local Scalars .. */
109 /* .. External Subroutines .. */
111 /* .. External Function .. */
113 /* .. Intrinsic Functions .. */
115 /* .. Executable Statements .. */
117 /* Parameter adjustments */
122 eps = slamch_("Precision");
123 safmin = slamch_("Safe minimum");
125 /* Computing 2nd power */
130 /* Check for deflation. */
140 nn = (*n0 << 2) + *pp;
141 if (*n0 == *i0 + 1) {
145 /* Check whether E(N0-1) is negligible, 1 eigenvalue. */
147 if (z__[nn - 5] > tol2 * (*sigma + z__[nn - 3]) && z__[nn - (*pp << 1) -
148 4] > tol2 * z__[nn - 7]) {
154 z__[(*n0 << 2) - 3] = z__[(*n0 << 2) + *pp - 3] + *sigma;
158 /* Check whether E(N0-2) is negligible, 2 eigenvalues. */
162 if (z__[nn - 9] > tol2 * *sigma && z__[nn - (*pp << 1) - 8] > tol2 * z__[
169 if (z__[nn - 3] > z__[nn - 7]) {
171 z__[nn - 3] = z__[nn - 7];
174 if (z__[nn - 5] > z__[nn - 3] * tol2) {
175 t = (z__[nn - 7] - z__[nn - 3] + z__[nn - 5]) * .5f;
176 s = z__[nn - 3] * (z__[nn - 5] / t);
178 s = z__[nn - 3] * (z__[nn - 5] / (t * (sqrt(s / t + 1.f) + 1.f)));
180 s = z__[nn - 3] * (z__[nn - 5] / (t + sqrt(t) * sqrt(t + s)));
182 t = z__[nn - 7] + (s + z__[nn - 5]);
183 z__[nn - 3] *= z__[nn - 7] / t;
186 z__[(*n0 << 2) - 7] = z__[nn - 7] + *sigma;
187 z__[(*n0 << 2) - 3] = z__[nn - 3] + *sigma;
193 /* Reverse the qd-array, if warranted. */
195 if (*dmin__ <= 0.f || *n0 < n0in) {
196 if (z__[(*i0 << 2) + *pp - 3] * 1.5f < z__[(*n0 << 2) + *pp - 3]) {
197 ipn4 = *i0 + *n0 << 2;
198 i__1 = *i0 + *n0 - 1 << 1;
199 for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
201 z__[j4 - 3] = z__[ipn4 - j4 - 3];
202 z__[ipn4 - j4 - 3] = temp;
204 z__[j4 - 2] = z__[ipn4 - j4 - 2];
205 z__[ipn4 - j4 - 2] = temp;
207 z__[j4 - 1] = z__[ipn4 - j4 - 5];
208 z__[ipn4 - j4 - 5] = temp;
210 z__[j4] = z__[ipn4 - j4 - 4];
211 z__[ipn4 - j4 - 4] = temp;
214 if (*n0 - *i0 <= 4) {
215 z__[(*n0 << 2) + *pp - 1] = z__[(*i0 << 2) + *pp - 1];
216 z__[(*n0 << 2) - *pp] = z__[(*i0 << 2) - *pp];
219 r__1 = *dmin2, r__2 = z__[(*n0 << 2) + *pp - 1];
220 *dmin2 = dmin(r__1,r__2);
222 r__1 = z__[(*n0 << 2) + *pp - 1], r__2 = z__[(*i0 << 2) + *pp - 1]
223 , r__1 = min(r__1,r__2), r__2 = z__[(*i0 << 2) + *pp + 3];
224 z__[(*n0 << 2) + *pp - 1] = dmin(r__1,r__2);
226 r__1 = z__[(*n0 << 2) - *pp], r__2 = z__[(*i0 << 2) - *pp], r__1 =
227 min(r__1,r__2), r__2 = z__[(*i0 << 2) - *pp + 4];
228 z__[(*n0 << 2) - *pp] = dmin(r__1,r__2);
230 r__1 = *qmax, r__2 = z__[(*i0 << 2) + *pp - 3], r__1 = max(r__1,
231 r__2), r__2 = z__[(*i0 << 2) + *pp + 1];
232 *qmax = dmax(r__1,r__2);
238 r__1 = z__[(*n0 << 2) + *pp - 1], r__2 = z__[(*n0 << 2) + *pp - 9], r__1 =
239 min(r__1,r__2), r__2 = *dmin2 + z__[(*n0 << 2) - *pp];
240 if (*dmin__ < 0.f || safmin * *qmax < dmin(r__1,r__2)) {
242 /* Choose a shift. */
244 slazq4_(i0, n0, &z__[1], pp, &n0in, dmin__, dmin1, dmin2, dn, dn1,
245 dn2, tau, ttype, &g);
247 /* Call dqds until DMIN > 0. */
251 slasq5_(i0, n0, &z__[1], pp, tau, dmin__, dmin1, dmin2, dn, dn1, dn2,
254 *ndiv += *n0 - *i0 + 2;
259 if (*dmin__ >= 0.f && *dmin1 > 0.f) {
265 } else if (*dmin__ < 0.f && *dmin1 > 0.f && z__[(*n0 - 1 << 2) - *pp]
266 < tol * (*sigma + *dn1) && dabs(*dn) < tol * *sigma) {
268 /* Convergence hidden by negative DN. */
270 z__[(*n0 - 1 << 2) - *pp + 2] = 0.f;
273 } else if (*dmin__ < 0.f) {
275 /* TAU too big. Select new TAU and try again. */
280 /* Failed twice. Play it safe. */
283 } else if (*dmin1 > 0.f) {
285 /* Late failure. Gives excellent shift. */
287 *tau = (*tau + *dmin__) * (1.f - eps * 2.f);
291 /* Early failure. Divide by 4. */
297 } else if (*dmin__ != *dmin__) {
305 /* Possible underflow. Play it safe. */
311 /* Risk of underflow. */
314 slasq6_(i0, n0, &z__[1], pp, dmin__, dmin1, dmin2, dn, dn1, dn2);
315 *ndiv += *n0 - *i0 + 2;
323 *desig -= t - *sigma;
326 *desig = *sigma - (t - *tau) + *desig;