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 cchkbl_(integer *nin, integer *nout)
00025 {
00026
00027 static char fmt_9999[] = "(1x,\002.. test output of CGEBAL .. \002)";
00028 static char fmt_9998[] = "(1x,\002value of largest test error "
00029 " = \002,e12.3)";
00030 static char fmt_9997[] = "(1x,\002example number where info is not zero "
00031 " = \002,i4)";
00032 static char fmt_9996[] = "(1x,\002example number where ILO or IHI wrong "
00033 " = \002,i4)";
00034 static char fmt_9995[] = "(1x,\002example number having largest error "
00035 " = \002,i4)";
00036 static char fmt_9994[] = "(1x,\002number of examples where info is not 0"
00037 " = \002,i4)";
00038 static char fmt_9993[] = "(1x,\002total 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, r__4, r__5, r__6;
00044 complex q__1, q__2;
00045
00046
00047 integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
00048 e_rsle(void);
00049 double r_imag(complex *);
00050 integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
00051
00052
00053 complex a[400] ;
00054 integer i__, j, n;
00055 complex ain[400] ;
00056 integer ihi, ilo, knt, info, lmax[3];
00057 real meps, temp, rmax, vmax, scale[20];
00058 integer ihiin, ninfo, iloin;
00059 real anorm, sfmin, dummy[1];
00060 extern int cgebal_(char *, integer *, complex *, integer
00061 *, integer *, integer *, real *, integer *);
00062 extern doublereal clange_(char *, integer *, integer *, complex *,
00063 integer *, real *), slamch_(char *);
00064 real scalin[20];
00065
00066
00067 static cilist io___8 = { 0, 0, 0, 0, 0 };
00068 static cilist io___11 = { 0, 0, 0, 0, 0 };
00069 static cilist io___14 = { 0, 0, 0, 0, 0 };
00070 static cilist io___17 = { 0, 0, 0, 0, 0 };
00071 static cilist io___19 = { 0, 0, 0, 0, 0 };
00072 static cilist io___28 = { 0, 0, 0, fmt_9999, 0 };
00073 static cilist io___29 = { 0, 0, 0, fmt_9998, 0 };
00074 static cilist io___30 = { 0, 0, 0, fmt_9997, 0 };
00075 static cilist io___31 = { 0, 0, 0, fmt_9996, 0 };
00076 static cilist io___32 = { 0, 0, 0, fmt_9995, 0 };
00077 static cilist io___33 = { 0, 0, 0, fmt_9994, 0 };
00078 static cilist io___34 = { 0, 0, 0, fmt_9993, 0 };
00079
00080
00081
00082
00083
00084
00085
00086
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 lmax[0] = 0;
00125 lmax[1] = 0;
00126 lmax[2] = 0;
00127 ninfo = 0;
00128 knt = 0;
00129 rmax = 0.f;
00130 vmax = 0.f;
00131 sfmin = slamch_("S");
00132 meps = slamch_("E");
00133
00134 L10:
00135
00136 io___8.ciunit = *nin;
00137 s_rsle(&io___8);
00138 do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00139 e_rsle();
00140 if (n == 0) {
00141 goto L70;
00142 }
00143 i__1 = n;
00144 for (i__ = 1; i__ <= i__1; ++i__) {
00145 io___11.ciunit = *nin;
00146 s_rsle(&io___11);
00147 i__2 = n;
00148 for (j = 1; j <= i__2; ++j) {
00149 do_lio(&c__6, &c__1, (char *)&a[i__ + j * 20 - 21], (ftnlen)
00150 sizeof(complex));
00151 }
00152 e_rsle();
00153
00154 }
00155
00156 io___14.ciunit = *nin;
00157 s_rsle(&io___14);
00158 do_lio(&c__3, &c__1, (char *)&iloin, (ftnlen)sizeof(integer));
00159 do_lio(&c__3, &c__1, (char *)&ihiin, (ftnlen)sizeof(integer));
00160 e_rsle();
00161 i__1 = n;
00162 for (i__ = 1; i__ <= i__1; ++i__) {
00163 io___17.ciunit = *nin;
00164 s_rsle(&io___17);
00165 i__2 = n;
00166 for (j = 1; j <= i__2; ++j) {
00167 do_lio(&c__6, &c__1, (char *)&ain[i__ + j * 20 - 21], (ftnlen)
00168 sizeof(complex));
00169 }
00170 e_rsle();
00171
00172 }
00173 io___19.ciunit = *nin;
00174 s_rsle(&io___19);
00175 i__1 = n;
00176 for (i__ = 1; i__ <= i__1; ++i__) {
00177 do_lio(&c__4, &c__1, (char *)&scalin[i__ - 1], (ftnlen)sizeof(real));
00178 }
00179 e_rsle();
00180
00181 anorm = clange_("M", &n, &n, a, &c__20, dummy);
00182 ++knt;
00183 cgebal_("B", &n, a, &c__20, &ilo, &ihi, scale, &info);
00184
00185 if (info != 0) {
00186 ++ninfo;
00187 lmax[0] = knt;
00188 }
00189
00190 if (ilo != iloin || ihi != ihiin) {
00191 ++ninfo;
00192 lmax[1] = knt;
00193 }
00194
00195 i__1 = n;
00196 for (i__ = 1; i__ <= i__1; ++i__) {
00197 i__2 = n;
00198 for (j = 1; j <= i__2; ++j) {
00199
00200 i__3 = i__ + j * 20 - 21;
00201 i__4 = i__ + j * 20 - 21;
00202 r__5 = (r__1 = a[i__3].r, dabs(r__1)) + (r__2 = r_imag(&a[i__ + j
00203 * 20 - 21]), dabs(r__2)), r__6 = (r__3 = ain[i__4].r,
00204 dabs(r__3)) + (r__4 = r_imag(&ain[i__ + j * 20 - 21]),
00205 dabs(r__4));
00206 temp = dmax(r__5,r__6);
00207 temp = dmax(temp,sfmin);
00208 i__3 = i__ + j * 20 - 21;
00209 i__4 = i__ + j * 20 - 21;
00210 q__2.r = a[i__3].r - ain[i__4].r, q__2.i = a[i__3].i - ain[i__4]
00211 .i;
00212 q__1.r = q__2.r, q__1.i = q__2.i;
00213
00214 r__3 = vmax, r__4 = ((r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(
00215 &q__1), dabs(r__2))) / temp;
00216 vmax = dmax(r__3,r__4);
00217
00218 }
00219
00220 }
00221
00222 i__1 = n;
00223 for (i__ = 1; i__ <= i__1; ++i__) {
00224
00225 r__1 = scale[i__ - 1], r__2 = scalin[i__ - 1];
00226 temp = dmax(r__1,r__2);
00227 temp = dmax(temp,sfmin);
00228
00229 r__2 = vmax, r__3 = (r__1 = scale[i__ - 1] - scalin[i__ - 1], dabs(
00230 r__1)) / temp;
00231 vmax = dmax(r__2,r__3);
00232
00233 }
00234
00235 if (vmax > rmax) {
00236 lmax[2] = knt;
00237 rmax = vmax;
00238 }
00239
00240 goto L10;
00241
00242 L70:
00243
00244 io___28.ciunit = *nout;
00245 s_wsfe(&io___28);
00246 e_wsfe();
00247
00248 io___29.ciunit = *nout;
00249 s_wsfe(&io___29);
00250 do_fio(&c__1, (char *)&rmax, (ftnlen)sizeof(real));
00251 e_wsfe();
00252 io___30.ciunit = *nout;
00253 s_wsfe(&io___30);
00254 do_fio(&c__1, (char *)&lmax[0], (ftnlen)sizeof(integer));
00255 e_wsfe();
00256 io___31.ciunit = *nout;
00257 s_wsfe(&io___31);
00258 do_fio(&c__1, (char *)&lmax[1], (ftnlen)sizeof(integer));
00259 e_wsfe();
00260 io___32.ciunit = *nout;
00261 s_wsfe(&io___32);
00262 do_fio(&c__1, (char *)&lmax[2], (ftnlen)sizeof(integer));
00263 e_wsfe();
00264 io___33.ciunit = *nout;
00265 s_wsfe(&io___33);
00266 do_fio(&c__1, (char *)&ninfo, (ftnlen)sizeof(integer));
00267 e_wsfe();
00268 io___34.ciunit = *nout;
00269 s_wsfe(&io___34);
00270 do_fio(&c__1, (char *)&knt, (ftnlen)sizeof(integer));
00271 e_wsfe();
00272
00273 return 0;
00274
00275
00276
00277 }