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


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