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__10 = 10;
00022 static doublecomplex c_b43 = {1.,0.};
00023
00024 int zget35_(doublereal *rmax, integer *lmax, integer *ninfo,
00025 integer *knt, integer *nin)
00026 {
00027
00028 integer i__1, i__2, i__3, i__4, i__5;
00029 doublereal d__1, d__2;
00030 doublecomplex z__1;
00031
00032
00033 double sqrt(doublereal);
00034 integer s_rsle(cilist *), do_lio(integer *, integer *, char *, ftnlen),
00035 e_rsle(void);
00036 double z_abs(doublecomplex *);
00037 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00038
00039
00040 doublecomplex a[100] , b[100]
00041 , c__[100] ;
00042 integer i__, j, m, n;
00043 doublereal vm1[3], vm2[3], dum[1], eps, res, res1;
00044 integer imla, imlb, imlc, info;
00045 doublecomplex csav[100] ;
00046 integer isgn;
00047 doublecomplex atmp[100] , btmp[100]
00048 , ctmp[100] ;
00049 doublereal tnrm;
00050 doublecomplex rmul;
00051 doublereal xnrm;
00052 integer imlad;
00053 doublereal scale;
00054 char trana[1], tranb[1];
00055 extern int zgemm_(char *, char *, integer *, integer *,
00056 integer *, doublecomplex *, doublecomplex *, integer *,
00057 doublecomplex *, integer *, doublecomplex *, doublecomplex *,
00058 integer *), dlabad_(doublereal *, doublereal *);
00059 extern doublereal dlamch_(char *);
00060 integer itrana, itranb;
00061 extern doublereal zlange_(char *, integer *, integer *, doublecomplex *,
00062 integer *, doublereal *);
00063 doublereal bignum, smlnum;
00064 extern int ztrsyl_(char *, char *, integer *, integer *,
00065 integer *, doublecomplex *, integer *, doublecomplex *, integer *,
00066 doublecomplex *, integer *, doublereal *, integer *);
00067
00068
00069 static cilist io___6 = { 0, 0, 0, 0, 0 };
00070 static cilist io___10 = { 0, 0, 0, 0, 0 };
00071 static cilist io___13 = { 0, 0, 0, 0, 0 };
00072 static cilist io___15 = { 0, 0, 0, 0, 0 };
00073
00074
00075
00076
00077
00078
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
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 eps = dlamch_("P");
00137 smlnum = dlamch_("S") / eps;
00138 bignum = 1. / smlnum;
00139 dlabad_(&smlnum, &bignum);
00140
00141
00142
00143 vm1[0] = sqrt(smlnum);
00144 vm1[1] = 1.;
00145 vm1[2] = 1e6;
00146 vm2[0] = 1.;
00147 vm2[1] = eps * 2. + 1.;
00148 vm2[2] = 2.;
00149
00150 *knt = 0;
00151 *ninfo = 0;
00152 *lmax = 0;
00153 *rmax = 0.;
00154
00155
00156
00157 L10:
00158 io___6.ciunit = *nin;
00159 s_rsle(&io___6);
00160 do_lio(&c__3, &c__1, (char *)&m, (ftnlen)sizeof(integer));
00161 do_lio(&c__3, &c__1, (char *)&n, (ftnlen)sizeof(integer));
00162 e_rsle();
00163 if (n == 0) {
00164 return 0;
00165 }
00166 i__1 = m;
00167 for (i__ = 1; i__ <= i__1; ++i__) {
00168 io___10.ciunit = *nin;
00169 s_rsle(&io___10);
00170 i__2 = m;
00171 for (j = 1; j <= i__2; ++j) {
00172 do_lio(&c__7, &c__1, (char *)&atmp[i__ + j * 10 - 11], (ftnlen)
00173 sizeof(doublecomplex));
00174 }
00175 e_rsle();
00176
00177 }
00178 i__1 = n;
00179 for (i__ = 1; i__ <= i__1; ++i__) {
00180 io___13.ciunit = *nin;
00181 s_rsle(&io___13);
00182 i__2 = n;
00183 for (j = 1; j <= i__2; ++j) {
00184 do_lio(&c__7, &c__1, (char *)&btmp[i__ + j * 10 - 11], (ftnlen)
00185 sizeof(doublecomplex));
00186 }
00187 e_rsle();
00188
00189 }
00190 i__1 = m;
00191 for (i__ = 1; i__ <= i__1; ++i__) {
00192 io___15.ciunit = *nin;
00193 s_rsle(&io___15);
00194 i__2 = n;
00195 for (j = 1; j <= i__2; ++j) {
00196 do_lio(&c__7, &c__1, (char *)&ctmp[i__ + j * 10 - 11], (ftnlen)
00197 sizeof(doublecomplex));
00198 }
00199 e_rsle();
00200
00201 }
00202 for (imla = 1; imla <= 3; ++imla) {
00203 for (imlad = 1; imlad <= 3; ++imlad) {
00204 for (imlb = 1; imlb <= 3; ++imlb) {
00205 for (imlc = 1; imlc <= 3; ++imlc) {
00206 for (itrana = 1; itrana <= 2; ++itrana) {
00207 for (itranb = 1; itranb <= 2; ++itranb) {
00208 for (isgn = -1; isgn <= 1; isgn += 2) {
00209 if (itrana == 1) {
00210 *(unsigned char *)trana = 'N';
00211 }
00212 if (itrana == 2) {
00213 *(unsigned char *)trana = 'C';
00214 }
00215 if (itranb == 1) {
00216 *(unsigned char *)tranb = 'N';
00217 }
00218 if (itranb == 2) {
00219 *(unsigned char *)tranb = 'C';
00220 }
00221 tnrm = 0.;
00222 i__1 = m;
00223 for (i__ = 1; i__ <= i__1; ++i__) {
00224 i__2 = m;
00225 for (j = 1; j <= i__2; ++j) {
00226 i__3 = i__ + j * 10 - 11;
00227 i__4 = i__ + j * 10 - 11;
00228 i__5 = imla - 1;
00229 z__1.r = vm1[i__5] * atmp[i__4].r,
00230 z__1.i = vm1[i__5] * atmp[
00231 i__4].i;
00232 a[i__3].r = z__1.r, a[i__3].i =
00233 z__1.i;
00234
00235 d__1 = tnrm, d__2 = z_abs(&a[i__ + j *
00236 10 - 11]);
00237 tnrm = max(d__1,d__2);
00238
00239 }
00240 i__2 = i__ + i__ * 10 - 11;
00241 i__3 = i__ + i__ * 10 - 11;
00242 i__4 = imlad - 1;
00243 z__1.r = vm2[i__4] * a[i__3].r, z__1.i =
00244 vm2[i__4] * a[i__3].i;
00245 a[i__2].r = z__1.r, a[i__2].i = z__1.i;
00246
00247 d__1 = tnrm, d__2 = z_abs(&a[i__ + i__ *
00248 10 - 11]);
00249 tnrm = max(d__1,d__2);
00250
00251 }
00252 i__1 = n;
00253 for (i__ = 1; i__ <= i__1; ++i__) {
00254 i__2 = n;
00255 for (j = 1; j <= i__2; ++j) {
00256 i__3 = i__ + j * 10 - 11;
00257 i__4 = i__ + j * 10 - 11;
00258 i__5 = imlb - 1;
00259 z__1.r = vm1[i__5] * btmp[i__4].r,
00260 z__1.i = vm1[i__5] * btmp[
00261 i__4].i;
00262 b[i__3].r = z__1.r, b[i__3].i =
00263 z__1.i;
00264
00265 d__1 = tnrm, d__2 = z_abs(&b[i__ + j *
00266 10 - 11]);
00267 tnrm = max(d__1,d__2);
00268
00269 }
00270
00271 }
00272 if (tnrm == 0.) {
00273 tnrm = 1.;
00274 }
00275 i__1 = m;
00276 for (i__ = 1; i__ <= i__1; ++i__) {
00277 i__2 = n;
00278 for (j = 1; j <= i__2; ++j) {
00279 i__3 = i__ + j * 10 - 11;
00280 i__4 = i__ + j * 10 - 11;
00281 i__5 = imlc - 1;
00282 z__1.r = vm1[i__5] * ctmp[i__4].r,
00283 z__1.i = vm1[i__5] * ctmp[
00284 i__4].i;
00285 c__[i__3].r = z__1.r, c__[i__3].i =
00286 z__1.i;
00287 i__3 = i__ + j * 10 - 11;
00288 i__4 = i__ + j * 10 - 11;
00289 csav[i__3].r = c__[i__4].r, csav[i__3]
00290 .i = c__[i__4].i;
00291
00292 }
00293
00294 }
00295 ++(*knt);
00296 ztrsyl_(trana, tranb, &isgn, &m, &n, a, &
00297 c__10, b, &c__10, c__, &c__10, &scale,
00298 &info);
00299 if (info != 0) {
00300 ++(*ninfo);
00301 }
00302 xnrm = zlange_("M", &m, &n, c__, &c__10, dum);
00303 rmul.r = 1., rmul.i = 0.;
00304 if (xnrm > 1. && tnrm > 1.) {
00305 if (xnrm > bignum / tnrm) {
00306 d__1 = max(xnrm,tnrm);
00307 rmul.r = d__1, rmul.i = 0.;
00308 z_div(&z__1, &c_b43, &rmul);
00309 rmul.r = z__1.r, rmul.i = z__1.i;
00310 }
00311 }
00312 d__1 = -scale;
00313 z__1.r = d__1 * rmul.r, z__1.i = d__1 *
00314 rmul.i;
00315 zgemm_(trana, "N", &m, &n, &m, &rmul, a, &
00316 c__10, c__, &c__10, &z__1, csav, &
00317 c__10);
00318 d__1 = (doublereal) isgn;
00319 z__1.r = d__1 * rmul.r, z__1.i = d__1 *
00320 rmul.i;
00321 zgemm_("N", tranb, &m, &n, &n, &z__1, c__, &
00322 c__10, b, &c__10, &c_b43, csav, &
00323 c__10);
00324 res1 = zlange_("M", &m, &n, csav, &c__10, dum);
00325
00326 d__1 = smlnum, d__2 = smlnum * xnrm, d__1 =
00327 max(d__1,d__2), d__2 = z_abs(&rmul) *
00328 tnrm * eps * xnrm;
00329 res = res1 / max(d__1,d__2);
00330 if (res > *rmax) {
00331 *lmax = *knt;
00332 *rmax = res;
00333 }
00334
00335 }
00336
00337 }
00338
00339 }
00340
00341 }
00342
00343 }
00344
00345 }
00346
00347 }
00348 goto L10;
00349
00350
00351
00352 }