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


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