sget36.c
Go to the documentation of this file.
00001 /* sget36.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__10 = 10;
00022 static real c_b21 = 0.f;
00023 static real c_b22 = 1.f;
00024 static integer c__200 = 200;
00025 
00026 /* Subroutine */ int sget36_(real *rmax, integer *lmax, integer *ninfo, 
00027         integer *knt, integer *nin)
00028 {
00029     /* System generated locals */
00030     integer i__1, i__2;
00031 
00032     /* Builtin functions */
00033     integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
00034             e_rsle(void);
00035     double r_sign(real *, real *);
00036 
00037     /* Local variables */
00038     integer i__, j, n;
00039     real q[100] /* was [10][10] */, t1[100]     /* was [10][10] */, t2[100]     
00040             /* was [10][10] */;
00041     integer loc;
00042     real eps, res, tmp[100]     /* was [10][10] */;
00043     integer ifst, ilst;
00044     real work[200];
00045     integer info1, info2, ifst1, ifst2, ilst1, ilst2;
00046     extern /* Subroutine */ int shst01_(integer *, integer *, integer *, real 
00047             *, integer *, real *, integer *, real *, integer *, real *, 
00048             integer *, real *);
00049     extern doublereal slamch_(char *);
00050     extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, 
00051             integer *, real *, integer *), slaset_(char *, integer *, 
00052             integer *, real *, real *, real *, integer *), strexc_(
00053             char *, integer *, real *, integer *, real *, integer *, integer *
00054 , integer *, real *, integer *);
00055     integer ifstsv;
00056     real result[2];
00057     integer ilstsv;
00058 
00059     /* Fortran I/O blocks */
00060     static cilist io___2 = { 0, 0, 0, 0, 0 };
00061     static cilist io___7 = { 0, 0, 0, 0, 0 };
00062 
00063 
00064 
00065 /*  -- LAPACK test routine (version 3.1) -- */
00066 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00067 /*     November 2006 */
00068 
00069 /*     .. Scalar Arguments .. */
00070 /*     .. */
00071 /*     .. Array Arguments .. */
00072 /*     .. */
00073 
00074 /*  Purpose */
00075 /*  ======= */
00076 
00077 /*  SGET36 tests STREXC, a routine for moving blocks (either 1 by 1 or */
00078 /*  2 by 2) on the diagonal of a matrix in real Schur form.  Thus, SLAEXC */
00079 /*  computes an orthogonal matrix Q such that */
00080 
00081 /*     Q' * T1 * Q  = T2 */
00082 
00083 /*  and where one of the diagonal blocks of T1 (the one at row IFST) has */
00084 /*  been moved to position ILST. */
00085 
00086 /*  The test code verifies that the residual Q'*T1*Q-T2 is small, that T2 */
00087 /*  is in Schur form, and that the final position of the IFST block is */
00088 /*  ILST (within +-1). */
00089 
00090 /*  The test matrices are read from a file with logical unit number NIN. */
00091 
00092 /*  Arguments */
00093 /*  ========== */
00094 
00095 /*  RMAX    (output) REAL */
00096 /*          Value of the largest test ratio. */
00097 
00098 /*  LMAX    (output) INTEGER */
00099 /*          Example number where largest test ratio achieved. */
00100 
00101 /*  NINFO   (output) INTEGER array, dimension (3) */
00102 /*          NINFO(J) is the number of examples where INFO=J. */
00103 
00104 /*  KNT     (output) INTEGER */
00105 /*          Total number of examples tested. */
00106 
00107 /*  NIN     (input) INTEGER */
00108 /*          Input logical unit number. */
00109 
00110 /*  ===================================================================== */
00111 
00112 /*     .. Parameters .. */
00113 /*     .. */
00114 /*     .. Local Scalars .. */
00115 /*     .. */
00116 /*     .. Local Arrays .. */
00117 /*     .. */
00118 /*     .. External Functions .. */
00119 /*     .. */
00120 /*     .. External Subroutines .. */
00121 /*     .. */
00122 /*     .. Intrinsic Functions .. */
00123 /*     .. */
00124 /*     .. Executable Statements .. */
00125 
00126     /* Parameter adjustments */
00127     --ninfo;
00128 
00129     /* Function Body */
00130     eps = slamch_("P");
00131     *rmax = 0.f;
00132     *lmax = 0;
00133     *knt = 0;
00134     ninfo[1] = 0;
00135     ninfo[2] = 0;
00136     ninfo[3] = 0;
00137 
00138 /*     Read input data until N=0 */
00139 
00140 L10:
00141     io___2.ciunit = *nin;
00142     s_rsle(&io___2);
00143     do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00144     do_lio(&c__3, &c__1, (char *)&ifst, (ftnlen)sizeof(integer));
00145     do_lio(&c__3, &c__1, (char *)&ilst, (ftnlen)sizeof(integer));
00146     e_rsle();
00147     if (n == 0) {
00148         return 0;
00149     }
00150     ++(*knt);
00151     i__1 = n;
00152     for (i__ = 1; i__ <= i__1; ++i__) {
00153         io___7.ciunit = *nin;
00154         s_rsle(&io___7);
00155         i__2 = n;
00156         for (j = 1; j <= i__2; ++j) {
00157             do_lio(&c__4, &c__1, (char *)&tmp[i__ + j * 10 - 11], (ftnlen)
00158                     sizeof(real));
00159         }
00160         e_rsle();
00161 /* L20: */
00162     }
00163     slacpy_("F", &n, &n, tmp, &c__10, t1, &c__10);
00164     slacpy_("F", &n, &n, tmp, &c__10, t2, &c__10);
00165     ifstsv = ifst;
00166     ilstsv = ilst;
00167     ifst1 = ifst;
00168     ilst1 = ilst;
00169     ifst2 = ifst;
00170     ilst2 = ilst;
00171     res = 0.f;
00172 
00173 /*     Test without accumulating Q */
00174 
00175     slaset_("Full", &n, &n, &c_b21, &c_b22, q, &c__10);
00176     strexc_("N", &n, t1, &c__10, q, &c__10, &ifst1, &ilst1, work, &info1);
00177     i__1 = n;
00178     for (i__ = 1; i__ <= i__1; ++i__) {
00179         i__2 = n;
00180         for (j = 1; j <= i__2; ++j) {
00181             if (i__ == j && q[i__ + j * 10 - 11] != 1.f) {
00182                 res += 1.f / eps;
00183             }
00184             if (i__ != j && q[i__ + j * 10 - 11] != 0.f) {
00185                 res += 1.f / eps;
00186             }
00187 /* L30: */
00188         }
00189 /* L40: */
00190     }
00191 
00192 /*     Test with accumulating Q */
00193 
00194     slaset_("Full", &n, &n, &c_b21, &c_b22, q, &c__10);
00195     strexc_("V", &n, t2, &c__10, q, &c__10, &ifst2, &ilst2, work, &info2);
00196 
00197 /*     Compare T1 with T2 */
00198 
00199     i__1 = n;
00200     for (i__ = 1; i__ <= i__1; ++i__) {
00201         i__2 = n;
00202         for (j = 1; j <= i__2; ++j) {
00203             if (t1[i__ + j * 10 - 11] != t2[i__ + j * 10 - 11]) {
00204                 res += 1.f / eps;
00205             }
00206 /* L50: */
00207         }
00208 /* L60: */
00209     }
00210     if (ifst1 != ifst2) {
00211         res += 1.f / eps;
00212     }
00213     if (ilst1 != ilst2) {
00214         res += 1.f / eps;
00215     }
00216     if (info1 != info2) {
00217         res += 1.f / eps;
00218     }
00219 
00220 /*     Test for successful reordering of T2 */
00221 
00222     if (info2 != 0) {
00223         ++ninfo[info2];
00224     } else {
00225         if ((i__1 = ifst2 - ifstsv, abs(i__1)) > 1) {
00226             res += 1.f / eps;
00227         }
00228         if ((i__1 = ilst2 - ilstsv, abs(i__1)) > 1) {
00229             res += 1.f / eps;
00230         }
00231     }
00232 
00233 /*     Test for small residual, and orthogonality of Q */
00234 
00235     shst01_(&n, &c__1, &n, tmp, &c__10, t2, &c__10, q, &c__10, work, &c__200, 
00236             result);
00237     res = res + result[0] + result[1];
00238 
00239 /*     Test for T2 being in Schur form */
00240 
00241     loc = 1;
00242 L70:
00243     if (t2[loc + 1 + loc * 10 - 11] != 0.f) {
00244 
00245 /*        2 by 2 block */
00246 
00247         if (t2[loc + (loc + 1) * 10 - 11] == 0.f || t2[loc + loc * 10 - 11] !=
00248                  t2[loc + 1 + (loc + 1) * 10 - 11] || r_sign(&c_b22, &t2[loc 
00249                 + (loc + 1) * 10 - 11]) == r_sign(&c_b22, &t2[loc + 1 + loc * 
00250                 10 - 11])) {
00251             res += 1.f / eps;
00252         }
00253         i__1 = n;
00254         for (i__ = loc + 2; i__ <= i__1; ++i__) {
00255             if (t2[i__ + loc * 10 - 11] != 0.f) {
00256                 res += 1.f / res;
00257             }
00258             if (t2[i__ + (loc + 1) * 10 - 11] != 0.f) {
00259                 res += 1.f / res;
00260             }
00261 /* L80: */
00262         }
00263         loc += 2;
00264     } else {
00265 
00266 /*        1 by 1 block */
00267 
00268         i__1 = n;
00269         for (i__ = loc + 1; i__ <= i__1; ++i__) {
00270             if (t2[i__ + loc * 10 - 11] != 0.f) {
00271                 res += 1.f / res;
00272             }
00273 /* L90: */
00274         }
00275         ++loc;
00276     }
00277     if (loc < n) {
00278         goto L70;
00279     }
00280     if (res > *rmax) {
00281         *rmax = res;
00282         *lmax = *knt;
00283     }
00284     goto L10;
00285 
00286 /*     End of SGET36 */
00287 
00288 } /* sget36_ */


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