00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
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 int cchkgl_(integer *nin, integer *nout)
00025 {
00026
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
00042 integer i__1, i__2, i__3, i__4;
00043 real r__1, r__2, r__3;
00044 complex q__1;
00045
00046
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
00053 complex a[400] , b[400] ;
00054 integer i__, j, n;
00055 complex ain[400] , bin[400] ;
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 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
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
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
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
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
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
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
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
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
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
00254 }
00255
00256 }
00257
00258 i__1 = n;
00259 for (i__ = 1; i__ <= i__1; ++i__) {
00260
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
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
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
00314
00315 }