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__3 = 3;
00019 static integer c__1 = 1;
00020 static integer c__6 = 6;
00021 static integer c__4 = 4;
00022 static integer c__20 = 20;
00023 static integer c__1200 = 1200;
00024
00025 int cget38_(real *rmax, integer *lmax, integer *ninfo,
00026 integer *knt, integer *nin)
00027 {
00028
00029 integer i__1, i__2, i__3, i__4;
00030 real r__1, r__2;
00031
00032
00033 double sqrt(doublereal);
00034 integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
00035 e_rsle(void);
00036 double r_imag(complex *);
00037
00038
00039 integer i__, j, m, n;
00040 complex q[400] ;
00041 real s;
00042 complex t[400] ;
00043 real v;
00044 complex w[20];
00045 real val[3], eps, sep, sin__, tol;
00046 complex tmp[400] ;
00047 integer ndim, iscl, info, kmin, itmp;
00048 real vmin, vmax;
00049 integer ipnt[20];
00050 complex qsav[400] , tsav[400] ;
00051 real tnrm;
00052 integer isrt;
00053 complex qtmp[400] ;
00054 real stmp, vmul;
00055 complex ttmp[400] , work[1200], wtmp[20];
00056 real wsrt[20];
00057 complex tsav1[400] ;
00058 extern int chst01_(integer *, integer *, integer *,
00059 complex *, integer *, complex *, integer *, complex *, integer *,
00060 complex *, integer *, real *, real *);
00061 real sepin, tolin, rwork[20];
00062 extern int slabad_(real *, real *);
00063 extern doublereal clange_(char *, integer *, integer *, complex *,
00064 integer *, real *);
00065 extern int cgehrd_(integer *, integer *, integer *,
00066 complex *, integer *, complex *, complex *, integer *, integer *);
00067 integer iselec[20];
00068 extern doublereal slamch_(char *);
00069 extern int csscal_(integer *, real *, complex *, integer
00070 *), clacpy_(char *, integer *, integer *, complex *, integer *,
00071 complex *, integer *);
00072 logical select[20];
00073 real bignum;
00074 extern int chseqr_(char *, char *, integer *, integer *,
00075 integer *, complex *, integer *, complex *, complex *, integer *,
00076 complex *, integer *, integer *), cunghr_(integer
00077 *, integer *, integer *, complex *, integer *, complex *, complex
00078 *, integer *, integer *), ctrsen_(char *, char *, logical *,
00079 integer *, complex *, integer *, complex *, integer *, complex *,
00080 integer *, real *, real *, complex *, integer *, integer *);
00081 real septmp, smlnum, result[2];
00082
00083
00084 static cilist io___5 = { 0, 0, 0, 0, 0 };
00085 static cilist io___9 = { 0, 0, 0, 0, 0 };
00086 static cilist io___12 = { 0, 0, 0, 0, 0 };
00087 static cilist io___15 = { 0, 0, 0, 0, 0 };
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
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 --ninfo;
00157 --lmax;
00158 --rmax;
00159
00160
00161 eps = slamch_("P");
00162 smlnum = slamch_("S") / eps;
00163 bignum = 1.f / smlnum;
00164 slabad_(&smlnum, &bignum);
00165
00166
00167
00168 eps = dmax(eps,5.9605e-8f);
00169 rmax[1] = 0.f;
00170 rmax[2] = 0.f;
00171 rmax[3] = 0.f;
00172 lmax[1] = 0;
00173 lmax[2] = 0;
00174 lmax[3] = 0;
00175 *knt = 0;
00176 ninfo[1] = 0;
00177 ninfo[2] = 0;
00178 ninfo[3] = 0;
00179 val[0] = sqrt(smlnum);
00180 val[1] = 1.f;
00181 val[2] = sqrt(sqrt(bignum));
00182
00183
00184
00185
00186
00187 L10:
00188 io___5.ciunit = *nin;
00189 s_rsle(&io___5);
00190 do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00191 do_lio(&c__3, &c__1, (char *)&ndim, (ftnlen)sizeof(integer));
00192 do_lio(&c__3, &c__1, (char *)&isrt, (ftnlen)sizeof(integer));
00193 e_rsle();
00194 if (n == 0) {
00195 return 0;
00196 }
00197 io___9.ciunit = *nin;
00198 s_rsle(&io___9);
00199 i__1 = ndim;
00200 for (i__ = 1; i__ <= i__1; ++i__) {
00201 do_lio(&c__3, &c__1, (char *)&iselec[i__ - 1], (ftnlen)sizeof(integer)
00202 );
00203 }
00204 e_rsle();
00205 i__1 = n;
00206 for (i__ = 1; i__ <= i__1; ++i__) {
00207 io___12.ciunit = *nin;
00208 s_rsle(&io___12);
00209 i__2 = n;
00210 for (j = 1; j <= i__2; ++j) {
00211 do_lio(&c__6, &c__1, (char *)&tmp[i__ + j * 20 - 21], (ftnlen)
00212 sizeof(complex));
00213 }
00214 e_rsle();
00215
00216 }
00217 io___15.ciunit = *nin;
00218 s_rsle(&io___15);
00219 do_lio(&c__4, &c__1, (char *)&sin__, (ftnlen)sizeof(real));
00220 do_lio(&c__4, &c__1, (char *)&sepin, (ftnlen)sizeof(real));
00221 e_rsle();
00222
00223 tnrm = clange_("M", &n, &n, tmp, &c__20, rwork);
00224 for (iscl = 1; iscl <= 3; ++iscl) {
00225
00226
00227
00228 ++(*knt);
00229 clacpy_("F", &n, &n, tmp, &c__20, t, &c__20);
00230 vmul = val[iscl - 1];
00231 i__1 = n;
00232 for (i__ = 1; i__ <= i__1; ++i__) {
00233 csscal_(&n, &vmul, &t[i__ * 20 - 20], &c__1);
00234
00235 }
00236 if (tnrm == 0.f) {
00237 vmul = 1.f;
00238 }
00239 clacpy_("F", &n, &n, t, &c__20, tsav, &c__20);
00240
00241
00242
00243 i__1 = 1200 - n;
00244 cgehrd_(&n, &c__1, &n, t, &c__20, work, &work[n], &i__1, &info);
00245 if (info != 0) {
00246 lmax[1] = *knt;
00247 ++ninfo[1];
00248 goto L200;
00249 }
00250
00251
00252
00253 clacpy_("L", &n, &n, t, &c__20, q, &c__20);
00254 i__1 = 1200 - n;
00255 cunghr_(&n, &c__1, &n, q, &c__20, work, &work[n], &i__1, &info);
00256
00257
00258
00259 i__1 = n - 2;
00260 for (j = 1; j <= i__1; ++j) {
00261 i__2 = n;
00262 for (i__ = j + 2; i__ <= i__2; ++i__) {
00263 i__3 = i__ + j * 20 - 21;
00264 t[i__3].r = 0.f, t[i__3].i = 0.f;
00265
00266 }
00267
00268 }
00269 chseqr_("S", "V", &n, &c__1, &n, t, &c__20, w, q, &c__20, work, &
00270 c__1200, &info);
00271 if (info != 0) {
00272 lmax[2] = *knt;
00273 ++ninfo[2];
00274 goto L200;
00275 }
00276
00277
00278
00279 i__1 = n;
00280 for (i__ = 1; i__ <= i__1; ++i__) {
00281 ipnt[i__ - 1] = i__;
00282 select[i__ - 1] = FALSE_;
00283
00284 }
00285 if (isrt == 0) {
00286 i__1 = n;
00287 for (i__ = 1; i__ <= i__1; ++i__) {
00288 i__2 = i__ - 1;
00289 wsrt[i__ - 1] = w[i__2].r;
00290
00291 }
00292 } else {
00293 i__1 = n;
00294 for (i__ = 1; i__ <= i__1; ++i__) {
00295 wsrt[i__ - 1] = r_imag(&w[i__ - 1]);
00296
00297 }
00298 }
00299 i__1 = n - 1;
00300 for (i__ = 1; i__ <= i__1; ++i__) {
00301 kmin = i__;
00302 vmin = wsrt[i__ - 1];
00303 i__2 = n;
00304 for (j = i__ + 1; j <= i__2; ++j) {
00305 if (wsrt[j - 1] < vmin) {
00306 kmin = j;
00307 vmin = wsrt[j - 1];
00308 }
00309
00310 }
00311 wsrt[kmin - 1] = wsrt[i__ - 1];
00312 wsrt[i__ - 1] = vmin;
00313 itmp = ipnt[i__ - 1];
00314 ipnt[i__ - 1] = ipnt[kmin - 1];
00315 ipnt[kmin - 1] = itmp;
00316
00317 }
00318 i__1 = ndim;
00319 for (i__ = 1; i__ <= i__1; ++i__) {
00320 select[ipnt[iselec[i__ - 1] - 1] - 1] = TRUE_;
00321
00322 }
00323
00324
00325
00326 clacpy_("F", &n, &n, q, &c__20, qsav, &c__20);
00327 clacpy_("F", &n, &n, t, &c__20, tsav1, &c__20);
00328 ctrsen_("B", "V", select, &n, t, &c__20, q, &c__20, wtmp, &m, &s, &
00329 sep, work, &c__1200, &info);
00330 if (info != 0) {
00331 lmax[3] = *knt;
00332 ++ninfo[3];
00333 goto L200;
00334 }
00335 septmp = sep / vmul;
00336 stmp = s;
00337
00338
00339
00340 chst01_(&n, &c__1, &n, tsav, &c__20, t, &c__20, q, &c__20, work, &
00341 c__1200, rwork, result);
00342 vmax = dmax(result[0],result[1]);
00343 if (vmax > rmax[1]) {
00344 rmax[1] = vmax;
00345 if (ninfo[1] == 0) {
00346 lmax[1] = *knt;
00347 }
00348 }
00349
00350
00351
00352
00353
00354 r__1 = (real) n * 2.f * eps * tnrm;
00355 v = dmax(r__1,smlnum);
00356 if (tnrm == 0.f) {
00357 v = 1.f;
00358 }
00359 if (v > septmp) {
00360 tol = 1.f;
00361 } else {
00362 tol = v / septmp;
00363 }
00364 if (v > sepin) {
00365 tolin = 1.f;
00366 } else {
00367 tolin = v / sepin;
00368 }
00369
00370 r__1 = tol, r__2 = smlnum / eps;
00371 tol = dmax(r__1,r__2);
00372
00373 r__1 = tolin, r__2 = smlnum / eps;
00374 tolin = dmax(r__1,r__2);
00375 if (eps * (sin__ - tolin) > stmp + tol) {
00376 vmax = 1.f / eps;
00377 } else if (sin__ - tolin > stmp + tol) {
00378 vmax = (sin__ - tolin) / (stmp + tol);
00379 } else if (sin__ + tolin < eps * (stmp - tol)) {
00380 vmax = 1.f / eps;
00381 } else if (sin__ + tolin < stmp - tol) {
00382 vmax = (stmp - tol) / (sin__ + tolin);
00383 } else {
00384 vmax = 1.f;
00385 }
00386 if (vmax > rmax[2]) {
00387 rmax[2] = vmax;
00388 if (ninfo[2] == 0) {
00389 lmax[2] = *knt;
00390 }
00391 }
00392
00393
00394
00395
00396 if (v > septmp * stmp) {
00397 tol = septmp;
00398 } else {
00399 tol = v / stmp;
00400 }
00401 if (v > sepin * sin__) {
00402 tolin = sepin;
00403 } else {
00404 tolin = v / sin__;
00405 }
00406
00407 r__1 = tol, r__2 = smlnum / eps;
00408 tol = dmax(r__1,r__2);
00409
00410 r__1 = tolin, r__2 = smlnum / eps;
00411 tolin = dmax(r__1,r__2);
00412 if (eps * (sepin - tolin) > septmp + tol) {
00413 vmax = 1.f / eps;
00414 } else if (sepin - tolin > septmp + tol) {
00415 vmax = (sepin - tolin) / (septmp + tol);
00416 } else if (sepin + tolin < eps * (septmp - tol)) {
00417 vmax = 1.f / eps;
00418 } else if (sepin + tolin < septmp - tol) {
00419 vmax = (septmp - tol) / (sepin + tolin);
00420 } else {
00421 vmax = 1.f;
00422 }
00423 if (vmax > rmax[2]) {
00424 rmax[2] = vmax;
00425 if (ninfo[2] == 0) {
00426 lmax[2] = *knt;
00427 }
00428 }
00429
00430
00431
00432
00433 if (sin__ <= (real) (n << 1) * eps && stmp <= (real) (n << 1) * eps) {
00434 vmax = 1.f;
00435 } else if (eps * sin__ > stmp) {
00436 vmax = 1.f / eps;
00437 } else if (sin__ > stmp) {
00438 vmax = sin__ / stmp;
00439 } else if (sin__ < eps * stmp) {
00440 vmax = 1.f / eps;
00441 } else if (sin__ < stmp) {
00442 vmax = stmp / sin__;
00443 } else {
00444 vmax = 1.f;
00445 }
00446 if (vmax > rmax[3]) {
00447 rmax[3] = vmax;
00448 if (ninfo[3] == 0) {
00449 lmax[3] = *knt;
00450 }
00451 }
00452
00453
00454
00455
00456 if (sepin <= v && septmp <= v) {
00457 vmax = 1.f;
00458 } else if (eps * sepin > septmp) {
00459 vmax = 1.f / eps;
00460 } else if (sepin > septmp) {
00461 vmax = sepin / septmp;
00462 } else if (sepin < eps * septmp) {
00463 vmax = 1.f / eps;
00464 } else if (sepin < septmp) {
00465 vmax = septmp / sepin;
00466 } else {
00467 vmax = 1.f;
00468 }
00469 if (vmax > rmax[3]) {
00470 rmax[3] = vmax;
00471 if (ninfo[3] == 0) {
00472 lmax[3] = *knt;
00473 }
00474 }
00475
00476
00477
00478
00479 vmax = 0.f;
00480 clacpy_("F", &n, &n, tsav1, &c__20, ttmp, &c__20);
00481 clacpy_("F", &n, &n, qsav, &c__20, qtmp, &c__20);
00482 septmp = -1.f;
00483 stmp = -1.f;
00484 ctrsen_("E", "V", select, &n, ttmp, &c__20, qtmp, &c__20, wtmp, &m, &
00485 stmp, &septmp, work, &c__1200, &info);
00486 if (info != 0) {
00487 lmax[3] = *knt;
00488 ++ninfo[3];
00489 goto L200;
00490 }
00491 if (s != stmp) {
00492 vmax = 1.f / eps;
00493 }
00494 if (-1.f != septmp) {
00495 vmax = 1.f / eps;
00496 }
00497 i__1 = n;
00498 for (i__ = 1; i__ <= i__1; ++i__) {
00499 i__2 = n;
00500 for (j = 1; j <= i__2; ++j) {
00501 i__3 = i__ + j * 20 - 21;
00502 i__4 = i__ + j * 20 - 21;
00503 if (ttmp[i__3].r != t[i__4].r || ttmp[i__3].i != t[i__4].i) {
00504 vmax = 1.f / eps;
00505 }
00506 i__3 = i__ + j * 20 - 21;
00507 i__4 = i__ + j * 20 - 21;
00508 if (qtmp[i__3].r != q[i__4].r || qtmp[i__3].i != q[i__4].i) {
00509 vmax = 1.f / eps;
00510 }
00511
00512 }
00513
00514 }
00515
00516
00517
00518
00519 clacpy_("F", &n, &n, tsav1, &c__20, ttmp, &c__20);
00520 clacpy_("F", &n, &n, qsav, &c__20, qtmp, &c__20);
00521 septmp = -1.f;
00522 stmp = -1.f;
00523 ctrsen_("V", "V", select, &n, ttmp, &c__20, qtmp, &c__20, wtmp, &m, &
00524 stmp, &septmp, work, &c__1200, &info);
00525 if (info != 0) {
00526 lmax[3] = *knt;
00527 ++ninfo[3];
00528 goto L200;
00529 }
00530 if (-1.f != stmp) {
00531 vmax = 1.f / eps;
00532 }
00533 if (sep != septmp) {
00534 vmax = 1.f / eps;
00535 }
00536 i__1 = n;
00537 for (i__ = 1; i__ <= i__1; ++i__) {
00538 i__2 = n;
00539 for (j = 1; j <= i__2; ++j) {
00540 i__3 = i__ + j * 20 - 21;
00541 i__4 = i__ + j * 20 - 21;
00542 if (ttmp[i__3].r != t[i__4].r || ttmp[i__3].i != t[i__4].i) {
00543 vmax = 1.f / eps;
00544 }
00545 i__3 = i__ + j * 20 - 21;
00546 i__4 = i__ + j * 20 - 21;
00547 if (qtmp[i__3].r != q[i__4].r || qtmp[i__3].i != q[i__4].i) {
00548 vmax = 1.f / eps;
00549 }
00550
00551 }
00552
00553 }
00554
00555
00556
00557
00558 clacpy_("F", &n, &n, tsav1, &c__20, ttmp, &c__20);
00559 clacpy_("F", &n, &n, qsav, &c__20, qtmp, &c__20);
00560 septmp = -1.f;
00561 stmp = -1.f;
00562 ctrsen_("E", "N", select, &n, ttmp, &c__20, qtmp, &c__20, wtmp, &m, &
00563 stmp, &septmp, work, &c__1200, &info);
00564 if (info != 0) {
00565 lmax[3] = *knt;
00566 ++ninfo[3];
00567 goto L200;
00568 }
00569 if (s != stmp) {
00570 vmax = 1.f / eps;
00571 }
00572 if (-1.f != septmp) {
00573 vmax = 1.f / eps;
00574 }
00575 i__1 = n;
00576 for (i__ = 1; i__ <= i__1; ++i__) {
00577 i__2 = n;
00578 for (j = 1; j <= i__2; ++j) {
00579 i__3 = i__ + j * 20 - 21;
00580 i__4 = i__ + j * 20 - 21;
00581 if (ttmp[i__3].r != t[i__4].r || ttmp[i__3].i != t[i__4].i) {
00582 vmax = 1.f / eps;
00583 }
00584 i__3 = i__ + j * 20 - 21;
00585 i__4 = i__ + j * 20 - 21;
00586 if (qtmp[i__3].r != qsav[i__4].r || qtmp[i__3].i != qsav[i__4]
00587 .i) {
00588 vmax = 1.f / eps;
00589 }
00590
00591 }
00592
00593 }
00594
00595
00596
00597
00598 clacpy_("F", &n, &n, tsav1, &c__20, ttmp, &c__20);
00599 clacpy_("F", &n, &n, qsav, &c__20, qtmp, &c__20);
00600 septmp = -1.f;
00601 stmp = -1.f;
00602 ctrsen_("V", "N", select, &n, ttmp, &c__20, qtmp, &c__20, wtmp, &m, &
00603 stmp, &septmp, work, &c__1200, &info);
00604 if (info != 0) {
00605 lmax[3] = *knt;
00606 ++ninfo[3];
00607 goto L200;
00608 }
00609 if (-1.f != stmp) {
00610 vmax = 1.f / eps;
00611 }
00612 if (sep != septmp) {
00613 vmax = 1.f / eps;
00614 }
00615 i__1 = n;
00616 for (i__ = 1; i__ <= i__1; ++i__) {
00617 i__2 = n;
00618 for (j = 1; j <= i__2; ++j) {
00619 i__3 = i__ + j * 20 - 21;
00620 i__4 = i__ + j * 20 - 21;
00621 if (ttmp[i__3].r != t[i__4].r || ttmp[i__3].i != t[i__4].i) {
00622 vmax = 1.f / eps;
00623 }
00624 i__3 = i__ + j * 20 - 21;
00625 i__4 = i__ + j * 20 - 21;
00626 if (qtmp[i__3].r != qsav[i__4].r || qtmp[i__3].i != qsav[i__4]
00627 .i) {
00628 vmax = 1.f / eps;
00629 }
00630
00631 }
00632
00633 }
00634 if (vmax > rmax[1]) {
00635 rmax[1] = vmax;
00636 if (ninfo[1] == 0) {
00637 lmax[1] = *knt;
00638 }
00639 }
00640 L200:
00641 ;
00642 }
00643 goto L10;
00644
00645
00646
00647 }