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__7 = 7;
00021 static integer c__5 = 5;
00022 static integer c__20 = 20;
00023
00024 int zchkgl_(integer *nin, integer *nout)
00025 {
00026
00027 static char fmt_9999[] = "(\002 .. test output of ZGGBAL .. \002)";
00028 static char fmt_9998[] = "(\002 ratio of largest test error "
00029 " = \002,d12.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 doublereal d__1, d__2, d__3;
00044 doublecomplex z__1;
00045
00046
00047 integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
00048 e_rsle(void);
00049 double z_abs(doublecomplex *);
00050 integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
00051
00052
00053 doublecomplex a[400] , b[400]
00054 ;
00055 integer i__, j, n;
00056 doublecomplex ain[400] , bin[400]
00057 ;
00058 integer ihi, ilo;
00059 doublereal eps;
00060 integer knt, info, lmax[3];
00061 doublereal rmax, vmax, work[120];
00062 integer ihiin, ninfo, iloin;
00063 doublereal anorm, bnorm;
00064 extern doublereal dlamch_(char *);
00065 doublereal lscale[20];
00066 extern int zggbal_(char *, integer *, doublecomplex *,
00067 integer *, doublecomplex *, integer *, integer *, integer *,
00068 doublereal *, doublereal *, doublereal *, integer *);
00069 doublereal rscale[20];
00070 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00071 integer *, doublereal *);
00072 doublereal lsclin[20], rsclin[20];
00073
00074
00075 static cilist io___6 = { 0, 0, 0, 0, 0 };
00076 static cilist io___9 = { 0, 0, 0, 0, 0 };
00077 static cilist io___12 = { 0, 0, 0, 0, 0 };
00078 static cilist io___14 = { 0, 0, 0, 0, 0 };
00079 static cilist io___17 = { 0, 0, 0, 0, 0 };
00080 static cilist io___19 = { 0, 0, 0, 0, 0 };
00081 static cilist io___21 = { 0, 0, 0, 0, 0 };
00082 static cilist io___23 = { 0, 0, 0, 0, 0 };
00083 static cilist io___34 = { 0, 0, 0, fmt_9999, 0 };
00084 static cilist io___35 = { 0, 0, 0, fmt_9998, 0 };
00085 static cilist io___36 = { 0, 0, 0, fmt_9997, 0 };
00086 static cilist io___37 = { 0, 0, 0, fmt_9996, 0 };
00087 static cilist io___38 = { 0, 0, 0, fmt_9995, 0 };
00088 static cilist io___39 = { 0, 0, 0, fmt_9994, 0 };
00089 static cilist io___40 = { 0, 0, 0, fmt_9993, 0 };
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
00128
00129
00130 lmax[0] = 0;
00131 lmax[1] = 0;
00132 lmax[2] = 0;
00133 ninfo = 0;
00134 knt = 0;
00135 rmax = 0.;
00136
00137 eps = dlamch_("Precision");
00138
00139 L10:
00140
00141 io___6.ciunit = *nin;
00142 s_rsle(&io___6);
00143 do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00144 e_rsle();
00145 if (n == 0) {
00146 goto L90;
00147 }
00148 i__1 = n;
00149 for (i__ = 1; i__ <= i__1; ++i__) {
00150 io___9.ciunit = *nin;
00151 s_rsle(&io___9);
00152 i__2 = n;
00153 for (j = 1; j <= i__2; ++j) {
00154 do_lio(&c__7, &c__1, (char *)&a[i__ + j * 20 - 21], (ftnlen)
00155 sizeof(doublecomplex));
00156 }
00157 e_rsle();
00158
00159 }
00160
00161 i__1 = n;
00162 for (i__ = 1; i__ <= i__1; ++i__) {
00163 io___12.ciunit = *nin;
00164 s_rsle(&io___12);
00165 i__2 = n;
00166 for (j = 1; j <= i__2; ++j) {
00167 do_lio(&c__7, &c__1, (char *)&b[i__ + j * 20 - 21], (ftnlen)
00168 sizeof(doublecomplex));
00169 }
00170 e_rsle();
00171
00172 }
00173
00174 io___14.ciunit = *nin;
00175 s_rsle(&io___14);
00176 do_lio(&c__3, &c__1, (char *)&iloin, (ftnlen)sizeof(integer));
00177 do_lio(&c__3, &c__1, (char *)&ihiin, (ftnlen)sizeof(integer));
00178 e_rsle();
00179 i__1 = n;
00180 for (i__ = 1; i__ <= i__1; ++i__) {
00181 io___17.ciunit = *nin;
00182 s_rsle(&io___17);
00183 i__2 = n;
00184 for (j = 1; j <= i__2; ++j) {
00185 do_lio(&c__7, &c__1, (char *)&ain[i__ + j * 20 - 21], (ftnlen)
00186 sizeof(doublecomplex));
00187 }
00188 e_rsle();
00189
00190 }
00191 i__1 = n;
00192 for (i__ = 1; i__ <= i__1; ++i__) {
00193 io___19.ciunit = *nin;
00194 s_rsle(&io___19);
00195 i__2 = n;
00196 for (j = 1; j <= i__2; ++j) {
00197 do_lio(&c__7, &c__1, (char *)&bin[i__ + j * 20 - 21], (ftnlen)
00198 sizeof(doublecomplex));
00199 }
00200 e_rsle();
00201
00202 }
00203
00204 io___21.ciunit = *nin;
00205 s_rsle(&io___21);
00206 i__1 = n;
00207 for (i__ = 1; i__ <= i__1; ++i__) {
00208 do_lio(&c__5, &c__1, (char *)&lsclin[i__ - 1], (ftnlen)sizeof(
00209 doublereal));
00210 }
00211 e_rsle();
00212 io___23.ciunit = *nin;
00213 s_rsle(&io___23);
00214 i__1 = n;
00215 for (i__ = 1; i__ <= i__1; ++i__) {
00216 do_lio(&c__5, &c__1, (char *)&rsclin[i__ - 1], (ftnlen)sizeof(
00217 doublereal));
00218 }
00219 e_rsle();
00220
00221 anorm = zlange_("M", &n, &n, a, &c__20, work);
00222 bnorm = zlange_("M", &n, &n, b, &c__20, work);
00223
00224 ++knt;
00225
00226 zggbal_("B", &n, a, &c__20, b, &c__20, &ilo, &ihi, lscale, rscale, work, &
00227 info);
00228
00229 if (info != 0) {
00230 ++ninfo;
00231 lmax[0] = knt;
00232 }
00233
00234 if (ilo != iloin || ihi != ihiin) {
00235 ++ninfo;
00236 lmax[1] = knt;
00237 }
00238
00239 vmax = 0.;
00240 i__1 = n;
00241 for (i__ = 1; i__ <= i__1; ++i__) {
00242 i__2 = n;
00243 for (j = 1; j <= i__2; ++j) {
00244
00245 i__3 = i__ + j * 20 - 21;
00246 i__4 = i__ + j * 20 - 21;
00247 z__1.r = a[i__3].r - ain[i__4].r, z__1.i = a[i__3].i - ain[i__4]
00248 .i;
00249 d__1 = vmax, d__2 = z_abs(&z__1);
00250 vmax = max(d__1,d__2);
00251
00252 i__3 = i__ + j * 20 - 21;
00253 i__4 = i__ + j * 20 - 21;
00254 z__1.r = b[i__3].r - bin[i__4].r, z__1.i = b[i__3].i - bin[i__4]
00255 .i;
00256 d__1 = vmax, d__2 = z_abs(&z__1);
00257 vmax = max(d__1,d__2);
00258
00259 }
00260
00261 }
00262
00263 i__1 = n;
00264 for (i__ = 1; i__ <= i__1; ++i__) {
00265
00266 d__2 = vmax, d__3 = (d__1 = lscale[i__ - 1] - lsclin[i__ - 1], abs(
00267 d__1));
00268 vmax = max(d__2,d__3);
00269
00270 d__2 = vmax, d__3 = (d__1 = rscale[i__ - 1] - rsclin[i__ - 1], abs(
00271 d__1));
00272 vmax = max(d__2,d__3);
00273
00274 }
00275
00276 vmax /= eps * max(anorm,bnorm);
00277
00278 if (vmax > rmax) {
00279 lmax[2] = knt;
00280 rmax = vmax;
00281 }
00282
00283 goto L10;
00284
00285 L90:
00286
00287 io___34.ciunit = *nout;
00288 s_wsfe(&io___34);
00289 e_wsfe();
00290
00291 io___35.ciunit = *nout;
00292 s_wsfe(&io___35);
00293 do_fio(&c__1, (char *)&rmax, (ftnlen)sizeof(doublereal));
00294 e_wsfe();
00295 io___36.ciunit = *nout;
00296 s_wsfe(&io___36);
00297 do_fio(&c__1, (char *)&lmax[0], (ftnlen)sizeof(integer));
00298 e_wsfe();
00299 io___37.ciunit = *nout;
00300 s_wsfe(&io___37);
00301 do_fio(&c__1, (char *)&lmax[1], (ftnlen)sizeof(integer));
00302 e_wsfe();
00303 io___38.ciunit = *nout;
00304 s_wsfe(&io___38);
00305 do_fio(&c__1, (char *)&lmax[2], (ftnlen)sizeof(integer));
00306 e_wsfe();
00307 io___39.ciunit = *nout;
00308 s_wsfe(&io___39);
00309 do_fio(&c__1, (char *)&ninfo, (ftnlen)sizeof(integer));
00310 e_wsfe();
00311 io___40.ciunit = *nout;
00312 s_wsfe(&io___40);
00313 do_fio(&c__1, (char *)&knt, (ftnlen)sizeof(integer));
00314 e_wsfe();
00315
00316 return 0;
00317
00318
00319
00320 }