00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int slasq3_(integer *i0, integer *n0, real *z__, integer *pp,
00017 real *dmin__, real *sigma, real *desig, real *qmax, integer *nfail,
00018 integer *iter, integer *ndiv, logical *ieee, integer *ttype, real *
00019 dmin1, real *dmin2, real *dn, real *dn1, real *dn2, real *g, real *
00020 tau)
00021 {
00022
00023 integer i__1;
00024 real r__1, r__2;
00025
00026
00027 double sqrt(doublereal);
00028
00029
00030 real s, t;
00031 integer j4, nn;
00032 real eps, tol;
00033 integer n0in, ipn4;
00034 real tol2, temp;
00035 extern int slasq4_(integer *, integer *, real *, integer
00036 *, integer *, real *, real *, real *, real *, real *, real *,
00037 real *, integer *, real *), slasq5_(integer *, integer *, real *,
00038 integer *, real *, real *, real *, real *, real *, real *, real *,
00039 logical *), slasq6_(integer *, integer *, real *, integer *,
00040 real *, real *, real *, real *, real *, real *);
00041 extern doublereal slamch_(char *);
00042 extern logical sisnan_(real *);
00043
00044
00045
00046
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 --z__;
00132
00133
00134 n0in = *n0;
00135 eps = slamch_("Precision");
00136 tol = eps * 100.f;
00137
00138 r__1 = tol;
00139 tol2 = r__1 * r__1;
00140
00141
00142
00143 L10:
00144
00145 if (*n0 < *i0) {
00146 return 0;
00147 }
00148 if (*n0 == *i0) {
00149 goto L20;
00150 }
00151 nn = (*n0 << 2) + *pp;
00152 if (*n0 == *i0 + 1) {
00153 goto L40;
00154 }
00155
00156
00157
00158 if (z__[nn - 5] > tol2 * (*sigma + z__[nn - 3]) && z__[nn - (*pp << 1) -
00159 4] > tol2 * z__[nn - 7]) {
00160 goto L30;
00161 }
00162
00163 L20:
00164
00165 z__[(*n0 << 2) - 3] = z__[(*n0 << 2) + *pp - 3] + *sigma;
00166 --(*n0);
00167 goto L10;
00168
00169
00170
00171 L30:
00172
00173 if (z__[nn - 9] > tol2 * *sigma && z__[nn - (*pp << 1) - 8] > tol2 * z__[
00174 nn - 11]) {
00175 goto L50;
00176 }
00177
00178 L40:
00179
00180 if (z__[nn - 3] > z__[nn - 7]) {
00181 s = z__[nn - 3];
00182 z__[nn - 3] = z__[nn - 7];
00183 z__[nn - 7] = s;
00184 }
00185 if (z__[nn - 5] > z__[nn - 3] * tol2) {
00186 t = (z__[nn - 7] - z__[nn - 3] + z__[nn - 5]) * .5f;
00187 s = z__[nn - 3] * (z__[nn - 5] / t);
00188 if (s <= t) {
00189 s = z__[nn - 3] * (z__[nn - 5] / (t * (sqrt(s / t + 1.f) + 1.f)));
00190 } else {
00191 s = z__[nn - 3] * (z__[nn - 5] / (t + sqrt(t) * sqrt(t + s)));
00192 }
00193 t = z__[nn - 7] + (s + z__[nn - 5]);
00194 z__[nn - 3] *= z__[nn - 7] / t;
00195 z__[nn - 7] = t;
00196 }
00197 z__[(*n0 << 2) - 7] = z__[nn - 7] + *sigma;
00198 z__[(*n0 << 2) - 3] = z__[nn - 3] + *sigma;
00199 *n0 += -2;
00200 goto L10;
00201
00202 L50:
00203 if (*pp == 2) {
00204 *pp = 0;
00205 }
00206
00207
00208
00209 if (*dmin__ <= 0.f || *n0 < n0in) {
00210 if (z__[(*i0 << 2) + *pp - 3] * 1.5f < z__[(*n0 << 2) + *pp - 3]) {
00211 ipn4 = *i0 + *n0 << 2;
00212 i__1 = *i0 + *n0 - 1 << 1;
00213 for (j4 = *i0 << 2; j4 <= i__1; j4 += 4) {
00214 temp = z__[j4 - 3];
00215 z__[j4 - 3] = z__[ipn4 - j4 - 3];
00216 z__[ipn4 - j4 - 3] = temp;
00217 temp = z__[j4 - 2];
00218 z__[j4 - 2] = z__[ipn4 - j4 - 2];
00219 z__[ipn4 - j4 - 2] = temp;
00220 temp = z__[j4 - 1];
00221 z__[j4 - 1] = z__[ipn4 - j4 - 5];
00222 z__[ipn4 - j4 - 5] = temp;
00223 temp = z__[j4];
00224 z__[j4] = z__[ipn4 - j4 - 4];
00225 z__[ipn4 - j4 - 4] = temp;
00226
00227 }
00228 if (*n0 - *i0 <= 4) {
00229 z__[(*n0 << 2) + *pp - 1] = z__[(*i0 << 2) + *pp - 1];
00230 z__[(*n0 << 2) - *pp] = z__[(*i0 << 2) - *pp];
00231 }
00232
00233 r__1 = *dmin2, r__2 = z__[(*n0 << 2) + *pp - 1];
00234 *dmin2 = dmin(r__1,r__2);
00235
00236 r__1 = z__[(*n0 << 2) + *pp - 1], r__2 = z__[(*i0 << 2) + *pp - 1]
00237 , r__1 = min(r__1,r__2), r__2 = z__[(*i0 << 2) + *pp + 3];
00238 z__[(*n0 << 2) + *pp - 1] = dmin(r__1,r__2);
00239
00240 r__1 = z__[(*n0 << 2) - *pp], r__2 = z__[(*i0 << 2) - *pp], r__1 =
00241 min(r__1,r__2), r__2 = z__[(*i0 << 2) - *pp + 4];
00242 z__[(*n0 << 2) - *pp] = dmin(r__1,r__2);
00243
00244 r__1 = *qmax, r__2 = z__[(*i0 << 2) + *pp - 3], r__1 = max(r__1,
00245 r__2), r__2 = z__[(*i0 << 2) + *pp + 1];
00246 *qmax = dmax(r__1,r__2);
00247 *dmin__ = -0.f;
00248 }
00249 }
00250
00251
00252
00253 slasq4_(i0, n0, &z__[1], pp, &n0in, dmin__, dmin1, dmin2, dn, dn1, dn2,
00254 tau, ttype, g);
00255
00256
00257
00258 L70:
00259
00260 slasq5_(i0, n0, &z__[1], pp, tau, dmin__, dmin1, dmin2, dn, dn1, dn2,
00261 ieee);
00262
00263 *ndiv += *n0 - *i0 + 2;
00264 ++(*iter);
00265
00266
00267
00268 if (*dmin__ >= 0.f && *dmin1 > 0.f) {
00269
00270
00271
00272 goto L90;
00273
00274 } else if (*dmin__ < 0.f && *dmin1 > 0.f && z__[(*n0 - 1 << 2) - *pp] <
00275 tol * (*sigma + *dn1) && dabs(*dn) < tol * *sigma) {
00276
00277
00278
00279 z__[(*n0 - 1 << 2) - *pp + 2] = 0.f;
00280 *dmin__ = 0.f;
00281 goto L90;
00282 } else if (*dmin__ < 0.f) {
00283
00284
00285
00286 ++(*nfail);
00287 if (*ttype < -22) {
00288
00289
00290
00291 *tau = 0.f;
00292 } else if (*dmin1 > 0.f) {
00293
00294
00295
00296 *tau = (*tau + *dmin__) * (1.f - eps * 2.f);
00297 *ttype += -11;
00298 } else {
00299
00300
00301
00302 *tau *= .25f;
00303 *ttype += -12;
00304 }
00305 goto L70;
00306 } else if (sisnan_(dmin__)) {
00307
00308
00309
00310 if (*tau == 0.f) {
00311 goto L80;
00312 } else {
00313 *tau = 0.f;
00314 goto L70;
00315 }
00316 } else {
00317
00318
00319
00320 goto L80;
00321 }
00322
00323
00324
00325 L80:
00326 slasq6_(i0, n0, &z__[1], pp, dmin__, dmin1, dmin2, dn, dn1, dn2);
00327 *ndiv += *n0 - *i0 + 2;
00328 ++(*iter);
00329 *tau = 0.f;
00330
00331 L90:
00332 if (*tau < *sigma) {
00333 *desig += *tau;
00334 t = *sigma + *desig;
00335 *desig -= t - *sigma;
00336 } else {
00337 t = *sigma + *tau;
00338 *desig = *sigma - (t - *tau) + *desig;
00339 }
00340 *sigma = t;
00341
00342 return 0;
00343
00344
00345
00346 }