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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 static integer c__3 = 3;
00021 static integer c__1 = 1;
00022 static integer c__6 = 6;
00023 static integer c__50 = 50;
00024
00025 int cchkgk_(integer *nin, integer *nout)
00026 {
00027
00028 static char fmt_9999[] = "(1x,\002.. test output of CGGBAK .. \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 CGGBAL info is not "
00032 "0 =\002,i4)";
00033 static char fmt_9996[] = "(\002 example number where CGGBAK(L) info is n"
00034 "ot 0 =\002,i4)";
00035 static char fmt_9995[] = "(\002 example number where CGGBAK(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
00045 integer i__1, i__2, i__3, i__4;
00046 real r__1, r__2, r__3, r__4;
00047 complex q__1, q__2;
00048
00049
00050 integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
00051 e_rsle(void);
00052 double r_imag(complex *);
00053 integer s_wsfe(cilist *), e_wsfe(void), do_fio(integer *, char *, ftnlen);
00054
00055
00056 complex a[2500] , b[2500] , e[
00057 2500] , f[2500] ;
00058 integer i__, j, m, n;
00059 complex af[2500] , bf[2500] ,
00060 vl[2500] , vr[2500] ;
00061 integer ihi, ilo;
00062 real eps;
00063 complex vlf[2500] ;
00064 integer knt;
00065 complex vrf[2500] ;
00066 integer info, lmax[4];
00067 real rmax, vmax;
00068 complex work[2500] ;
00069 extern int cgemm_(char *, char *, integer *, integer *,
00070 integer *, complex *, complex *, integer *, complex *, integer *,
00071 complex *, complex *, integer *);
00072 integer ninfo;
00073 real anorm, bnorm, rwork[300];
00074 extern int cggbak_(char *, char *, integer *, integer *,
00075 integer *, real *, real *, integer *, complex *, integer *,
00076 integer *), cggbal_(char *, integer *, complex *,
00077 integer *, complex *, integer *, integer *, integer *, real *,
00078 real *, real *, integer *);
00079 extern doublereal clange_(char *, integer *, integer *, complex *,
00080 integer *, real *);
00081 real lscale[50];
00082 extern doublereal slamch_(char *);
00083 real rscale[50];
00084 extern int clacpy_(char *, integer *, integer *, complex
00085 *, integer *, complex *, integer *);
00086
00087
00088 static cilist io___6 = { 0, 0, 0, 0, 0 };
00089 static cilist io___10 = { 0, 0, 0, 0, 0 };
00090 static cilist io___13 = { 0, 0, 0, 0, 0 };
00091 static cilist io___15 = { 0, 0, 0, 0, 0 };
00092 static cilist io___17 = { 0, 0, 0, 0, 0 };
00093 static cilist io___35 = { 0, 0, 0, fmt_9999, 0 };
00094 static cilist io___36 = { 0, 0, 0, fmt_9998, 0 };
00095 static cilist io___37 = { 0, 0, 0, fmt_9997, 0 };
00096 static cilist io___38 = { 0, 0, 0, fmt_9996, 0 };
00097 static cilist io___39 = { 0, 0, 0, fmt_9995, 0 };
00098 static cilist io___40 = { 0, 0, 0, fmt_9994, 0 };
00099 static cilist io___41 = { 0, 0, 0, fmt_9992, 0 };
00100 static cilist io___42 = { 0, 0, 0, fmt_9991, 0 };
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
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146 lmax[0] = 0;
00147 lmax[1] = 0;
00148 lmax[2] = 0;
00149 lmax[3] = 0;
00150 ninfo = 0;
00151 knt = 0;
00152 rmax = 0.f;
00153
00154 eps = slamch_("Precision");
00155
00156 L10:
00157 io___6.ciunit = *nin;
00158 s_rsle(&io___6);
00159 do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00160 do_lio(&c__3, &c__1, (char *)&m, (ftnlen)sizeof(integer));
00161 e_rsle();
00162 if (n == 0) {
00163 goto L100;
00164 }
00165
00166 i__1 = n;
00167 for (i__ = 1; i__ <= i__1; ++i__) {
00168 io___10.ciunit = *nin;
00169 s_rsle(&io___10);
00170 i__2 = n;
00171 for (j = 1; j <= i__2; ++j) {
00172 do_lio(&c__6, &c__1, (char *)&a[i__ + j * 50 - 51], (ftnlen)
00173 sizeof(complex));
00174 }
00175 e_rsle();
00176
00177 }
00178
00179 i__1 = n;
00180 for (i__ = 1; i__ <= i__1; ++i__) {
00181 io___13.ciunit = *nin;
00182 s_rsle(&io___13);
00183 i__2 = n;
00184 for (j = 1; j <= i__2; ++j) {
00185 do_lio(&c__6, &c__1, (char *)&b[i__ + j * 50 - 51], (ftnlen)
00186 sizeof(complex));
00187 }
00188 e_rsle();
00189
00190 }
00191
00192 i__1 = n;
00193 for (i__ = 1; i__ <= i__1; ++i__) {
00194 io___15.ciunit = *nin;
00195 s_rsle(&io___15);
00196 i__2 = m;
00197 for (j = 1; j <= i__2; ++j) {
00198 do_lio(&c__6, &c__1, (char *)&vl[i__ + j * 50 - 51], (ftnlen)
00199 sizeof(complex));
00200 }
00201 e_rsle();
00202
00203 }
00204
00205 i__1 = n;
00206 for (i__ = 1; i__ <= i__1; ++i__) {
00207 io___17.ciunit = *nin;
00208 s_rsle(&io___17);
00209 i__2 = m;
00210 for (j = 1; j <= i__2; ++j) {
00211 do_lio(&c__6, &c__1, (char *)&vr[i__ + j * 50 - 51], (ftnlen)
00212 sizeof(complex));
00213 }
00214 e_rsle();
00215
00216 }
00217
00218 ++knt;
00219
00220 anorm = clange_("M", &n, &n, a, &c__50, rwork);
00221 bnorm = clange_("M", &n, &n, b, &c__50, rwork);
00222
00223 clacpy_("FULL", &n, &n, a, &c__50, af, &c__50);
00224 clacpy_("FULL", &n, &n, b, &c__50, bf, &c__50);
00225
00226 cggbal_("B", &n, a, &c__50, b, &c__50, &ilo, &ihi, lscale, rscale, rwork,
00227 &info);
00228 if (info != 0) {
00229 ++ninfo;
00230 lmax[0] = knt;
00231 }
00232
00233 clacpy_("FULL", &n, &m, vl, &c__50, vlf, &c__50);
00234 clacpy_("FULL", &n, &m, vr, &c__50, vrf, &c__50);
00235
00236 cggbak_("B", "L", &n, &ilo, &ihi, lscale, rscale, &m, vl, &c__50, &info);
00237 if (info != 0) {
00238 ++ninfo;
00239 lmax[1] = knt;
00240 }
00241
00242 cggbak_("B", "R", &n, &ilo, &ihi, lscale, rscale, &m, vr, &c__50, &info);
00243 if (info != 0) {
00244 ++ninfo;
00245 lmax[2] = knt;
00246 }
00247
00248
00249
00250
00251
00252
00253 cgemm_("N", "N", &n, &m, &n, &c_b2, af, &c__50, vr, &c__50, &c_b1, work, &
00254 c__50);
00255 cgemm_("C", "N", &m, &m, &n, &c_b2, vl, &c__50, work, &c__50, &c_b1, e, &
00256 c__50);
00257
00258 cgemm_("N", "N", &n, &m, &n, &c_b2, a, &c__50, vrf, &c__50, &c_b1, work, &
00259 c__50);
00260 cgemm_("C", "N", &m, &m, &n, &c_b2, vlf, &c__50, work, &c__50, &c_b1, f, &
00261 c__50);
00262
00263 vmax = 0.f;
00264 i__1 = m;
00265 for (j = 1; j <= i__1; ++j) {
00266 i__2 = m;
00267 for (i__ = 1; i__ <= i__2; ++i__) {
00268 i__3 = i__ + j * 50 - 51;
00269 i__4 = i__ + j * 50 - 51;
00270 q__2.r = e[i__3].r - f[i__4].r, q__2.i = e[i__3].i - f[i__4].i;
00271 q__1.r = q__2.r, q__1.i = q__2.i;
00272
00273 r__3 = vmax, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00274 q__1), dabs(r__2));
00275 vmax = dmax(r__3,r__4);
00276
00277 }
00278
00279 }
00280 vmax /= eps * dmax(anorm,bnorm);
00281 if (vmax > rmax) {
00282 lmax[3] = knt;
00283 rmax = vmax;
00284 }
00285
00286
00287
00288 cgemm_("N", "N", &n, &m, &n, &c_b2, bf, &c__50, vr, &c__50, &c_b1, work, &
00289 c__50);
00290 cgemm_("C", "N", &m, &m, &n, &c_b2, vl, &c__50, work, &c__50, &c_b1, e, &
00291 c__50);
00292
00293 cgemm_("n", "n", &n, &m, &n, &c_b2, b, &c__50, vrf, &c__50, &c_b1, work, &
00294 c__50);
00295 cgemm_("C", "N", &m, &m, &n, &c_b2, vlf, &c__50, work, &c__50, &c_b1, f, &
00296 c__50);
00297
00298 vmax = 0.f;
00299 i__1 = m;
00300 for (j = 1; j <= i__1; ++j) {
00301 i__2 = m;
00302 for (i__ = 1; i__ <= i__2; ++i__) {
00303 i__3 = i__ + j * 50 - 51;
00304 i__4 = i__ + j * 50 - 51;
00305 q__2.r = e[i__3].r - f[i__4].r, q__2.i = e[i__3].i - f[i__4].i;
00306 q__1.r = q__2.r, q__1.i = q__2.i;
00307
00308 r__3 = vmax, r__4 = (r__1 = q__1.r, dabs(r__1)) + (r__2 = r_imag(&
00309 q__1), dabs(r__2));
00310 vmax = dmax(r__3,r__4);
00311
00312 }
00313
00314 }
00315 vmax /= eps * dmax(anorm,bnorm);
00316 if (vmax > rmax) {
00317 lmax[3] = knt;
00318 rmax = vmax;
00319 }
00320
00321 goto L10;
00322
00323 L100:
00324
00325 io___35.ciunit = *nout;
00326 s_wsfe(&io___35);
00327 e_wsfe();
00328
00329 io___36.ciunit = *nout;
00330 s_wsfe(&io___36);
00331 do_fio(&c__1, (char *)&rmax, (ftnlen)sizeof(real));
00332 e_wsfe();
00333 io___37.ciunit = *nout;
00334 s_wsfe(&io___37);
00335 do_fio(&c__1, (char *)&lmax[0], (ftnlen)sizeof(integer));
00336 e_wsfe();
00337 io___38.ciunit = *nout;
00338 s_wsfe(&io___38);
00339 do_fio(&c__1, (char *)&lmax[1], (ftnlen)sizeof(integer));
00340 e_wsfe();
00341 io___39.ciunit = *nout;
00342 s_wsfe(&io___39);
00343 do_fio(&c__1, (char *)&lmax[2], (ftnlen)sizeof(integer));
00344 e_wsfe();
00345 io___40.ciunit = *nout;
00346 s_wsfe(&io___40);
00347 do_fio(&c__1, (char *)&lmax[3], (ftnlen)sizeof(integer));
00348 e_wsfe();
00349 io___41.ciunit = *nout;
00350 s_wsfe(&io___41);
00351 do_fio(&c__1, (char *)&ninfo, (ftnlen)sizeof(integer));
00352 e_wsfe();
00353 io___42.ciunit = *nout;
00354 s_wsfe(&io___42);
00355 do_fio(&c__1, (char *)&knt, (ftnlen)sizeof(integer));
00356 e_wsfe();
00357
00358 return 0;
00359
00360
00361
00362 }