sget38.c
Go to the documentation of this file.
00001 /* sget38.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
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 /* Subroutine */ int sget38_(real *rmax, integer *lmax, integer *ninfo, 
00026         integer *knt, integer *nin)
00027 {
00028     /* System generated locals */
00029     integer i__1, i__2;
00030     real r__1, r__2;
00031 
00032     /* Builtin functions */
00033     double sqrt(doublereal);
00034     integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
00035             e_rsle(void);
00036 
00037     /* Local variables */
00038     integer i__, j, m, n;
00039     real q[400] /* was [20][20] */, s, t[400]   /* was [20][20] */, v, wi[20],
00040              wr[20], val[3], eps, sep, sin__, tol, tmp[400]     /* was [20][
00041             20] */;
00042     integer ndim, iscl, info, kmin, itmp, ipnt[20];
00043     real vmax, qsav[400]        /* was [20][20] */, tsav[400]   /* was [20][
00044             20] */, tnrm, qtmp[400]     /* was [20][20] */, work[1200], stmp, 
00045             vmul, ttmp[400]     /* was [20][20] */, tsav1[400]  /* was [20][
00046             20] */;
00047     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00048     real sepin, vimin;
00049     extern /* Subroutine */ 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 /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00055             integer *);
00056     real witmp[20], wrtmp[20];
00057     extern /* Subroutine */ int slabad_(real *, real *);
00058     integer iselec[20];
00059     extern doublereal slamch_(char *), slange_(char *, integer *, 
00060             integer *, real *, integer *, real *);
00061     extern /* Subroutine */ int sgehrd_(integer *, integer *, integer *, real 
00062             *, integer *, real *, real *, integer *, integer *);
00063     logical select[20];
00064     real bignum;
00065     extern /* Subroutine */ 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 /* Subroutine */ 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     /* Fortran I/O blocks */
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 /*  -- LAPACK test routine (version 3.1) -- */
00086 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00087 /*     November 2006 */
00088 
00089 /*     .. Scalar Arguments .. */
00090 /*     .. */
00091 /*     .. Array Arguments .. */
00092 /*     .. */
00093 
00094 /*  Purpose */
00095 /*  ======= */
00096 
00097 /*  SGET38 tests STRSEN, a routine for estimating condition numbers of a */
00098 /*  cluster of eigenvalues and/or its associated right invariant subspace */
00099 
00100 /*  The test matrices are read from a file with logical unit number NIN. */
00101 
00102 /*  Arguments */
00103 /*  ========== */
00104 
00105 /*  RMAX    (output) REAL array, dimension (3) */
00106 /*          Values of the largest test ratios. */
00107 /*          RMAX(1) = largest residuals from SHST01 or comparing */
00108 /*                    different calls to STRSEN */
00109 /*          RMAX(2) = largest error in reciprocal condition */
00110 /*                    numbers taking their conditioning into account */
00111 /*          RMAX(3) = largest error in reciprocal condition */
00112 /*                    numbers not taking their conditioning into */
00113 /*                    account (may be larger than RMAX(2)) */
00114 
00115 /*  LMAX    (output) INTEGER array, dimension (3) */
00116 /*          LMAX(i) is example number where largest test ratio */
00117 /*          RMAX(i) is achieved. Also: */
00118 /*          If SGEHRD returns INFO nonzero on example i, LMAX(1)=i */
00119 /*          If SHSEQR returns INFO nonzero on example i, LMAX(2)=i */
00120 /*          If STRSEN returns INFO nonzero on example i, LMAX(3)=i */
00121 
00122 /*  NINFO   (output) INTEGER array, dimension (3) */
00123 /*          NINFO(1) = No. of times SGEHRD returned INFO nonzero */
00124 /*          NINFO(2) = No. of times SHSEQR returned INFO nonzero */
00125 /*          NINFO(3) = No. of times STRSEN returned INFO nonzero */
00126 
00127 /*  KNT     (output) INTEGER */
00128 /*          Total number of examples tested. */
00129 
00130 /*  NIN     (input) INTEGER */
00131 /*          Input logical unit number. */
00132 
00133 /*  ===================================================================== */
00134 
00135 /*     .. Parameters .. */
00136 /*     .. */
00137 /*     .. Local Scalars .. */
00138 /*     .. */
00139 /*     .. Local Arrays .. */
00140 /*     .. */
00141 /*     .. External Functions .. */
00142 /*     .. */
00143 /*     .. External Subroutines .. */
00144 /*     .. */
00145 /*     .. Intrinsic Functions .. */
00146 /*     .. */
00147 /*     .. Executable Statements .. */
00148 
00149     /* Parameter adjustments */
00150     --ninfo;
00151     --lmax;
00152     --rmax;
00153 
00154     /* Function Body */
00155     eps = slamch_("P");
00156     smlnum = slamch_("S") / eps;
00157     bignum = 1.f / smlnum;
00158     slabad_(&smlnum, &bignum);
00159 
00160 /*     EPSIN = 2**(-24) = precision to which input data computed */
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 /*     Read input data until N=0.  Assume input eigenvalues are sorted */
00179 /*     lexicographically (increasing by real part, then decreasing by */
00180 /*     imaginary part) */
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 /* L20: */
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 /*        Scale input matrix */
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 /* L30: */
00229         }
00230         if (tnrm == 0.f) {
00231             vmul = 1.f;
00232         }
00233         slacpy_("F", &n, &n, t, &c__20, tsav, &c__20);
00234 
00235 /*        Compute Schur form */
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 /*        Generate orthogonal matrix */
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 /*        Compute Schur form */
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 /*        Sort, select eigenvalues */
00262 
00263         i__1 = n;
00264         for (i__ = 1; i__ <= i__1; ++i__) {
00265             ipnt[i__ - 1] = i__;
00266             select[i__ - 1] = FALSE_;
00267 /* L40: */
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 /* L50: */
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 /* L60: */
00293         }
00294         i__1 = ndim;
00295         for (i__ = 1; i__ <= i__1; ++i__) {
00296             select[ipnt[iselec[i__ - 1] - 1] - 1] = TRUE_;
00297 /* L70: */
00298         }
00299 
00300 /*        Compute condition numbers */
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 /*        Compute residuals */
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 /*        Compare condition number for eigenvalue cluster */
00327 /*        taking its condition number into account */
00328 
00329 /* Computing MAX */
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 /* Computing MAX */
00346         r__1 = tol, r__2 = smlnum / eps;
00347         tol = dmax(r__1,r__2);
00348 /* Computing MAX */
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 /*        Compare condition numbers for invariant subspace */
00370 /*        taking its condition number into account */
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 /* Computing MAX */
00383         r__1 = tol, r__2 = smlnum / eps;
00384         tol = dmax(r__1,r__2);
00385 /* Computing MAX */
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 /*        Compare condition number for eigenvalue cluster */
00407 /*        without taking its condition number into account */
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 /*        Compare condition numbers for invariant subspace */
00430 /*        without taking its condition number into account */
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 /*        Compute eigenvalue condition number only and compare */
00453 /*        Update Q */
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 /* L80: */
00485             }
00486 /* L90: */
00487         }
00488 
00489 /*        Compute invariant subspace condition number only and compare */
00490 /*        Update Q */
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 /* L100: */
00521             }
00522 /* L110: */
00523         }
00524 
00525 /*        Compute eigenvalue condition number only and compare */
00526 /*        Do not update Q */
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 /* L120: */
00557             }
00558 /* L130: */
00559         }
00560 
00561 /*        Compute invariant subspace condition number only and compare */
00562 /*        Do not update Q */
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 /* L140: */
00593             }
00594 /* L150: */
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 /*     End of SGET38 */
00608 
00609 } /* sget38_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:08