00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dlasq3_(integer *i0, integer *n0, doublereal *z__,
00017 integer *pp, doublereal *dmin__, doublereal *sigma, doublereal *desig,
00018 doublereal *qmax, integer *nfail, integer *iter, integer *ndiv,
00019 logical *ieee, integer *ttype, doublereal *dmin1, doublereal *dmin2,
00020 doublereal *dn, doublereal *dn1, doublereal *dn2, doublereal *g,
00021 doublereal *tau)
00022 {
00023
00024 integer i__1;
00025 doublereal d__1, d__2;
00026
00027
00028 double sqrt(doublereal);
00029
00030
00031 doublereal s, t;
00032 integer j4, nn;
00033 doublereal eps, tol;
00034 integer n0in, ipn4;
00035 doublereal tol2, temp;
00036 extern int dlasq4_(integer *, integer *, doublereal *,
00037 integer *, integer *, doublereal *, doublereal *, doublereal *,
00038 doublereal *, doublereal *, doublereal *, doublereal *, integer *,
00039 doublereal *), dlasq5_(integer *, integer *, doublereal *,
00040 integer *, doublereal *, doublereal *, doublereal *, doublereal *,
00041 doublereal *, doublereal *, doublereal *, logical *), dlasq6_(
00042 integer *, integer *, doublereal *, integer *, doublereal *,
00043 doublereal *, doublereal *, doublereal *, doublereal *,
00044 doublereal *);
00045 extern doublereal dlamch_(char *);
00046 extern logical disnan_(doublereal *);
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 --z__;
00136
00137
00138 n0in = *n0;
00139 eps = dlamch_("Precision");
00140 tol = eps * 100.;
00141
00142 d__1 = tol;
00143 tol2 = d__1 * d__1;
00144
00145
00146
00147 L10:
00148
00149 if (*n0 < *i0) {
00150 return 0;
00151 }
00152 if (*n0 == *i0) {
00153 goto L20;
00154 }
00155 nn = (*n0 << 2) + *pp;
00156 if (*n0 == *i0 + 1) {
00157 goto L40;
00158 }
00159
00160
00161
00162 if (z__[nn - 5] > tol2 * (*sigma + z__[nn - 3]) && z__[nn - (*pp << 1) -
00163 4] > tol2 * z__[nn - 7]) {
00164 goto L30;
00165 }
00166
00167 L20:
00168
00169 z__[(*n0 << 2) - 3] = z__[(*n0 << 2) + *pp - 3] + *sigma;
00170 --(*n0);
00171 goto L10;
00172
00173
00174
00175 L30:
00176
00177 if (z__[nn - 9] > tol2 * *sigma && z__[nn - (*pp << 1) - 8] > tol2 * z__[
00178 nn - 11]) {
00179 goto L50;
00180 }
00181
00182 L40:
00183
00184 if (z__[nn - 3] > z__[nn - 7]) {
00185 s = z__[nn - 3];
00186 z__[nn - 3] = z__[nn - 7];
00187 z__[nn - 7] = s;
00188 }
00189 if (z__[nn - 5] > z__[nn - 3] * tol2) {
00190 t = (z__[nn - 7] - z__[nn - 3] + z__[nn - 5]) * .5;
00191 s = z__[nn - 3] * (z__[nn - 5] / t);
00192 if (s <= t) {
00193 s = z__[nn - 3] * (z__[nn - 5] / (t * (sqrt(s / t + 1.) + 1.)));
00194 } else {
00195 s = z__[nn - 3] * (z__[nn - 5] / (t + sqrt(t) * sqrt(t + s)));
00196 }
00197 t = z__[nn - 7] + (s + z__[nn - 5]);
00198 z__[nn - 3] *= z__[nn - 7] / t;
00199 z__[nn - 7] = t;
00200 }
00201 z__[(*n0 << 2) - 7] = z__[nn - 7] + *sigma;
00202 z__[(*n0 << 2) - 3] = z__[nn - 3] + *sigma;
00203 *n0 += -2;
00204 goto L10;
00205
00206 L50:
00207 if (*pp == 2) {
00208 *pp = 0;
00209 }
00210
00211
00212
00213 if (*dmin__ <= 0. || *n0 < n0in) {
00214 if (z__[(*i0 << 2) + *pp - 3] * 1.5 < z__[(*n0 << 2) + *pp - 3]) {
00215 ipn4 = *i0 + *n0 << 2;
00216 i__1 = *i0 + *n0 - 1 << 1;
00217 for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
00218 temp = z__[j4 - 3];
00219 z__[j4 - 3] = z__[ipn4 - j4 - 3];
00220 z__[ipn4 - j4 - 3] = temp;
00221 temp = z__[j4 - 2];
00222 z__[j4 - 2] = z__[ipn4 - j4 - 2];
00223 z__[ipn4 - j4 - 2] = temp;
00224 temp = z__[j4 - 1];
00225 z__[j4 - 1] = z__[ipn4 - j4 - 5];
00226 z__[ipn4 - j4 - 5] = temp;
00227 temp = z__[j4];
00228 z__[j4] = z__[ipn4 - j4 - 4];
00229 z__[ipn4 - j4 - 4] = temp;
00230
00231 }
00232 if (*n0 - *i0 <= 4) {
00233 z__[(*n0 << 2) + *pp - 1] = z__[(*i0 << 2) + *pp - 1];
00234 z__[(*n0 << 2) - *pp] = z__[(*i0 << 2) - *pp];
00235 }
00236
00237 d__1 = *dmin2, d__2 = z__[(*n0 << 2) + *pp - 1];
00238 *dmin2 = min(d__1,d__2);
00239
00240 d__1 = z__[(*n0 << 2) + *pp - 1], d__2 = z__[(*i0 << 2) + *pp - 1]
00241 , d__1 = min(d__1,d__2), d__2 = z__[(*i0 << 2) + *pp + 3];
00242 z__[(*n0 << 2) + *pp - 1] = min(d__1,d__2);
00243
00244 d__1 = z__[(*n0 << 2) - *pp], d__2 = z__[(*i0 << 2) - *pp], d__1 =
00245 min(d__1,d__2), d__2 = z__[(*i0 << 2) - *pp + 4];
00246 z__[(*n0 << 2) - *pp] = min(d__1,d__2);
00247
00248 d__1 = *qmax, d__2 = z__[(*i0 << 2) + *pp - 3], d__1 = max(d__1,
00249 d__2), d__2 = z__[(*i0 << 2) + *pp + 1];
00250 *qmax = max(d__1,d__2);
00251 *dmin__ = -0.;
00252 }
00253 }
00254
00255
00256
00257 dlasq4_(i0, n0, &z__[1], pp, &n0in, dmin__, dmin1, dmin2, dn, dn1, dn2,
00258 tau, ttype, g);
00259
00260
00261
00262 L70:
00263
00264 dlasq5_(i0, n0, &z__[1], pp, tau, dmin__, dmin1, dmin2, dn, dn1, dn2,
00265 ieee);
00266
00267 *ndiv += *n0 - *i0 + 2;
00268 ++(*iter);
00269
00270
00271
00272 if (*dmin__ >= 0. && *dmin1 > 0.) {
00273
00274
00275
00276 goto L90;
00277
00278 } else if (*dmin__ < 0. && *dmin1 > 0. && z__[(*n0 - 1 << 2) - *pp] < tol
00279 * (*sigma + *dn1) && abs(*dn) < tol * *sigma) {
00280
00281
00282
00283 z__[(*n0 - 1 << 2) - *pp + 2] = 0.;
00284 *dmin__ = 0.;
00285 goto L90;
00286 } else if (*dmin__ < 0.) {
00287
00288
00289
00290 ++(*nfail);
00291 if (*ttype < -22) {
00292
00293
00294
00295 *tau = 0.;
00296 } else if (*dmin1 > 0.) {
00297
00298
00299
00300 *tau = (*tau + *dmin__) * (1. - eps * 2.);
00301 *ttype += -11;
00302 } else {
00303
00304
00305
00306 *tau *= .25;
00307 *ttype += -12;
00308 }
00309 goto L70;
00310 } else if (disnan_(dmin__)) {
00311
00312
00313
00314 if (*tau == 0.) {
00315 goto L80;
00316 } else {
00317 *tau = 0.;
00318 goto L70;
00319 }
00320 } else {
00321
00322
00323
00324 goto L80;
00325 }
00326
00327
00328
00329 L80:
00330 dlasq6_(i0, n0, &z__[1], pp, dmin__, dmin1, dmin2, dn, dn1, dn2);
00331 *ndiv += *n0 - *i0 + 2;
00332 ++(*iter);
00333 *tau = 0.;
00334
00335 L90:
00336 if (*tau < *sigma) {
00337 *desig += *tau;
00338 t = *sigma + *desig;
00339 *desig -= t - *sigma;
00340 } else {
00341 t = *sigma + *tau;
00342 *desig = *sigma - (t - *tau) + *desig;
00343 }
00344 *sigma = t;
00345
00346 return 0;
00347
00348
00349
00350 }