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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:45