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