cchkgk.c
Go to the documentation of this file.
00001 /* cchkgk.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__50 = 50;
00024 
00025 /* Subroutine */ int cchkgk_(integer *nin, integer *nout)
00026 {
00027     /* Format strings */
00028     static char fmt_9999[] = "(1x,\002.. test output of CGGBAK .. \002)";
00029     static char fmt_9998[] = "(\002 value of largest test error             "
00030             "     =\002,e12.3)";
00031     static char fmt_9997[] = "(\002 example number where CGGBAL info is not "
00032             "0    =\002,i4)";
00033     static char fmt_9996[] = "(\002 example number where CGGBAK(L) info is n"
00034             "ot 0 =\002,i4)";
00035     static char fmt_9995[] = "(\002 example number where CGGBAK(R) info is n"
00036             "ot 0 =\002,i4)";
00037     static char fmt_9994[] = "(\002 example number having largest error     "
00038             "     =\002,i4)";
00039     static char fmt_9992[] = "(\002 number of examples where info is not 0  "
00040             "     =\002,i4)";
00041     static char fmt_9991[] = "(\002 total number of examples tested         "
00042             "     =\002,i4)";
00043 
00044     /* System generated locals */
00045     integer i__1, i__2, i__3, i__4;
00046     real r__1, r__2, r__3, r__4;
00047     complex q__1, q__2;
00048 
00049     /* Builtin functions */
00050     integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
00051             e_rsle(void);
00052     double r_imag(complex *);
00053     integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
00054 
00055     /* Local variables */
00056     complex a[2500]     /* was [50][50] */, b[2500]     /* was [50][50] */, e[
00057             2500]       /* was [50][50] */, f[2500]     /* was [50][50] */;
00058     integer i__, j, m, n;
00059     complex af[2500]    /* was [50][50] */, bf[2500]    /* was [50][50] */, 
00060             vl[2500]    /* was [50][50] */, vr[2500]    /* was [50][50] */;
00061     integer ihi, ilo;
00062     real eps;
00063     complex vlf[2500]   /* was [50][50] */;
00064     integer knt;
00065     complex vrf[2500]   /* was [50][50] */;
00066     integer info, lmax[4];
00067     real rmax, vmax;
00068     complex work[2500]  /* was [50][50] */;
00069     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00070             integer *, complex *, complex *, integer *, complex *, integer *, 
00071             complex *, complex *, integer *);
00072     integer ninfo;
00073     real anorm, bnorm, rwork[300];
00074     extern /* Subroutine */ int cggbak_(char *, char *, integer *, integer *, 
00075             integer *, real *, real *, integer *, complex *, integer *, 
00076             integer *), cggbal_(char *, integer *, complex *, 
00077             integer *, complex *, integer *, integer *, integer *, real *, 
00078             real *, real *, integer *);
00079     extern doublereal clange_(char *, integer *, integer *, complex *, 
00080             integer *, real *);
00081     real lscale[50];
00082     extern doublereal slamch_(char *);
00083     real rscale[50];
00084     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00085             *, integer *, complex *, integer *);
00086 
00087     /* Fortran I/O blocks */
00088     static cilist io___6 = { 0, 0, 0, 0, 0 };
00089     static cilist io___10 = { 0, 0, 0, 0, 0 };
00090     static cilist io___13 = { 0, 0, 0, 0, 0 };
00091     static cilist io___15 = { 0, 0, 0, 0, 0 };
00092     static cilist io___17 = { 0, 0, 0, 0, 0 };
00093     static cilist io___35 = { 0, 0, 0, fmt_9999, 0 };
00094     static cilist io___36 = { 0, 0, 0, fmt_9998, 0 };
00095     static cilist io___37 = { 0, 0, 0, fmt_9997, 0 };
00096     static cilist io___38 = { 0, 0, 0, fmt_9996, 0 };
00097     static cilist io___39 = { 0, 0, 0, fmt_9995, 0 };
00098     static cilist io___40 = { 0, 0, 0, fmt_9994, 0 };
00099     static cilist io___41 = { 0, 0, 0, fmt_9992, 0 };
00100     static cilist io___42 = { 0, 0, 0, fmt_9991, 0 };
00101 
00102 
00103 
00104 /*  -- LAPACK test routine (version 3.1) -- */
00105 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00106 /*     November 2006 */
00107 
00108 /*     .. Scalar Arguments .. */
00109 /*     .. */
00110 
00111 /*  Purpose */
00112 /*  ======= */
00113 
00114 /*  CCHKGK tests CGGBAK, a routine for backward balancing  of */
00115 /*  a matrix pair (A, B). */
00116 
00117 /*  Arguments */
00118 /*  ========= */
00119 
00120 /*  NIN     (input) INTEGER */
00121 /*          The logical unit number for input.  NIN > 0. */
00122 
00123 /*  NOUT    (input) INTEGER */
00124 /*          The logical unit number for output.  NOUT > 0. */
00125 
00126 /*  ===================================================================== */
00127 
00128 /*     .. Parameters .. */
00129 /*     .. */
00130 /*     .. Local Scalars .. */
00131 /*     .. */
00132 /*     .. Local Arrays .. */
00133 /*     .. */
00134 /*     .. External Functions .. */
00135 /*     .. */
00136 /*     .. External Subroutines .. */
00137 /*     .. */
00138 /*     .. Intrinsic Functions .. */
00139 /*     .. */
00140 /*     .. Statement Functions .. */
00141 /*     .. */
00142 /*     .. Statement Function definitions .. */
00143 /*     .. */
00144 /*     .. Executable Statements .. */
00145 
00146     lmax[0] = 0;
00147     lmax[1] = 0;
00148     lmax[2] = 0;
00149     lmax[3] = 0;
00150     ninfo = 0;
00151     knt = 0;
00152     rmax = 0.f;
00153 
00154     eps = slamch_("Precision");
00155 
00156 L10:
00157     io___6.ciunit = *nin;
00158     s_rsle(&io___6);
00159     do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00160     do_lio(&c__3, &c__1, (char *)&m, (ftnlen)sizeof(integer));
00161     e_rsle();
00162     if (n == 0) {
00163         goto L100;
00164     }
00165 
00166     i__1 = n;
00167     for (i__ = 1; i__ <= i__1; ++i__) {
00168         io___10.ciunit = *nin;
00169         s_rsle(&io___10);
00170         i__2 = n;
00171         for (j = 1; j <= i__2; ++j) {
00172             do_lio(&c__6, &c__1, (char *)&a[i__ + j * 50 - 51], (ftnlen)
00173                     sizeof(complex));
00174         }
00175         e_rsle();
00176 /* L20: */
00177     }
00178 
00179     i__1 = n;
00180     for (i__ = 1; i__ <= i__1; ++i__) {
00181         io___13.ciunit = *nin;
00182         s_rsle(&io___13);
00183         i__2 = n;
00184         for (j = 1; j <= i__2; ++j) {
00185             do_lio(&c__6, &c__1, (char *)&b[i__ + j * 50 - 51], (ftnlen)
00186                     sizeof(complex));
00187         }
00188         e_rsle();
00189 /* L30: */
00190     }
00191 
00192     i__1 = n;
00193     for (i__ = 1; i__ <= i__1; ++i__) {
00194         io___15.ciunit = *nin;
00195         s_rsle(&io___15);
00196         i__2 = m;
00197         for (j = 1; j <= i__2; ++j) {
00198             do_lio(&c__6, &c__1, (char *)&vl[i__ + j * 50 - 51], (ftnlen)
00199                     sizeof(complex));
00200         }
00201         e_rsle();
00202 /* L40: */
00203     }
00204 
00205     i__1 = n;
00206     for (i__ = 1; i__ <= i__1; ++i__) {
00207         io___17.ciunit = *nin;
00208         s_rsle(&io___17);
00209         i__2 = m;
00210         for (j = 1; j <= i__2; ++j) {
00211             do_lio(&c__6, &c__1, (char *)&vr[i__ + j * 50 - 51], (ftnlen)
00212                     sizeof(complex));
00213         }
00214         e_rsle();
00215 /* L50: */
00216     }
00217 
00218     ++knt;
00219 
00220     anorm = clange_("M", &n, &n, a, &c__50, rwork);
00221     bnorm = clange_("M", &n, &n, b, &c__50, rwork);
00222 
00223     clacpy_("FULL", &n, &n, a, &c__50, af, &c__50);
00224     clacpy_("FULL", &n, &n, b, &c__50, bf, &c__50);
00225 
00226     cggbal_("B", &n, a, &c__50, b, &c__50, &ilo, &ihi, lscale, rscale, rwork, 
00227             &info);
00228     if (info != 0) {
00229         ++ninfo;
00230         lmax[0] = knt;
00231     }
00232 
00233     clacpy_("FULL", &n, &m, vl, &c__50, vlf, &c__50);
00234     clacpy_("FULL", &n, &m, vr, &c__50, vrf, &c__50);
00235 
00236     cggbak_("B", "L", &n, &ilo, &ihi, lscale, rscale, &m, vl, &c__50, &info);
00237     if (info != 0) {
00238         ++ninfo;
00239         lmax[1] = knt;
00240     }
00241 
00242     cggbak_("B", "R", &n, &ilo, &ihi, lscale, rscale, &m, vr, &c__50, &info);
00243     if (info != 0) {
00244         ++ninfo;
00245         lmax[2] = knt;
00246     }
00247 
00248 /*     Test of CGGBAK */
00249 
00250 /*     Check tilde(VL)'*A*tilde(VR) - VL'*tilde(A)*VR */
00251 /*     where tilde(A) denotes the transformed matrix. */
00252 
00253     cgemm_("N", "N", &n, &m, &n, &c_b2, af, &c__50, vr, &c__50, &c_b1, work, &
00254             c__50);
00255     cgemm_("C", "N", &m, &m, &n, &c_b2, vl, &c__50, work, &c__50, &c_b1, e, &
00256             c__50);
00257 
00258     cgemm_("N", "N", &n, &m, &n, &c_b2, a, &c__50, vrf, &c__50, &c_b1, work, &
00259             c__50);
00260     cgemm_("C", "N", &m, &m, &n, &c_b2, vlf, &c__50, work, &c__50, &c_b1, f, &
00261             c__50);
00262 
00263     vmax = 0.f;
00264     i__1 = m;
00265     for (j = 1; j <= i__1; ++j) {
00266         i__2 = m;
00267         for (i__ = 1; i__ <= i__2; ++i__) {
00268             i__3 = i__ + j * 50 - 51;
00269             i__4 = i__ + j * 50 - 51;
00270             q__2.r = e[i__3].r - f[i__4].r, q__2.i = e[i__3].i - f[i__4].i;
00271             q__1.r = q__2.r, q__1.i = q__2.i;
00272 /* Computing MAX */
00273             r__3 = vmax, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00274                     q__1), dabs(r__2));
00275             vmax = dmax(r__3,r__4);
00276 /* L60: */
00277         }
00278 /* L70: */
00279     }
00280     vmax /= eps * dmax(anorm,bnorm);
00281     if (vmax > rmax) {
00282         lmax[3] = knt;
00283         rmax = vmax;
00284     }
00285 
00286 /*     Check tilde(VL)'*B*tilde(VR) - VL'*tilde(B)*VR */
00287 
00288     cgemm_("N", "N", &n, &m, &n, &c_b2, bf, &c__50, vr, &c__50, &c_b1, work, &
00289             c__50);
00290     cgemm_("C", "N", &m, &m, &n, &c_b2, vl, &c__50, work, &c__50, &c_b1, e, &
00291             c__50);
00292 
00293     cgemm_("n", "n", &n, &m, &n, &c_b2, b, &c__50, vrf, &c__50, &c_b1, work, &
00294             c__50);
00295     cgemm_("C", "N", &m, &m, &n, &c_b2, vlf, &c__50, work, &c__50, &c_b1, f, &
00296             c__50);
00297 
00298     vmax = 0.f;
00299     i__1 = m;
00300     for (j = 1; j <= i__1; ++j) {
00301         i__2 = m;
00302         for (i__ = 1; i__ <= i__2; ++i__) {
00303             i__3 = i__ + j * 50 - 51;
00304             i__4 = i__ + j * 50 - 51;
00305             q__2.r = e[i__3].r - f[i__4].r, q__2.i = e[i__3].i - f[i__4].i;
00306             q__1.r = q__2.r, q__1.i = q__2.i;
00307 /* Computing MAX */
00308             r__3 = vmax, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00309                     q__1), dabs(r__2));
00310             vmax = dmax(r__3,r__4);
00311 /* L80: */
00312         }
00313 /* L90: */
00314     }
00315     vmax /= eps * dmax(anorm,bnorm);
00316     if (vmax > rmax) {
00317         lmax[3] = knt;
00318         rmax = vmax;
00319     }
00320 
00321     goto L10;
00322 
00323 L100:
00324 
00325     io___35.ciunit = *nout;
00326     s_wsfe(&io___35);
00327     e_wsfe();
00328 
00329     io___36.ciunit = *nout;
00330     s_wsfe(&io___36);
00331     do_fio(&c__1, (char *)&rmax, (ftnlen)sizeof(real));
00332     e_wsfe();
00333     io___37.ciunit = *nout;
00334     s_wsfe(&io___37);
00335     do_fio(&c__1, (char *)&lmax[0], (ftnlen)sizeof(integer));
00336     e_wsfe();
00337     io___38.ciunit = *nout;
00338     s_wsfe(&io___38);
00339     do_fio(&c__1, (char *)&lmax[1], (ftnlen)sizeof(integer));
00340     e_wsfe();
00341     io___39.ciunit = *nout;
00342     s_wsfe(&io___39);
00343     do_fio(&c__1, (char *)&lmax[2], (ftnlen)sizeof(integer));
00344     e_wsfe();
00345     io___40.ciunit = *nout;
00346     s_wsfe(&io___40);
00347     do_fio(&c__1, (char *)&lmax[3], (ftnlen)sizeof(integer));
00348     e_wsfe();
00349     io___41.ciunit = *nout;
00350     s_wsfe(&io___41);
00351     do_fio(&c__1, (char *)&ninfo, (ftnlen)sizeof(integer));
00352     e_wsfe();
00353     io___42.ciunit = *nout;
00354     s_wsfe(&io___42);
00355     do_fio(&c__1, (char *)&knt, (ftnlen)sizeof(integer));
00356     e_wsfe();
00357 
00358     return 0;
00359 
00360 /*     End of CCHKGK */
00361 
00362 } /* cchkgk_ */


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