00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 static integer c__2 = 2;
00019
00020 int sget31_(real *rmax, integer *lmax, integer *ninfo,
00021 integer *knt)
00022 {
00023
00024
00025 static logical ltrans[2] = { FALSE_,TRUE_ };
00026
00027
00028 real r__1, r__2, r__3, r__4, r__5, r__6, r__7, r__8, r__9, r__10, r__11,
00029 r__12, r__13;
00030
00031
00032 double sqrt(doublereal);
00033
00034
00035 real a[4] , b[4] , x[4]
00036 , d1, d2, ca;
00037 integer ia, ib, na;
00038 real wi;
00039 integer nw;
00040 real wr;
00041 integer id1, id2, ica;
00042 real den, vab[3], vca[5], vdd[4], eps;
00043 integer iwi;
00044 real res, tmp;
00045 integer iwr;
00046 real vwi[4], vwr[4];
00047 integer info;
00048 real unfl, smin, scale;
00049 integer ismin;
00050 real vsmin[4], xnorm;
00051 extern int slaln2_(logical *, integer *, integer *, real
00052 *, real *, real *, integer *, real *, real *, real *, integer *,
00053 real *, real *, real *, integer *, real *, real *, integer *),
00054 slabad_(real *, real *);
00055 extern doublereal slamch_(char *);
00056 real bignum;
00057 integer itrans;
00058 real smlnum;
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 --ninfo;
00129
00130
00131
00132
00133
00134
00135
00136 eps = slamch_("P");
00137 unfl = slamch_("U");
00138 smlnum = slamch_("S") / eps;
00139 bignum = 1.f / smlnum;
00140 slabad_(&smlnum, &bignum);
00141
00142
00143
00144 vsmin[0] = smlnum;
00145 vsmin[1] = eps;
00146 vsmin[2] = .01f;
00147 vsmin[3] = 1.f / eps;
00148 vab[0] = sqrt(smlnum);
00149 vab[1] = 1.f;
00150 vab[2] = sqrt(bignum);
00151 vwr[0] = 0.f;
00152 vwr[1] = .5f;
00153 vwr[2] = 2.f;
00154 vwr[3] = 1.f;
00155 vwi[0] = smlnum;
00156 vwi[1] = eps;
00157 vwi[2] = 1.f;
00158 vwi[3] = 2.f;
00159 vdd[0] = sqrt(smlnum);
00160 vdd[1] = 1.f;
00161 vdd[2] = 2.f;
00162 vdd[3] = sqrt(bignum);
00163 vca[0] = 0.f;
00164 vca[1] = sqrt(smlnum);
00165 vca[2] = eps;
00166 vca[3] = .5f;
00167 vca[4] = 1.f;
00168
00169 *knt = 0;
00170 ninfo[1] = 0;
00171 ninfo[2] = 0;
00172 *lmax = 0;
00173 *rmax = 0.f;
00174
00175
00176
00177 for (id1 = 1; id1 <= 4; ++id1) {
00178 d1 = vdd[id1 - 1];
00179 for (id2 = 1; id2 <= 4; ++id2) {
00180 d2 = vdd[id2 - 1];
00181 for (ica = 1; ica <= 5; ++ica) {
00182 ca = vca[ica - 1];
00183 for (itrans = 0; itrans <= 1; ++itrans) {
00184 for (ismin = 1; ismin <= 4; ++ismin) {
00185 smin = vsmin[ismin - 1];
00186
00187 na = 1;
00188 nw = 1;
00189 for (ia = 1; ia <= 3; ++ia) {
00190 a[0] = vab[ia - 1];
00191 for (ib = 1; ib <= 3; ++ib) {
00192 b[0] = vab[ib - 1];
00193 for (iwr = 1; iwr <= 4; ++iwr) {
00194 if (d1 == 1.f && d2 == 1.f && ca == 1.f) {
00195 wr = vwr[iwr - 1] * a[0];
00196 } else {
00197 wr = vwr[iwr - 1];
00198 }
00199 wi = 0.f;
00200 slaln2_(<rans[itrans], &na, &nw, &smin,
00201 &ca, a, &c__2, &d1, &d2, b, &c__2,
00202 &wr, &wi, x, &c__2, &scale, &
00203 xnorm, &info);
00204 if (info < 0) {
00205 ++ninfo[1];
00206 }
00207 if (info > 0) {
00208 ++ninfo[2];
00209 }
00210 res = (r__1 = (ca * a[0] - wr * d1) * x[0]
00211 - scale * b[0], dabs(r__1));
00212 if (info == 0) {
00213
00214 r__2 = eps * (r__1 = (ca * a[0] - wr *
00215 d1) * x[0], dabs(r__1));
00216 den = dmax(r__2,smlnum);
00217 } else {
00218
00219 r__1 = smin * dabs(x[0]);
00220 den = dmax(r__1,smlnum);
00221 }
00222 res /= den;
00223 if (dabs(x[0]) < unfl && dabs(b[0]) <=
00224 smlnum * (r__1 = ca * a[0] - wr *
00225 d1, dabs(r__1))) {
00226 res = 0.f;
00227 }
00228 if (scale > 1.f) {
00229 res += 1.f / eps;
00230 }
00231 res += (r__1 = xnorm - dabs(x[0]), dabs(
00232 r__1)) / dmax(smlnum,xnorm) / eps;
00233 if (info != 0 && info != 1) {
00234 res += 1.f / eps;
00235 }
00236 ++(*knt);
00237 if (res > *rmax) {
00238 *lmax = *knt;
00239 *rmax = res;
00240 }
00241
00242 }
00243
00244 }
00245
00246 }
00247
00248 na = 1;
00249 nw = 2;
00250 for (ia = 1; ia <= 3; ++ia) {
00251 a[0] = vab[ia - 1];
00252 for (ib = 1; ib <= 3; ++ib) {
00253 b[0] = vab[ib - 1];
00254 b[2] = vab[ib - 1] * -.5f;
00255 for (iwr = 1; iwr <= 4; ++iwr) {
00256 if (d1 == 1.f && d2 == 1.f && ca == 1.f) {
00257 wr = vwr[iwr - 1] * a[0];
00258 } else {
00259 wr = vwr[iwr - 1];
00260 }
00261 for (iwi = 1; iwi <= 4; ++iwi) {
00262 if (d1 == 1.f && d2 == 1.f && ca ==
00263 1.f) {
00264 wi = vwi[iwi - 1] * a[0];
00265 } else {
00266 wi = vwi[iwi - 1];
00267 }
00268 slaln2_(<rans[itrans], &na, &nw, &
00269 smin, &ca, a, &c__2, &d1, &d2,
00270 b, &c__2, &wr, &wi, x, &c__2,
00271 &scale, &xnorm, &info);
00272 if (info < 0) {
00273 ++ninfo[1];
00274 }
00275 if (info > 0) {
00276 ++ninfo[2];
00277 }
00278 res = (r__1 = (ca * a[0] - wr * d1) *
00279 x[0] + wi * d1 * x[2] - scale
00280 * b[0], dabs(r__1));
00281 res += (r__1 = -wi * d1 * x[0] + (ca *
00282 a[0] - wr * d1) * x[2] -
00283 scale * b[2], dabs(r__1));
00284 if (info == 0) {
00285
00286
00287 r__4 = (r__1 = ca * a[0] - wr *
00288 d1, dabs(r__1)), r__5 = (
00289 r__2 = d1 * wi, dabs(r__2)
00290 );
00291 r__3 = eps * (dmax(r__4,r__5) * (
00292 dabs(x[0]) + dabs(x[2])));
00293 den = dmax(r__3,smlnum);
00294 } else {
00295
00296 r__1 = smin * (dabs(x[0]) + dabs(
00297 x[2]));
00298 den = dmax(r__1,smlnum);
00299 }
00300 res /= den;
00301 if (dabs(x[0]) < unfl && dabs(x[2]) <
00302 unfl && dabs(b[0]) <= smlnum *
00303 (r__1 = ca * a[0] - wr * d1,
00304 dabs(r__1))) {
00305 res = 0.f;
00306 }
00307 if (scale > 1.f) {
00308 res += 1.f / eps;
00309 }
00310 res += (r__1 = xnorm - dabs(x[0]) -
00311 dabs(x[2]), dabs(r__1)) /
00312 dmax(smlnum,xnorm) / eps;
00313 if (info != 0 && info != 1) {
00314 res += 1.f / eps;
00315 }
00316 ++(*knt);
00317 if (res > *rmax) {
00318 *lmax = *knt;
00319 *rmax = res;
00320 }
00321
00322 }
00323
00324 }
00325
00326 }
00327
00328 }
00329
00330 na = 2;
00331 nw = 1;
00332 for (ia = 1; ia <= 3; ++ia) {
00333 a[0] = vab[ia - 1];
00334 a[2] = vab[ia - 1] * -3.f;
00335 a[1] = vab[ia - 1] * -7.f;
00336 a[3] = vab[ia - 1] * 21.f;
00337 for (ib = 1; ib <= 3; ++ib) {
00338 b[0] = vab[ib - 1];
00339 b[1] = vab[ib - 1] * -2.f;
00340 for (iwr = 1; iwr <= 4; ++iwr) {
00341 if (d1 == 1.f && d2 == 1.f && ca == 1.f) {
00342 wr = vwr[iwr - 1] * a[0];
00343 } else {
00344 wr = vwr[iwr - 1];
00345 }
00346 wi = 0.f;
00347 slaln2_(<rans[itrans], &na, &nw, &smin,
00348 &ca, a, &c__2, &d1, &d2, b, &c__2,
00349 &wr, &wi, x, &c__2, &scale, &
00350 xnorm, &info);
00351 if (info < 0) {
00352 ++ninfo[1];
00353 }
00354 if (info > 0) {
00355 ++ninfo[2];
00356 }
00357 if (itrans == 1) {
00358 tmp = a[2];
00359 a[2] = a[1];
00360 a[1] = tmp;
00361 }
00362 res = (r__1 = (ca * a[0] - wr * d1) * x[0]
00363 + ca * a[2] * x[1] - scale * b[0]
00364 , dabs(r__1));
00365 res += (r__1 = ca * a[1] * x[0] + (ca * a[
00366 3] - wr * d2) * x[1] - scale * b[
00367 1], dabs(r__1));
00368 if (info == 0) {
00369
00370
00371 r__6 = (r__1 = ca * a[0] - wr * d1,
00372 dabs(r__1)) + (r__2 = ca * a[
00373 2], dabs(r__2)), r__7 = (r__3
00374 = ca * a[1], dabs(r__3)) + (
00375 r__4 = ca * a[3] - wr * d2,
00376 dabs(r__4));
00377
00378 r__8 = dabs(x[0]), r__9 = dabs(x[1]);
00379 r__5 = eps * (dmax(r__6,r__7) * dmax(
00380 r__8,r__9));
00381 den = dmax(r__5,smlnum);
00382 } else {
00383
00384
00385
00386 r__8 = (r__1 = ca * a[0] - wr * d1,
00387 dabs(r__1)) + (r__2 = ca * a[
00388 2], dabs(r__2)), r__9 = (r__3
00389 = ca * a[1], dabs(r__3)) + (
00390 r__4 = ca * a[3] - wr * d2,
00391 dabs(r__4));
00392 r__6 = smin / eps, r__7 = dmax(r__8,
00393 r__9);
00394
00395 r__10 = dabs(x[0]), r__11 = dabs(x[1])
00396 ;
00397 r__5 = eps * (dmax(r__6,r__7) * dmax(
00398 r__10,r__11));
00399 den = dmax(r__5,smlnum);
00400 }
00401 res /= den;
00402 if (dabs(x[0]) < unfl && dabs(x[1]) <
00403 unfl && dabs(b[0]) + dabs(b[1]) <=
00404 smlnum * ((r__1 = ca * a[0] - wr
00405 * d1, dabs(r__1)) + (r__2 = ca *
00406 a[2], dabs(r__2)) + (r__3 = ca *
00407 a[1], dabs(r__3)) + (r__4 = ca *
00408 a[3] - wr * d2, dabs(r__4)))) {
00409 res = 0.f;
00410 }
00411 if (scale > 1.f) {
00412 res += 1.f / eps;
00413 }
00414
00415 r__2 = dabs(x[0]), r__3 = dabs(x[1]);
00416 res += (r__1 = xnorm - dmax(r__2,r__3),
00417 dabs(r__1)) / dmax(smlnum,xnorm) /
00418 eps;
00419 if (info != 0 && info != 1) {
00420 res += 1.f / eps;
00421 }
00422 ++(*knt);
00423 if (res > *rmax) {
00424 *lmax = *knt;
00425 *rmax = res;
00426 }
00427
00428 }
00429
00430 }
00431
00432 }
00433
00434 na = 2;
00435 nw = 2;
00436 for (ia = 1; ia <= 3; ++ia) {
00437 a[0] = vab[ia - 1] * 2.f;
00438 a[2] = vab[ia - 1] * -3.f;
00439 a[1] = vab[ia - 1] * -7.f;
00440 a[3] = vab[ia - 1] * 21.f;
00441 for (ib = 1; ib <= 3; ++ib) {
00442 b[0] = vab[ib - 1];
00443 b[1] = vab[ib - 1] * -2.f;
00444 b[2] = vab[ib - 1] * 4.f;
00445 b[3] = vab[ib - 1] * -7.f;
00446 for (iwr = 1; iwr <= 4; ++iwr) {
00447 if (d1 == 1.f && d2 == 1.f && ca == 1.f) {
00448 wr = vwr[iwr - 1] * a[0];
00449 } else {
00450 wr = vwr[iwr - 1];
00451 }
00452 for (iwi = 1; iwi <= 4; ++iwi) {
00453 if (d1 == 1.f && d2 == 1.f && ca ==
00454 1.f) {
00455 wi = vwi[iwi - 1] * a[0];
00456 } else {
00457 wi = vwi[iwi - 1];
00458 }
00459 slaln2_(<rans[itrans], &na, &nw, &
00460 smin, &ca, a, &c__2, &d1, &d2,
00461 b, &c__2, &wr, &wi, x, &c__2,
00462 &scale, &xnorm, &info);
00463 if (info < 0) {
00464 ++ninfo[1];
00465 }
00466 if (info > 0) {
00467 ++ninfo[2];
00468 }
00469 if (itrans == 1) {
00470 tmp = a[2];
00471 a[2] = a[1];
00472 a[1] = tmp;
00473 }
00474 res = (r__1 = (ca * a[0] - wr * d1) *
00475 x[0] + ca * a[2] * x[1] + wi *
00476 d1 * x[2] - scale * b[0],
00477 dabs(r__1));
00478 res += (r__1 = (ca * a[0] - wr * d1) *
00479 x[2] + ca * a[2] * x[3] - wi
00480 * d1 * x[0] - scale * b[2],
00481 dabs(r__1));
00482 res += (r__1 = ca * a[1] * x[0] + (ca
00483 * a[3] - wr * d2) * x[1] + wi
00484 * d2 * x[3] - scale * b[1],
00485 dabs(r__1));
00486 res += (r__1 = ca * a[1] * x[2] + (ca
00487 * a[3] - wr * d2) * x[3] - wi
00488 * d2 * x[1] - scale * b[3],
00489 dabs(r__1));
00490 if (info == 0) {
00491
00492
00493 r__8 = (r__1 = ca * a[0] - wr *
00494 d1, dabs(r__1)) + (r__2 =
00495 ca * a[2], dabs(r__2)) + (
00496 r__3 = wi * d1, dabs(r__3)
00497 ), r__9 = (r__4 = ca * a[
00498 1], dabs(r__4)) + (r__5 =
00499 ca * a[3] - wr * d2, dabs(
00500 r__5)) + (r__6 = wi * d2,
00501 dabs(r__6));
00502
00503 r__10 = dabs(x[0]) + dabs(x[1]),
00504 r__11 = dabs(x[2]) + dabs(
00505 x[3]);
00506 r__7 = eps * (dmax(r__8,r__9) *
00507 dmax(r__10,r__11));
00508 den = dmax(r__7,smlnum);
00509 } else {
00510
00511
00512
00513 r__10 = (r__1 = ca * a[0] - wr *
00514 d1, dabs(r__1)) + (r__2 =
00515 ca * a[2], dabs(r__2)) + (
00516 r__3 = wi * d1, dabs(r__3)
00517 ), r__11 = (r__4 = ca * a[
00518 1], dabs(r__4)) + (r__5 =
00519 ca * a[3] - wr * d2, dabs(
00520 r__5)) + (r__6 = wi * d2,
00521 dabs(r__6));
00522 r__8 = smin / eps, r__9 = dmax(
00523 r__10,r__11);
00524
00525 r__12 = dabs(x[0]) + dabs(x[1]),
00526 r__13 = dabs(x[2]) + dabs(
00527 x[3]);
00528 r__7 = eps * (dmax(r__8,r__9) *
00529 dmax(r__12,r__13));
00530 den = dmax(r__7,smlnum);
00531 }
00532 res /= den;
00533 if (dabs(x[0]) < unfl && dabs(x[1]) <
00534 unfl && dabs(x[2]) < unfl &&
00535 dabs(x[3]) < unfl && dabs(b[0]
00536 ) + dabs(b[1]) <= smlnum * ((
00537 r__1 = ca * a[0] - wr * d1,
00538 dabs(r__1)) + (r__2 = ca * a[
00539 2], dabs(r__2)) + (r__3 = ca *
00540 a[1], dabs(r__3)) + (r__4 =
00541 ca * a[3] - wr * d2, dabs(
00542 r__4)) + (r__5 = wi * d2,
00543 dabs(r__5)) + (r__6 = wi * d1,
00544 dabs(r__6)))) {
00545 res = 0.f;
00546 }
00547 if (scale > 1.f) {
00548 res += 1.f / eps;
00549 }
00550
00551 r__2 = dabs(x[0]) + dabs(x[2]), r__3 =
00552 dabs(x[1]) + dabs(x[3]);
00553 res += (r__1 = xnorm - dmax(r__2,r__3)
00554 , dabs(r__1)) / dmax(smlnum,
00555 xnorm) / eps;
00556 if (info != 0 && info != 1) {
00557 res += 1.f / eps;
00558 }
00559 ++(*knt);
00560 if (res > *rmax) {
00561 *lmax = *knt;
00562 *rmax = res;
00563 }
00564
00565 }
00566
00567 }
00568
00569 }
00570
00571 }
00572
00573 }
00574
00575 }
00576
00577 }
00578
00579 }
00580
00581 }
00582
00583 return 0;
00584
00585
00586
00587 }