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__1 = 1;
00019
00020 int zlaein_(logical *rightv, logical *noinit, integer *n,
00021 doublecomplex *h__, integer *ldh, doublecomplex *w, doublecomplex *v,
00022 doublecomplex *b, integer *ldb, doublereal *rwork, doublereal *eps3,
00023 doublereal *smlnum, integer *info)
00024 {
00025
00026 integer b_dim1, b_offset, h_dim1, h_offset, i__1, i__2, i__3, i__4, i__5;
00027 doublereal d__1, d__2, d__3, d__4;
00028 doublecomplex z__1, z__2;
00029
00030
00031 double sqrt(doublereal), d_imag(doublecomplex *);
00032
00033
00034 integer i__, j;
00035 doublecomplex x, ei, ej;
00036 integer its, ierr;
00037 doublecomplex temp;
00038 doublereal scale;
00039 char trans[1];
00040 doublereal rtemp, rootn, vnorm;
00041 extern doublereal dznrm2_(integer *, doublecomplex *, integer *);
00042 extern int zdscal_(integer *, doublereal *,
00043 doublecomplex *, integer *);
00044 extern integer izamax_(integer *, doublecomplex *, integer *);
00045 extern VOID zladiv_(doublecomplex *, doublecomplex *,
00046 doublecomplex *);
00047 char normin[1];
00048 extern doublereal dzasum_(integer *, doublecomplex *, integer *);
00049 doublereal nrmsml;
00050 extern int zlatrs_(char *, char *, char *, char *,
00051 integer *, doublecomplex *, integer *, doublecomplex *,
00052 doublereal *, doublereal *, integer *);
00053 doublereal growto;
00054
00055
00056
00057
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
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 h_dim1 = *ldh;
00143 h_offset = 1 + h_dim1;
00144 h__ -= h_offset;
00145 --v;
00146 b_dim1 = *ldb;
00147 b_offset = 1 + b_dim1;
00148 b -= b_offset;
00149 --rwork;
00150
00151
00152 *info = 0;
00153
00154
00155
00156
00157 rootn = sqrt((doublereal) (*n));
00158 growto = .1 / rootn;
00159
00160 d__1 = 1., d__2 = *eps3 * rootn;
00161 nrmsml = max(d__1,d__2) * *smlnum;
00162
00163
00164
00165
00166 i__1 = *n;
00167 for (j = 1; j <= i__1; ++j) {
00168 i__2 = j - 1;
00169 for (i__ = 1; i__ <= i__2; ++i__) {
00170 i__3 = i__ + j * b_dim1;
00171 i__4 = i__ + j * h_dim1;
00172 b[i__3].r = h__[i__4].r, b[i__3].i = h__[i__4].i;
00173
00174 }
00175 i__2 = j + j * b_dim1;
00176 i__3 = j + j * h_dim1;
00177 z__1.r = h__[i__3].r - w->r, z__1.i = h__[i__3].i - w->i;
00178 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00179
00180 }
00181
00182 if (*noinit) {
00183
00184
00185
00186 i__1 = *n;
00187 for (i__ = 1; i__ <= i__1; ++i__) {
00188 i__2 = i__;
00189 v[i__2].r = *eps3, v[i__2].i = 0.;
00190
00191 }
00192 } else {
00193
00194
00195
00196 vnorm = dznrm2_(n, &v[1], &c__1);
00197 d__1 = *eps3 * rootn / max(vnorm,nrmsml);
00198 zdscal_(n, &d__1, &v[1], &c__1);
00199 }
00200
00201 if (*rightv) {
00202
00203
00204
00205
00206 i__1 = *n - 1;
00207 for (i__ = 1; i__ <= i__1; ++i__) {
00208 i__2 = i__ + 1 + i__ * h_dim1;
00209 ei.r = h__[i__2].r, ei.i = h__[i__2].i;
00210 i__2 = i__ + i__ * b_dim1;
00211 if ((d__1 = b[i__2].r, abs(d__1)) + (d__2 = d_imag(&b[i__ + i__ *
00212 b_dim1]), abs(d__2)) < (d__3 = ei.r, abs(d__3)) + (d__4 =
00213 d_imag(&ei), abs(d__4))) {
00214
00215
00216
00217 zladiv_(&z__1, &b[i__ + i__ * b_dim1], &ei);
00218 x.r = z__1.r, x.i = z__1.i;
00219 i__2 = i__ + i__ * b_dim1;
00220 b[i__2].r = ei.r, b[i__2].i = ei.i;
00221 i__2 = *n;
00222 for (j = i__ + 1; j <= i__2; ++j) {
00223 i__3 = i__ + 1 + j * b_dim1;
00224 temp.r = b[i__3].r, temp.i = b[i__3].i;
00225 i__3 = i__ + 1 + j * b_dim1;
00226 i__4 = i__ + j * b_dim1;
00227 z__2.r = x.r * temp.r - x.i * temp.i, z__2.i = x.r *
00228 temp.i + x.i * temp.r;
00229 z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i - z__2.i;
00230 b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00231 i__3 = i__ + j * b_dim1;
00232 b[i__3].r = temp.r, b[i__3].i = temp.i;
00233
00234 }
00235 } else {
00236
00237
00238
00239 i__2 = i__ + i__ * b_dim1;
00240 if (b[i__2].r == 0. && b[i__2].i == 0.) {
00241 i__3 = i__ + i__ * b_dim1;
00242 b[i__3].r = *eps3, b[i__3].i = 0.;
00243 }
00244 zladiv_(&z__1, &ei, &b[i__ + i__ * b_dim1]);
00245 x.r = z__1.r, x.i = z__1.i;
00246 if (x.r != 0. || x.i != 0.) {
00247 i__2 = *n;
00248 for (j = i__ + 1; j <= i__2; ++j) {
00249 i__3 = i__ + 1 + j * b_dim1;
00250 i__4 = i__ + 1 + j * b_dim1;
00251 i__5 = i__ + j * b_dim1;
00252 z__2.r = x.r * b[i__5].r - x.i * b[i__5].i, z__2.i =
00253 x.r * b[i__5].i + x.i * b[i__5].r;
00254 z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i -
00255 z__2.i;
00256 b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00257
00258 }
00259 }
00260 }
00261
00262 }
00263 i__1 = *n + *n * b_dim1;
00264 if (b[i__1].r == 0. && b[i__1].i == 0.) {
00265 i__2 = *n + *n * b_dim1;
00266 b[i__2].r = *eps3, b[i__2].i = 0.;
00267 }
00268
00269 *(unsigned char *)trans = 'N';
00270
00271 } else {
00272
00273
00274
00275
00276 for (j = *n; j >= 2; --j) {
00277 i__1 = j + (j - 1) * h_dim1;
00278 ej.r = h__[i__1].r, ej.i = h__[i__1].i;
00279 i__1 = j + j * b_dim1;
00280 if ((d__1 = b[i__1].r, abs(d__1)) + (d__2 = d_imag(&b[j + j *
00281 b_dim1]), abs(d__2)) < (d__3 = ej.r, abs(d__3)) + (d__4 =
00282 d_imag(&ej), abs(d__4))) {
00283
00284
00285
00286 zladiv_(&z__1, &b[j + j * b_dim1], &ej);
00287 x.r = z__1.r, x.i = z__1.i;
00288 i__1 = j + j * b_dim1;
00289 b[i__1].r = ej.r, b[i__1].i = ej.i;
00290 i__1 = j - 1;
00291 for (i__ = 1; i__ <= i__1; ++i__) {
00292 i__2 = i__ + (j - 1) * b_dim1;
00293 temp.r = b[i__2].r, temp.i = b[i__2].i;
00294 i__2 = i__ + (j - 1) * b_dim1;
00295 i__3 = i__ + j * b_dim1;
00296 z__2.r = x.r * temp.r - x.i * temp.i, z__2.i = x.r *
00297 temp.i + x.i * temp.r;
00298 z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i - z__2.i;
00299 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00300 i__2 = i__ + j * b_dim1;
00301 b[i__2].r = temp.r, b[i__2].i = temp.i;
00302
00303 }
00304 } else {
00305
00306
00307
00308 i__1 = j + j * b_dim1;
00309 if (b[i__1].r == 0. && b[i__1].i == 0.) {
00310 i__2 = j + j * b_dim1;
00311 b[i__2].r = *eps3, b[i__2].i = 0.;
00312 }
00313 zladiv_(&z__1, &ej, &b[j + j * b_dim1]);
00314 x.r = z__1.r, x.i = z__1.i;
00315 if (x.r != 0. || x.i != 0.) {
00316 i__1 = j - 1;
00317 for (i__ = 1; i__ <= i__1; ++i__) {
00318 i__2 = i__ + (j - 1) * b_dim1;
00319 i__3 = i__ + (j - 1) * b_dim1;
00320 i__4 = i__ + j * b_dim1;
00321 z__2.r = x.r * b[i__4].r - x.i * b[i__4].i, z__2.i =
00322 x.r * b[i__4].i + x.i * b[i__4].r;
00323 z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i -
00324 z__2.i;
00325 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00326
00327 }
00328 }
00329 }
00330
00331 }
00332 i__1 = b_dim1 + 1;
00333 if (b[i__1].r == 0. && b[i__1].i == 0.) {
00334 i__2 = b_dim1 + 1;
00335 b[i__2].r = *eps3, b[i__2].i = 0.;
00336 }
00337
00338 *(unsigned char *)trans = 'C';
00339
00340 }
00341
00342 *(unsigned char *)normin = 'N';
00343 i__1 = *n;
00344 for (its = 1; its <= i__1; ++its) {
00345
00346
00347
00348
00349
00350 zlatrs_("Upper", trans, "Nonunit", normin, n, &b[b_offset], ldb, &v[1]
00351 , &scale, &rwork[1], &ierr);
00352 *(unsigned char *)normin = 'Y';
00353
00354
00355
00356 vnorm = dzasum_(n, &v[1], &c__1);
00357 if (vnorm >= growto * scale) {
00358 goto L120;
00359 }
00360
00361
00362
00363 rtemp = *eps3 / (rootn + 1.);
00364 v[1].r = *eps3, v[1].i = 0.;
00365 i__2 = *n;
00366 for (i__ = 2; i__ <= i__2; ++i__) {
00367 i__3 = i__;
00368 v[i__3].r = rtemp, v[i__3].i = 0.;
00369
00370 }
00371 i__2 = *n - its + 1;
00372 i__3 = *n - its + 1;
00373 d__1 = *eps3 * rootn;
00374 z__1.r = v[i__3].r - d__1, z__1.i = v[i__3].i;
00375 v[i__2].r = z__1.r, v[i__2].i = z__1.i;
00376
00377 }
00378
00379
00380
00381 *info = 1;
00382
00383 L120:
00384
00385
00386
00387 i__ = izamax_(n, &v[1], &c__1);
00388 i__1 = i__;
00389 d__3 = 1. / ((d__1 = v[i__1].r, abs(d__1)) + (d__2 = d_imag(&v[i__]), abs(
00390 d__2)));
00391 zdscal_(n, &d__3, &v[1], &c__1);
00392
00393 return 0;
00394
00395
00396
00397 }