Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
eis_cinvit.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "f2c.h"
00007
00008 int cinvit_(integer *nm, integer *n, doublereal *ar,
00009 doublereal *ai, doublereal *wr, doublereal *wi, logical *select,
00010 integer *mm, integer *m, doublereal *zr, doublereal *zi, integer *
00011 ierr, doublereal *rm1, doublereal *rm2, doublereal *rv1, doublereal *
00012 rv2)
00013 {
00014
00015 integer ar_dim1, ar_offset, ai_dim1, ai_offset, zr_dim1, zr_offset,
00016 zi_dim1, zi_offset, rm1_dim1, rm1_offset, rm2_dim1, rm2_offset,
00017 i__1, i__2, i__3;
00018 doublereal d__1, d__2;
00019
00020
00021 double sqrt(doublereal);
00022
00023
00024 extern int cdiv_(doublereal *, doublereal *, doublereal *
00025 , doublereal *, doublereal *, doublereal *);
00026 static doublereal norm;
00027 static integer i__, j, k, s;
00028 static doublereal x, y, normv;
00029 static integer ii;
00030 static doublereal ilambd;
00031 static integer mp, uk;
00032 static doublereal rlambd;
00033 extern doublereal pythag_(doublereal *, doublereal *), epslon_(doublereal
00034 *);
00035 static integer km1, ip1;
00036 static doublereal growto, ukroot;
00037 static integer its;
00038 static doublereal eps3;
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
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 --rv2;
00114 --rv1;
00115 rm2_dim1 = *n;
00116 rm2_offset = rm2_dim1 + 1;
00117 rm2 -= rm2_offset;
00118 rm1_dim1 = *n;
00119 rm1_offset = rm1_dim1 + 1;
00120 rm1 -= rm1_offset;
00121 --select;
00122 --wi;
00123 --wr;
00124 ai_dim1 = *nm;
00125 ai_offset = ai_dim1 + 1;
00126 ai -= ai_offset;
00127 ar_dim1 = *nm;
00128 ar_offset = ar_dim1 + 1;
00129 ar -= ar_offset;
00130 zi_dim1 = *nm;
00131 zi_offset = zi_dim1 + 1;
00132 zi -= zi_offset;
00133 zr_dim1 = *nm;
00134 zr_offset = zr_dim1 + 1;
00135 zr -= zr_offset;
00136
00137
00138 *ierr = 0;
00139 uk = 0;
00140 s = 1;
00141
00142 i__1 = *n;
00143 for (k = 1; k <= i__1; ++k) {
00144 if (! select[k]) {
00145 goto L980;
00146 }
00147 if (s > *mm) {
00148 goto L1000;
00149 }
00150 if (uk >= k) {
00151 goto L200;
00152 }
00153
00154 i__2 = *n;
00155 for (uk = k; uk <= i__2; ++uk) {
00156 if (uk == *n) {
00157 goto L140;
00158 }
00159 if (ar[uk + 1 + uk * ar_dim1] == 0. && ai[uk + 1 + uk * ai_dim1]
00160 == 0.) {
00161 goto L140;
00162 }
00163
00164 }
00165
00166
00167 L140:
00168 norm = 0.;
00169 mp = 1;
00170
00171 i__2 = uk;
00172 for (i__ = 1; i__ <= i__2; ++i__) {
00173 x = 0.;
00174
00175 i__3 = uk;
00176 for (j = mp; j <= i__3; ++j) {
00177
00178 x += pythag_(&ar[i__ + j * ar_dim1], &ai[i__ + j * ai_dim1]);
00179 }
00180
00181 if (x > norm) {
00182 norm = x;
00183 }
00184 mp = i__;
00185
00186 }
00187
00188
00189 if (norm == 0.) {
00190 norm = 1.;
00191 }
00192 eps3 = epslon_(&norm);
00193
00194 ukroot = (doublereal) uk;
00195 ukroot = sqrt(ukroot);
00196 growto = .1 / ukroot;
00197 L200:
00198 rlambd = wr[k];
00199 ilambd = wi[k];
00200 if (k == 1) {
00201 goto L280;
00202 }
00203 km1 = k - 1;
00204 goto L240;
00205
00206
00207 L220:
00208 rlambd += eps3;
00209
00210 L240:
00211 i__2 = km1;
00212 for (ii = 1; ii <= i__2; ++ii) {
00213 i__ = k - ii;
00214 if (select[i__] && (d__1 = wr[i__] - rlambd, abs(d__1)) < eps3 &&
00215 (d__2 = wi[i__] - ilambd, abs(d__2)) < eps3) {
00216 goto L220;
00217 }
00218
00219 }
00220
00221 wr[k] = rlambd;
00222
00223
00224 L280:
00225 mp = 1;
00226
00227 i__2 = uk;
00228 for (i__ = 1; i__ <= i__2; ++i__) {
00229
00230 i__3 = uk;
00231 for (j = mp; j <= i__3; ++j) {
00232 rm1[i__ + j * rm1_dim1] = ar[i__ + j * ar_dim1];
00233 rm2[i__ + j * rm2_dim1] = ai[i__ + j * ai_dim1];
00234
00235 }
00236
00237 rm1[i__ + i__ * rm1_dim1] -= rlambd;
00238 rm2[i__ + i__ * rm2_dim1] -= ilambd;
00239 mp = i__;
00240 rv1[i__] = eps3;
00241
00242 }
00243
00244
00245 if (uk == 1) {
00246 goto L420;
00247 }
00248
00249 i__2 = uk;
00250 for (i__ = 2; i__ <= i__2; ++i__) {
00251 mp = i__ - 1;
00252 if (pythag_(&rm1[i__ + mp * rm1_dim1], &rm2[i__ + mp * rm2_dim1])
00253 <= pythag_(&rm1[mp + mp * rm1_dim1], &rm2[mp + mp *
00254 rm2_dim1])) {
00255 goto L360;
00256 }
00257
00258 i__3 = uk;
00259 for (j = mp; j <= i__3; ++j) {
00260 y = rm1[i__ + j * rm1_dim1];
00261 rm1[i__ + j * rm1_dim1] = rm1[mp + j * rm1_dim1];
00262 rm1[mp + j * rm1_dim1] = y;
00263 y = rm2[i__ + j * rm2_dim1];
00264 rm2[i__ + j * rm2_dim1] = rm2[mp + j * rm2_dim1];
00265 rm2[mp + j * rm2_dim1] = y;
00266
00267 }
00268
00269 L360:
00270 if (rm1[mp + mp * rm1_dim1] == 0. && rm2[mp + mp * rm2_dim1] ==
00271 0.) {
00272 rm1[mp + mp * rm1_dim1] = eps3;
00273 }
00274 cdiv_(&rm1[i__ + mp * rm1_dim1], &rm2[i__ + mp * rm2_dim1], &rm1[
00275 mp + mp * rm1_dim1], &rm2[mp + mp * rm2_dim1], &x, &y);
00276 if (x == 0. && y == 0.) {
00277 goto L400;
00278 }
00279
00280 i__3 = uk;
00281 for (j = i__; j <= i__3; ++j) {
00282 rm1[i__ + j * rm1_dim1] = rm1[i__ + j * rm1_dim1] - x * rm1[
00283 mp + j * rm1_dim1] + y * rm2[mp + j * rm2_dim1];
00284 rm2[i__ + j * rm2_dim1] = rm2[i__ + j * rm2_dim1] - x * rm2[
00285 mp + j * rm2_dim1] - y * rm1[mp + j * rm1_dim1];
00286
00287 }
00288
00289 L400:
00290 ;
00291 }
00292
00293 L420:
00294 if (rm1[uk + uk * rm1_dim1] == 0. && rm2[uk + uk * rm2_dim1] == 0.) {
00295 rm1[uk + uk * rm1_dim1] = eps3;
00296 }
00297 its = 0;
00298
00299
00300 L660:
00301 i__2 = uk;
00302 for (ii = 1; ii <= i__2; ++ii) {
00303 i__ = uk + 1 - ii;
00304 x = rv1[i__];
00305 y = 0.;
00306 if (i__ == uk) {
00307 goto L700;
00308 }
00309 ip1 = i__ + 1;
00310
00311 i__3 = uk;
00312 for (j = ip1; j <= i__3; ++j) {
00313 x = x - rm1[i__ + j * rm1_dim1] * rv1[j] + rm2[i__ + j *
00314 rm2_dim1] * rv2[j];
00315 y = y - rm1[i__ + j * rm1_dim1] * rv2[j] - rm2[i__ + j *
00316 rm2_dim1] * rv1[j];
00317
00318 }
00319
00320 L700:
00321 cdiv_(&x, &y, &rm1[i__ + i__ * rm1_dim1], &rm2[i__ + i__ *
00322 rm2_dim1], &rv1[i__], &rv2[i__]);
00323
00324 }
00325
00326
00327 ++its;
00328 norm = 0.;
00329 normv = 0.;
00330
00331 i__2 = uk;
00332 for (i__ = 1; i__ <= i__2; ++i__) {
00333 x = pythag_(&rv1[i__], &rv2[i__]);
00334 if (normv >= x) {
00335 goto L760;
00336 }
00337 normv = x;
00338 j = i__;
00339 L760:
00340 norm += x;
00341
00342 }
00343
00344 if (norm < growto) {
00345 goto L840;
00346 }
00347
00348 x = rv1[j];
00349 y = rv2[j];
00350
00351 i__2 = uk;
00352 for (i__ = 1; i__ <= i__2; ++i__) {
00353 cdiv_(&rv1[i__], &rv2[i__], &x, &y, &zr[i__ + s * zr_dim1], &zi[
00354 i__ + s * zi_dim1]);
00355
00356 }
00357
00358 if (uk == *n) {
00359 goto L940;
00360 }
00361 j = uk + 1;
00362 goto L900;
00363
00364
00365 L840:
00366 if (its >= uk) {
00367 goto L880;
00368 }
00369 x = ukroot;
00370 y = eps3 / (x + 1.);
00371 rv1[1] = eps3;
00372
00373 i__2 = uk;
00374 for (i__ = 2; i__ <= i__2; ++i__) {
00375
00376 rv1[i__] = y;
00377 }
00378
00379 j = uk - its + 1;
00380 rv1[j] -= eps3 * x;
00381 goto L660;
00382
00383 L880:
00384 j = 1;
00385 *ierr = -k;
00386
00387
00388 L900:
00389 i__2 = *n;
00390 for (i__ = j; i__ <= i__2; ++i__) {
00391 zr[i__ + s * zr_dim1] = 0.;
00392 zi[i__ + s * zi_dim1] = 0.;
00393
00394 }
00395
00396 L940:
00397 ++s;
00398 L980:
00399 ;
00400 }
00401
00402 goto L1001;
00403
00404
00405 L1000:
00406 if (*ierr != 0) {
00407 *ierr -= *n;
00408 }
00409 if (*ierr == 0) {
00410 *ierr = -((*n << 1) + 1);
00411 }
00412 L1001:
00413 *m = s - 1;
00414 return 0;
00415 }
00416