Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016 int dlar1v_(integer *n, integer *b1, integer *bn, doublereal
00017 *lambda, doublereal *d__, doublereal *l, doublereal *ld, doublereal *
00018 lld, doublereal *pivmin, doublereal *gaptol, doublereal *z__, logical
00019 *wantnc, integer *negcnt, doublereal *ztz, doublereal *mingma,
00020 integer *r__, integer *isuppz, doublereal *nrminv, doublereal *resid,
00021 doublereal *rqcorr, doublereal *work)
00022 {
00023
00024 integer i__1;
00025 doublereal d__1, d__2, d__3;
00026
00027
00028 double sqrt(doublereal);
00029
00030
00031 integer i__;
00032 doublereal s;
00033 integer r1, r2;
00034 doublereal eps, tmp;
00035 integer neg1, neg2, indp, inds;
00036 doublereal dplus;
00037 extern doublereal dlamch_(char *);
00038 extern logical disnan_(doublereal *);
00039 integer indlpl, indumn;
00040 doublereal dminus;
00041 logical sawnan1, sawnan2;
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
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
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 --work;
00179 --isuppz;
00180 --z__;
00181 --lld;
00182 --ld;
00183 --l;
00184 --d__;
00185
00186
00187 eps = dlamch_("Precision");
00188 if (*r__ == 0) {
00189 r1 = *b1;
00190 r2 = *bn;
00191 } else {
00192 r1 = *r__;
00193 r2 = *r__;
00194 }
00195
00196 indlpl = 0;
00197
00198 indumn = *n;
00199 inds = (*n << 1) + 1;
00200 indp = *n * 3 + 1;
00201 if (*b1 == 1) {
00202 work[inds] = 0.;
00203 } else {
00204 work[inds + *b1 - 1] = lld[*b1 - 1];
00205 }
00206
00207
00208
00209
00210 sawnan1 = FALSE_;
00211 neg1 = 0;
00212 s = work[inds + *b1 - 1] - *lambda;
00213 i__1 = r1 - 1;
00214 for (i__ = *b1; i__ <= i__1; ++i__) {
00215 dplus = d__[i__] + s;
00216 work[indlpl + i__] = ld[i__] / dplus;
00217 if (dplus < 0.) {
00218 ++neg1;
00219 }
00220 work[inds + i__] = s * work[indlpl + i__] * l[i__];
00221 s = work[inds + i__] - *lambda;
00222
00223 }
00224 sawnan1 = disnan_(&s);
00225 if (sawnan1) {
00226 goto L60;
00227 }
00228 i__1 = r2 - 1;
00229 for (i__ = r1; i__ <= i__1; ++i__) {
00230 dplus = d__[i__] + s;
00231 work[indlpl + i__] = ld[i__] / dplus;
00232 work[inds + i__] = s * work[indlpl + i__] * l[i__];
00233 s = work[inds + i__] - *lambda;
00234
00235 }
00236 sawnan1 = disnan_(&s);
00237
00238 L60:
00239 if (sawnan1) {
00240
00241 neg1 = 0;
00242 s = work[inds + *b1 - 1] - *lambda;
00243 i__1 = r1 - 1;
00244 for (i__ = *b1; i__ <= i__1; ++i__) {
00245 dplus = d__[i__] + s;
00246 if (abs(dplus) < *pivmin) {
00247 dplus = -(*pivmin);
00248 }
00249 work[indlpl + i__] = ld[i__] / dplus;
00250 if (dplus < 0.) {
00251 ++neg1;
00252 }
00253 work[inds + i__] = s * work[indlpl + i__] * l[i__];
00254 if (work[indlpl + i__] == 0.) {
00255 work[inds + i__] = lld[i__];
00256 }
00257 s = work[inds + i__] - *lambda;
00258
00259 }
00260 i__1 = r2 - 1;
00261 for (i__ = r1; i__ <= i__1; ++i__) {
00262 dplus = d__[i__] + s;
00263 if (abs(dplus) < *pivmin) {
00264 dplus = -(*pivmin);
00265 }
00266 work[indlpl + i__] = ld[i__] / dplus;
00267 work[inds + i__] = s * work[indlpl + i__] * l[i__];
00268 if (work[indlpl + i__] == 0.) {
00269 work[inds + i__] = lld[i__];
00270 }
00271 s = work[inds + i__] - *lambda;
00272
00273 }
00274 }
00275
00276
00277
00278
00279 sawnan2 = FALSE_;
00280 neg2 = 0;
00281 work[indp + *bn - 1] = d__[*bn] - *lambda;
00282 i__1 = r1;
00283 for (i__ = *bn - 1; i__ >= i__1; --i__) {
00284 dminus = lld[i__] + work[indp + i__];
00285 tmp = d__[i__] / dminus;
00286 if (dminus < 0.) {
00287 ++neg2;
00288 }
00289 work[indumn + i__] = l[i__] * tmp;
00290 work[indp + i__ - 1] = work[indp + i__] * tmp - *lambda;
00291
00292 }
00293 tmp = work[indp + r1 - 1];
00294 sawnan2 = disnan_(&tmp);
00295 if (sawnan2) {
00296
00297 neg2 = 0;
00298 i__1 = r1;
00299 for (i__ = *bn - 1; i__ >= i__1; --i__) {
00300 dminus = lld[i__] + work[indp + i__];
00301 if (abs(dminus) < *pivmin) {
00302 dminus = -(*pivmin);
00303 }
00304 tmp = d__[i__] / dminus;
00305 if (dminus < 0.) {
00306 ++neg2;
00307 }
00308 work[indumn + i__] = l[i__] * tmp;
00309 work[indp + i__ - 1] = work[indp + i__] * tmp - *lambda;
00310 if (tmp == 0.) {
00311 work[indp + i__ - 1] = d__[i__] - *lambda;
00312 }
00313
00314 }
00315 }
00316
00317
00318
00319
00320 *mingma = work[inds + r1 - 1] + work[indp + r1 - 1];
00321 if (*mingma < 0.) {
00322 ++neg1;
00323 }
00324 if (*wantnc) {
00325 *negcnt = neg1 + neg2;
00326 } else {
00327 *negcnt = -1;
00328 }
00329 if (abs(*mingma) == 0.) {
00330 *mingma = eps * work[inds + r1 - 1];
00331 }
00332 *r__ = r1;
00333 i__1 = r2 - 1;
00334 for (i__ = r1; i__ <= i__1; ++i__) {
00335 tmp = work[inds + i__] + work[indp + i__];
00336 if (tmp == 0.) {
00337 tmp = eps * work[inds + i__];
00338 }
00339 if (abs(tmp) <= abs(*mingma)) {
00340 *mingma = tmp;
00341 *r__ = i__ + 1;
00342 }
00343
00344 }
00345
00346
00347
00348 isuppz[1] = *b1;
00349 isuppz[2] = *bn;
00350 z__[*r__] = 1.;
00351 *ztz = 1.;
00352
00353
00354
00355 if (! sawnan1 && ! sawnan2) {
00356 i__1 = *b1;
00357 for (i__ = *r__ - 1; i__ >= i__1; --i__) {
00358 z__[i__] = -(work[indlpl + i__] * z__[i__ + 1]);
00359 if (((d__1 = z__[i__], abs(d__1)) + (d__2 = z__[i__ + 1], abs(
00360 d__2))) * (d__3 = ld[i__], abs(d__3)) < *gaptol) {
00361 z__[i__] = 0.;
00362 isuppz[1] = i__ + 1;
00363 goto L220;
00364 }
00365 *ztz += z__[i__] * z__[i__];
00366
00367 }
00368 L220:
00369 ;
00370 } else {
00371
00372 i__1 = *b1;
00373 for (i__ = *r__ - 1; i__ >= i__1; --i__) {
00374 if (z__[i__ + 1] == 0.) {
00375 z__[i__] = -(ld[i__ + 1] / ld[i__]) * z__[i__ + 2];
00376 } else {
00377 z__[i__] = -(work[indlpl + i__] * z__[i__ + 1]);
00378 }
00379 if (((d__1 = z__[i__], abs(d__1)) + (d__2 = z__[i__ + 1], abs(
00380 d__2))) * (d__3 = ld[i__], abs(d__3)) < *gaptol) {
00381 z__[i__] = 0.;
00382 isuppz[1] = i__ + 1;
00383 goto L240;
00384 }
00385 *ztz += z__[i__] * z__[i__];
00386
00387 }
00388 L240:
00389 ;
00390 }
00391
00392 if (! sawnan1 && ! sawnan2) {
00393 i__1 = *bn - 1;
00394 for (i__ = *r__; i__ <= i__1; ++i__) {
00395 z__[i__ + 1] = -(work[indumn + i__] * z__[i__]);
00396 if (((d__1 = z__[i__], abs(d__1)) + (d__2 = z__[i__ + 1], abs(
00397 d__2))) * (d__3 = ld[i__], abs(d__3)) < *gaptol) {
00398 z__[i__ + 1] = 0.;
00399 isuppz[2] = i__;
00400 goto L260;
00401 }
00402 *ztz += z__[i__ + 1] * z__[i__ + 1];
00403
00404 }
00405 L260:
00406 ;
00407 } else {
00408
00409 i__1 = *bn - 1;
00410 for (i__ = *r__; i__ <= i__1; ++i__) {
00411 if (z__[i__] == 0.) {
00412 z__[i__ + 1] = -(ld[i__ - 1] / ld[i__]) * z__[i__ - 1];
00413 } else {
00414 z__[i__ + 1] = -(work[indumn + i__] * z__[i__]);
00415 }
00416 if (((d__1 = z__[i__], abs(d__1)) + (d__2 = z__[i__ + 1], abs(
00417 d__2))) * (d__3 = ld[i__], abs(d__3)) < *gaptol) {
00418 z__[i__ + 1] = 0.;
00419 isuppz[2] = i__;
00420 goto L280;
00421 }
00422 *ztz += z__[i__ + 1] * z__[i__ + 1];
00423
00424 }
00425 L280:
00426 ;
00427 }
00428
00429
00430
00431 tmp = 1. / *ztz;
00432 *nrminv = sqrt(tmp);
00433 *resid = abs(*mingma) * *nrminv;
00434 *rqcorr = *mingma * tmp;
00435
00436
00437 return 0;
00438
00439
00440
00441 }