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