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