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__2 = 2;
00019
00020 int dget32_(doublereal *rmax, integer *lmax, integer *ninfo,
00021 integer *knt)
00022 {
00023
00024
00025 static integer itval[32] = { 8,4,2,1,4,8,1,2,2,1,8,
00026 4,1,2,4,8,9,4,2,1,4,9,1,2,2,1,9,4,1,2,4,9 };
00027
00028
00029 doublereal d__1, d__2;
00030
00031
00032 double sqrt(doublereal);
00033
00034
00035 doublereal b[4] , x[4] ;
00036 integer n1, n2, ib;
00037 doublereal tl[4] , tr[4] ;
00038 integer ib1, ib2, ib3;
00039 doublereal den, val[3], eps;
00040 integer itl;
00041 doublereal res, sgn;
00042 integer itr;
00043 doublereal tmp;
00044 integer info, isgn;
00045 doublereal tnrm, xnrm, scale, xnorm;
00046 extern int dlasy2_(logical *, logical *, integer *,
00047 integer *, integer *, doublereal *, integer *, doublereal *,
00048 integer *, doublereal *, integer *, doublereal *, doublereal *,
00049 integer *, doublereal *, integer *), dlabad_(doublereal *,
00050 doublereal *);
00051 extern doublereal dlamch_(char *);
00052 doublereal bignum;
00053 integer itranl, itlscl;
00054 logical ltranl;
00055 integer itranr, itrscl;
00056 logical ltranr;
00057 doublereal smlnum;
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
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 eps = dlamch_("P");
00124 smlnum = dlamch_("S") / eps;
00125 bignum = 1. / smlnum;
00126 dlabad_(&smlnum, &bignum);
00127
00128
00129
00130 val[0] = sqrt(smlnum);
00131 val[1] = 1.;
00132 val[2] = sqrt(bignum);
00133
00134 *knt = 0;
00135 *ninfo = 0;
00136 *lmax = 0;
00137 *rmax = 0.;
00138
00139
00140
00141 for (itranl = 0; itranl <= 1; ++itranl) {
00142 for (itranr = 0; itranr <= 1; ++itranr) {
00143 for (isgn = -1; isgn <= 1; isgn += 2) {
00144 sgn = (doublereal) isgn;
00145 ltranl = itranl == 1;
00146 ltranr = itranr == 1;
00147
00148 n1 = 1;
00149 n2 = 1;
00150 for (itl = 1; itl <= 3; ++itl) {
00151 for (itr = 1; itr <= 3; ++itr) {
00152 for (ib = 1; ib <= 3; ++ib) {
00153 tl[0] = val[itl - 1];
00154 tr[0] = val[itr - 1];
00155 b[0] = val[ib - 1];
00156 ++(*knt);
00157 dlasy2_(<ranl, <ranr, &isgn, &n1, &n2, tl, &
00158 c__2, tr, &c__2, b, &c__2, &scale, x, &
00159 c__2, &xnorm, &info);
00160 if (info != 0) {
00161 ++(*ninfo);
00162 }
00163 res = (d__1 = (tl[0] + sgn * tr[0]) * x[0] -
00164 scale * b[0], abs(d__1));
00165 if (info == 0) {
00166
00167 d__1 = eps * ((abs(tr[0]) + abs(tl[0])) * abs(
00168 x[0]));
00169 den = max(d__1,smlnum);
00170 } else {
00171
00172 d__1 = abs(x[0]);
00173 den = smlnum * max(d__1,1.);
00174 }
00175 res /= den;
00176 if (scale > 1.) {
00177 res += 1. / eps;
00178 }
00179 res += (d__1 = xnorm - abs(x[0]), abs(d__1)) /
00180 max(smlnum,xnorm) / eps;
00181 if (info != 0 && info != 1) {
00182 res += 1. / eps;
00183 }
00184 if (res > *rmax) {
00185 *lmax = *knt;
00186 *rmax = res;
00187 }
00188
00189 }
00190
00191 }
00192
00193 }
00194
00195 n1 = 2;
00196 n2 = 1;
00197 for (itl = 1; itl <= 8; ++itl) {
00198 for (itlscl = 1; itlscl <= 3; ++itlscl) {
00199 for (itr = 1; itr <= 3; ++itr) {
00200 for (ib1 = 1; ib1 <= 3; ++ib1) {
00201 for (ib2 = 1; ib2 <= 3; ++ib2) {
00202 b[0] = val[ib1 - 1];
00203 b[1] = val[ib2 - 1] * -4.;
00204 tl[0] = itval[((itl << 1) + 1 << 1) - 6] *
00205 val[itlscl - 1];
00206 tl[1] = itval[((itl << 1) + 1 << 1) - 5] *
00207 val[itlscl - 1];
00208 tl[2] = itval[((itl << 1) + 2 << 1) - 6] *
00209 val[itlscl - 1];
00210 tl[3] = itval[((itl << 1) + 2 << 1) - 5] *
00211 val[itlscl - 1];
00212 tr[0] = val[itr - 1];
00213 ++(*knt);
00214 dlasy2_(<ranl, <ranr, &isgn, &n1, &n2,
00215 tl, &c__2, tr, &c__2, b, &c__2, &
00216 scale, x, &c__2, &xnorm, &info);
00217 if (info != 0) {
00218 ++(*ninfo);
00219 }
00220 if (ltranl) {
00221 tmp = tl[2];
00222 tl[2] = tl[1];
00223 tl[1] = tmp;
00224 }
00225 res = (d__1 = (tl[0] + sgn * tr[0]) * x[0]
00226 + tl[2] * x[1] - scale * b[0],
00227 abs(d__1));
00228 res += (d__1 = (tl[3] + sgn * tr[0]) * x[
00229 1] + tl[1] * x[0] - scale * b[1],
00230 abs(d__1));
00231 tnrm = abs(tr[0]) + abs(tl[0]) + abs(tl[2]
00232 ) + abs(tl[1]) + abs(tl[3]);
00233
00234 d__1 = abs(x[0]), d__2 = abs(x[1]);
00235 xnrm = max(d__1,d__2);
00236
00237 d__1 = smlnum, d__2 = smlnum * xnrm, d__1
00238 = max(d__1,d__2), d__2 = tnrm *
00239 eps * xnrm;
00240 den = max(d__1,d__2);
00241 res /= den;
00242 if (scale > 1.) {
00243 res += 1. / eps;
00244 }
00245 res += (d__1 = xnorm - xnrm, abs(d__1)) /
00246 max(smlnum,xnorm) / eps;
00247 if (res > *rmax) {
00248 *lmax = *knt;
00249 *rmax = res;
00250 }
00251
00252 }
00253
00254 }
00255
00256 }
00257
00258 }
00259
00260 }
00261
00262 n1 = 1;
00263 n2 = 2;
00264 for (itr = 1; itr <= 8; ++itr) {
00265 for (itrscl = 1; itrscl <= 3; ++itrscl) {
00266 for (itl = 1; itl <= 3; ++itl) {
00267 for (ib1 = 1; ib1 <= 3; ++ib1) {
00268 for (ib2 = 1; ib2 <= 3; ++ib2) {
00269 b[0] = val[ib1 - 1];
00270 b[2] = val[ib2 - 1] * -2.;
00271 tr[0] = itval[((itr << 1) + 1 << 1) - 6] *
00272 val[itrscl - 1];
00273 tr[1] = itval[((itr << 1) + 1 << 1) - 5] *
00274 val[itrscl - 1];
00275 tr[2] = itval[((itr << 1) + 2 << 1) - 6] *
00276 val[itrscl - 1];
00277 tr[3] = itval[((itr << 1) + 2 << 1) - 5] *
00278 val[itrscl - 1];
00279 tl[0] = val[itl - 1];
00280 ++(*knt);
00281 dlasy2_(<ranl, <ranr, &isgn, &n1, &n2,
00282 tl, &c__2, tr, &c__2, b, &c__2, &
00283 scale, x, &c__2, &xnorm, &info);
00284 if (info != 0) {
00285 ++(*ninfo);
00286 }
00287 if (ltranr) {
00288 tmp = tr[2];
00289 tr[2] = tr[1];
00290 tr[1] = tmp;
00291 }
00292 tnrm = abs(tl[0]) + abs(tr[0]) + abs(tr[2]
00293 ) + abs(tr[3]) + abs(tr[1]);
00294 xnrm = abs(x[0]) + abs(x[2]);
00295 res = (d__1 = (tl[0] + sgn * tr[0]) * x[0]
00296 + sgn * tr[1] * x[2] - scale * b[
00297 0], abs(d__1));
00298 res += (d__1 = (tl[0] + sgn * tr[3]) * x[
00299 2] + sgn * tr[2] * x[0] - scale *
00300 b[2], abs(d__1));
00301
00302 d__1 = smlnum, d__2 = smlnum * xnrm, d__1
00303 = max(d__1,d__2), d__2 = tnrm *
00304 eps * xnrm;
00305 den = max(d__1,d__2);
00306 res /= den;
00307 if (scale > 1.) {
00308 res += 1. / eps;
00309 }
00310 res += (d__1 = xnorm - xnrm, abs(d__1)) /
00311 max(smlnum,xnorm) / eps;
00312 if (res > *rmax) {
00313 *lmax = *knt;
00314 *rmax = res;
00315 }
00316
00317 }
00318
00319 }
00320
00321 }
00322
00323 }
00324
00325 }
00326
00327 n1 = 2;
00328 n2 = 2;
00329 for (itr = 1; itr <= 8; ++itr) {
00330 for (itrscl = 1; itrscl <= 3; ++itrscl) {
00331 for (itl = 1; itl <= 8; ++itl) {
00332 for (itlscl = 1; itlscl <= 3; ++itlscl) {
00333 for (ib1 = 1; ib1 <= 3; ++ib1) {
00334 for (ib2 = 1; ib2 <= 3; ++ib2) {
00335 for (ib3 = 1; ib3 <= 3; ++ib3) {
00336 b[0] = val[ib1 - 1];
00337 b[1] = val[ib2 - 1] * -4.;
00338 b[2] = val[ib3 - 1] * -2.;
00339
00340 d__1 = val[ib1 - 1], d__2 = val[
00341 ib2 - 1], d__1 = min(d__1,
00342 d__2), d__2 = val[ib3 - 1]
00343 ;
00344 b[3] = min(d__1,d__2) * 8.;
00345 tr[0] = itval[((itr << 1) + 1 <<
00346 1) - 6] * val[itrscl - 1];
00347 tr[1] = itval[((itr << 1) + 1 <<
00348 1) - 5] * val[itrscl - 1];
00349 tr[2] = itval[((itr << 1) + 2 <<
00350 1) - 6] * val[itrscl - 1];
00351 tr[3] = itval[((itr << 1) + 2 <<
00352 1) - 5] * val[itrscl - 1];
00353 tl[0] = itval[((itl << 1) + 1 <<
00354 1) - 6] * val[itlscl - 1];
00355 tl[1] = itval[((itl << 1) + 1 <<
00356 1) - 5] * val[itlscl - 1];
00357 tl[2] = itval[((itl << 1) + 2 <<
00358 1) - 6] * val[itlscl - 1];
00359 tl[3] = itval[((itl << 1) + 2 <<
00360 1) - 5] * val[itlscl - 1];
00361 ++(*knt);
00362 dlasy2_(<ranl, <ranr, &isgn, &
00363 n1, &n2, tl, &c__2, tr, &
00364 c__2, b, &c__2, &scale, x,
00365 &c__2, &xnorm, &info);
00366 if (info != 0) {
00367 ++(*ninfo);
00368 }
00369 if (ltranr) {
00370 tmp = tr[2];
00371 tr[2] = tr[1];
00372 tr[1] = tmp;
00373 }
00374 if (ltranl) {
00375 tmp = tl[2];
00376 tl[2] = tl[1];
00377 tl[1] = tmp;
00378 }
00379 tnrm = abs(tr[0]) + abs(tr[1]) +
00380 abs(tr[2]) + abs(tr[3]) +
00381 abs(tl[0]) + abs(tl[1]) +
00382 abs(tl[2]) + abs(tl[3]);
00383
00384 d__1 = abs(x[0]) + abs(x[2]),
00385 d__2 = abs(x[1]) + abs(x[
00386 3]);
00387 xnrm = max(d__1,d__2);
00388 res = (d__1 = (tl[0] + sgn * tr[0]
00389 ) * x[0] + sgn * tr[1] *
00390 x[2] + tl[2] * x[1] -
00391 scale * b[0], abs(d__1));
00392 res += (d__1 = tl[0] * x[2] + sgn
00393 * tr[2] * x[0] + sgn * tr[
00394 3] * x[2] + tl[2] * x[3]
00395 - scale * b[2], abs(d__1))
00396 ;
00397 res += (d__1 = tl[1] * x[0] + sgn
00398 * tr[0] * x[1] + sgn * tr[
00399 1] * x[3] + tl[3] * x[1]
00400 - scale * b[1], abs(d__1))
00401 ;
00402 res += (d__1 = (tl[3] + sgn * tr[
00403 3]) * x[3] + sgn * tr[2] *
00404 x[1] + tl[1] * x[2] -
00405 scale * b[3], abs(d__1));
00406
00407 d__1 = smlnum, d__2 = smlnum *
00408 xnrm, d__1 = max(d__1,
00409 d__2), d__2 = tnrm * eps *
00410 xnrm;
00411 den = max(d__1,d__2);
00412 res /= den;
00413 if (scale > 1.) {
00414 res += 1. / eps;
00415 }
00416 res += (d__1 = xnorm - xnrm, abs(
00417 d__1)) / max(smlnum,xnorm)
00418 / eps;
00419 if (res > *rmax) {
00420 *lmax = *knt;
00421 *rmax = res;
00422 }
00423
00424 }
00425
00426 }
00427
00428 }
00429
00430 }
00431
00432 }
00433
00434 }
00435
00436 }
00437
00438 }
00439
00440 }
00441
00442 }
00443
00444 return 0;
00445
00446
00447
00448 }