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


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