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


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