cchkgl.c
Go to the documentation of this file.
00001 /* cchkgl.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__6 = 6;
00021 static integer c__4 = 4;
00022 static integer c__20 = 20;
00023 
00024 /* Subroutine */ int cchkgl_(integer *nin, integer *nout)
00025 {
00026     /* Format strings */
00027     static char fmt_9999[] = "(\002 .. test output of CGGBAL .. \002)";
00028     static char fmt_9998[] = "(\002 ratio of largest test error             "
00029             " = \002,e12.3)";
00030     static char fmt_9997[] = "(\002 example number where info is not zero   "
00031             " = \002,i4)";
00032     static char fmt_9996[] = "(\002 example number where ILO or IHI is wrong"
00033             " = \002,i4)";
00034     static char fmt_9995[] = "(\002 example number having largest error     "
00035             " = \002,i4)";
00036     static char fmt_9994[] = "(\002 number of examples where info is not 0  "
00037             " = \002,i4)";
00038     static char fmt_9993[] = "(\002 total number of examples tested         "
00039             " = \002,i4)";
00040 
00041     /* System generated locals */
00042     integer i__1, i__2, i__3, i__4;
00043     real r__1, r__2, r__3;
00044     complex q__1;
00045 
00046     /* Builtin functions */
00047     integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
00048             e_rsle(void);
00049     double c_abs(complex *);
00050     integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
00051 
00052     /* Local variables */
00053     complex a[400]      /* was [20][20] */, b[400]      /* was [20][20] */;
00054     integer i__, j, n;
00055     complex ain[400]    /* was [20][20] */, bin[400]    /* was [20][20] */;
00056     integer ihi, ilo;
00057     real eps;
00058     integer knt, info, lmax[3];
00059     real rmax, vmax, work[120];
00060     integer ihiin, ninfo, iloin;
00061     real anorm, bnorm;
00062     extern /* Subroutine */ int cggbal_(char *, integer *, complex *, integer 
00063             *, complex *, integer *, integer *, integer *, real *, real *, 
00064             real *, integer *);
00065     extern doublereal clange_(char *, integer *, integer *, complex *, 
00066             integer *, real *);
00067     real lscale[20];
00068     extern doublereal slamch_(char *);
00069     real rscale[20], lsclin[20], rsclin[20];
00070 
00071     /* Fortran I/O blocks */
00072     static cilist io___6 = { 0, 0, 0, 0, 0 };
00073     static cilist io___9 = { 0, 0, 0, 0, 0 };
00074     static cilist io___12 = { 0, 0, 0, 0, 0 };
00075     static cilist io___14 = { 0, 0, 0, 0, 0 };
00076     static cilist io___17 = { 0, 0, 0, 0, 0 };
00077     static cilist io___19 = { 0, 0, 0, 0, 0 };
00078     static cilist io___21 = { 0, 0, 0, 0, 0 };
00079     static cilist io___23 = { 0, 0, 0, 0, 0 };
00080     static cilist io___34 = { 0, 0, 0, fmt_9999, 0 };
00081     static cilist io___35 = { 0, 0, 0, fmt_9998, 0 };
00082     static cilist io___36 = { 0, 0, 0, fmt_9997, 0 };
00083     static cilist io___37 = { 0, 0, 0, fmt_9996, 0 };
00084     static cilist io___38 = { 0, 0, 0, fmt_9995, 0 };
00085     static cilist io___39 = { 0, 0, 0, fmt_9994, 0 };
00086     static cilist io___40 = { 0, 0, 0, fmt_9993, 0 };
00087 
00088 
00089 
00090 /*  -- LAPACK test routine (version 3.1) -- */
00091 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00092 /*     November 2006 */
00093 
00094 /*     .. Scalar Arguments .. */
00095 /*     .. */
00096 
00097 /*  Purpose */
00098 /*  ======= */
00099 
00100 /*  CCHKGL tests CGGBAL, a routine for balancing a matrix pair (A, B). */
00101 
00102 /*  Arguments */
00103 /*  ========= */
00104 
00105 /*  NIN     (input) INTEGER */
00106 /*          The logical unit number for input.  NIN > 0. */
00107 
00108 /*  NOUT    (input) INTEGER */
00109 /*          The logical unit number for output.  NOUT > 0. */
00110 
00111 /*  ===================================================================== */
00112 
00113 /*     .. Parameters .. */
00114 /*     .. */
00115 /*     .. Local Scalars .. */
00116 /*     .. */
00117 /*     .. Local Arrays .. */
00118 /*     .. */
00119 /*     .. External Functions .. */
00120 /*     .. */
00121 /*     .. External Subroutines .. */
00122 /*     .. */
00123 /*     .. Intrinsic Functions .. */
00124 /*     .. */
00125 /*     .. Executable Statements .. */
00126 
00127     lmax[0] = 0;
00128     lmax[1] = 0;
00129     lmax[2] = 0;
00130     ninfo = 0;
00131     knt = 0;
00132     rmax = 0.f;
00133 
00134     eps = slamch_("Precision");
00135 
00136 L10:
00137 
00138     io___6.ciunit = *nin;
00139     s_rsle(&io___6);
00140     do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00141     e_rsle();
00142     if (n == 0) {
00143         goto L90;
00144     }
00145     i__1 = n;
00146     for (i__ = 1; i__ <= i__1; ++i__) {
00147         io___9.ciunit = *nin;
00148         s_rsle(&io___9);
00149         i__2 = n;
00150         for (j = 1; j <= i__2; ++j) {
00151             do_lio(&c__6, &c__1, (char *)&a[i__ + j * 20 - 21], (ftnlen)
00152                     sizeof(complex));
00153         }
00154         e_rsle();
00155 /* L20: */
00156     }
00157 
00158     i__1 = n;
00159     for (i__ = 1; i__ <= i__1; ++i__) {
00160         io___12.ciunit = *nin;
00161         s_rsle(&io___12);
00162         i__2 = n;
00163         for (j = 1; j <= i__2; ++j) {
00164             do_lio(&c__6, &c__1, (char *)&b[i__ + j * 20 - 21], (ftnlen)
00165                     sizeof(complex));
00166         }
00167         e_rsle();
00168 /* L30: */
00169     }
00170 
00171     io___14.ciunit = *nin;
00172     s_rsle(&io___14);
00173     do_lio(&c__3, &c__1, (char *)&iloin, (ftnlen)sizeof(integer));
00174     do_lio(&c__3, &c__1, (char *)&ihiin, (ftnlen)sizeof(integer));
00175     e_rsle();
00176     i__1 = n;
00177     for (i__ = 1; i__ <= i__1; ++i__) {
00178         io___17.ciunit = *nin;
00179         s_rsle(&io___17);
00180         i__2 = n;
00181         for (j = 1; j <= i__2; ++j) {
00182             do_lio(&c__6, &c__1, (char *)&ain[i__ + j * 20 - 21], (ftnlen)
00183                     sizeof(complex));
00184         }
00185         e_rsle();
00186 /* L40: */
00187     }
00188     i__1 = n;
00189     for (i__ = 1; i__ <= i__1; ++i__) {
00190         io___19.ciunit = *nin;
00191         s_rsle(&io___19);
00192         i__2 = n;
00193         for (j = 1; j <= i__2; ++j) {
00194             do_lio(&c__6, &c__1, (char *)&bin[i__ + j * 20 - 21], (ftnlen)
00195                     sizeof(complex));
00196         }
00197         e_rsle();
00198 /* L50: */
00199     }
00200 
00201     io___21.ciunit = *nin;
00202     s_rsle(&io___21);
00203     i__1 = n;
00204     for (i__ = 1; i__ <= i__1; ++i__) {
00205         do_lio(&c__4, &c__1, (char *)&lsclin[i__ - 1], (ftnlen)sizeof(real));
00206     }
00207     e_rsle();
00208     io___23.ciunit = *nin;
00209     s_rsle(&io___23);
00210     i__1 = n;
00211     for (i__ = 1; i__ <= i__1; ++i__) {
00212         do_lio(&c__4, &c__1, (char *)&rsclin[i__ - 1], (ftnlen)sizeof(real));
00213     }
00214     e_rsle();
00215 
00216     anorm = clange_("M", &n, &n, a, &c__20, work);
00217     bnorm = clange_("M", &n, &n, b, &c__20, work);
00218 
00219     ++knt;
00220 
00221     cggbal_("B", &n, a, &c__20, b, &c__20, &ilo, &ihi, lscale, rscale, work, &
00222             info);
00223 
00224     if (info != 0) {
00225         ++ninfo;
00226         lmax[0] = knt;
00227     }
00228 
00229     if (ilo != iloin || ihi != ihiin) {
00230         ++ninfo;
00231         lmax[1] = knt;
00232     }
00233 
00234     vmax = 0.f;
00235     i__1 = n;
00236     for (i__ = 1; i__ <= i__1; ++i__) {
00237         i__2 = n;
00238         for (j = 1; j <= i__2; ++j) {
00239 /* Computing MAX */
00240             i__3 = i__ + j * 20 - 21;
00241             i__4 = i__ + j * 20 - 21;
00242             q__1.r = a[i__3].r - ain[i__4].r, q__1.i = a[i__3].i - ain[i__4]
00243                     .i;
00244             r__1 = vmax, r__2 = c_abs(&q__1);
00245             vmax = dmax(r__1,r__2);
00246 /* Computing MAX */
00247             i__3 = i__ + j * 20 - 21;
00248             i__4 = i__ + j * 20 - 21;
00249             q__1.r = b[i__3].r - bin[i__4].r, q__1.i = b[i__3].i - bin[i__4]
00250                     .i;
00251             r__1 = vmax, r__2 = c_abs(&q__1);
00252             vmax = dmax(r__1,r__2);
00253 /* L60: */
00254         }
00255 /* L70: */
00256     }
00257 
00258     i__1 = n;
00259     for (i__ = 1; i__ <= i__1; ++i__) {
00260 /* Computing MAX */
00261         r__2 = vmax, r__3 = (r__1 = lscale[i__ - 1] - lsclin[i__ - 1], dabs(
00262                 r__1));
00263         vmax = dmax(r__2,r__3);
00264 /* Computing MAX */
00265         r__2 = vmax, r__3 = (r__1 = rscale[i__ - 1] - rsclin[i__ - 1], dabs(
00266                 r__1));
00267         vmax = dmax(r__2,r__3);
00268 /* L80: */
00269     }
00270 
00271     vmax /= eps * dmax(anorm,bnorm);
00272 
00273     if (vmax > rmax) {
00274         lmax[2] = knt;
00275         rmax = vmax;
00276     }
00277 
00278     goto L10;
00279 
00280 L90:
00281 
00282     io___34.ciunit = *nout;
00283     s_wsfe(&io___34);
00284     e_wsfe();
00285 
00286     io___35.ciunit = *nout;
00287     s_wsfe(&io___35);
00288     do_fio(&c__1, (char *)&rmax, (ftnlen)sizeof(real));
00289     e_wsfe();
00290     io___36.ciunit = *nout;
00291     s_wsfe(&io___36);
00292     do_fio(&c__1, (char *)&lmax[0], (ftnlen)sizeof(integer));
00293     e_wsfe();
00294     io___37.ciunit = *nout;
00295     s_wsfe(&io___37);
00296     do_fio(&c__1, (char *)&lmax[1], (ftnlen)sizeof(integer));
00297     e_wsfe();
00298     io___38.ciunit = *nout;
00299     s_wsfe(&io___38);
00300     do_fio(&c__1, (char *)&lmax[2], (ftnlen)sizeof(integer));
00301     e_wsfe();
00302     io___39.ciunit = *nout;
00303     s_wsfe(&io___39);
00304     do_fio(&c__1, (char *)&ninfo, (ftnlen)sizeof(integer));
00305     e_wsfe();
00306     io___40.ciunit = *nout;
00307     s_wsfe(&io___40);
00308     do_fio(&c__1, (char *)&knt, (ftnlen)sizeof(integer));
00309     e_wsfe();
00310 
00311     return 0;
00312 
00313 /*     End of CCHKGL */
00314 
00315 } /* cchkgl_ */


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