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