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