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 static integer c__0 = 0;
00020 static real c_b42 = 1.f;
00021
00022 int sgsvj0_(char *jobv, integer *m, integer *n, real *a,
00023 integer *lda, real *d__, real *sva, integer *mv, real *v, integer *
00024 ldv, real *eps, real *sfmin, real *tol, integer *nsweep, real *work,
00025 integer *lwork, integer *info)
00026 {
00027
00028 integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5,
00029 i__6;
00030 real r__1, r__2;
00031
00032
00033 double sqrt(doublereal), r_sign(real *, real *);
00034
00035
00036 real bigtheta;
00037 integer pskipped, i__, p, q;
00038 real t, rootsfmin, cs, sn;
00039 integer ir1, jbc;
00040 real big;
00041 integer kbl, igl, ibr, jgl, nbl, mvl;
00042 real aapp, aapq, aaqq;
00043 integer ierr;
00044 extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
00045 real aapp0, temp1;
00046 extern doublereal snrm2_(integer *, real *, integer *);
00047 real apoaq, aqoap;
00048 extern logical lsame_(char *, char *);
00049 real theta, small, fastr[5];
00050 logical applv, rsvec;
00051 extern int scopy_(integer *, real *, integer *, real *,
00052 integer *);
00053 logical rotok;
00054 extern int sswap_(integer *, real *, integer *, real *,
00055 integer *), saxpy_(integer *, real *, real *, integer *, real *,
00056 integer *), srotm_(integer *, real *, integer *, real *, integer *
00057 , real *), xerbla_(char *, integer *);
00058 integer ijblsk, swband;
00059 extern int slascl_(char *, integer *, integer *, real *,
00060 real *, integer *, integer *, real *, integer *, integer *);
00061 extern integer isamax_(integer *, real *, integer *);
00062 integer blskip;
00063 real mxaapq, thsign;
00064 extern int slassq_(integer *, real *, integer *, real *,
00065 real *);
00066 real mxsinj;
00067 integer emptsw, notrot, iswrot, lkahead;
00068 real rootbig, rooteps;
00069 integer rowskip;
00070 real roottol;
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
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 --sva;
00220 --d__;
00221 a_dim1 = *lda;
00222 a_offset = 1 + a_dim1;
00223 a -= a_offset;
00224 v_dim1 = *ldv;
00225 v_offset = 1 + v_dim1;
00226 v -= v_offset;
00227 --work;
00228
00229
00230 applv = lsame_(jobv, "A");
00231 rsvec = lsame_(jobv, "V");
00232 if (! (rsvec || applv || lsame_(jobv, "N"))) {
00233 *info = -1;
00234 } else if (*m < 0) {
00235 *info = -2;
00236 } else if (*n < 0 || *n > *m) {
00237 *info = -3;
00238 } else if (*lda < *m) {
00239 *info = -5;
00240 } else if (*mv < 0) {
00241 *info = -8;
00242 } else if (*ldv < *m) {
00243 *info = -10;
00244 } else if (*tol <= *eps) {
00245 *info = -13;
00246 } else if (*nsweep < 0) {
00247 *info = -14;
00248 } else if (*lwork < *m) {
00249 *info = -16;
00250 } else {
00251 *info = 0;
00252 }
00253
00254
00255 if (*info != 0) {
00256 i__1 = -(*info);
00257 xerbla_("SGSVJ0", &i__1);
00258 return 0;
00259 }
00260
00261 if (rsvec) {
00262 mvl = *n;
00263 } else if (applv) {
00264 mvl = *mv;
00265 }
00266 rsvec = rsvec || applv;
00267 rooteps = sqrt(*eps);
00268 rootsfmin = sqrt(*sfmin);
00269 small = *sfmin / *eps;
00270 big = 1.f / *sfmin;
00271 rootbig = 1.f / rootsfmin;
00272 bigtheta = 1.f / rooteps;
00273 roottol = sqrt(*tol);
00274
00275
00276
00277
00278 emptsw = *n * (*n - 1) / 2;
00279 notrot = 0;
00280 fastr[0] = 0.f;
00281
00282
00283
00284 swband = 0;
00285
00286
00287
00288
00289 kbl = min(8,*n);
00290
00291
00292
00293
00294
00295 nbl = *n / kbl;
00296 if (nbl * kbl != *n) {
00297 ++nbl;
00298 }
00299
00300 i__1 = kbl;
00301 blskip = i__1 * i__1 + 1;
00302
00303 rowskip = min(5,kbl);
00304
00305 lkahead = 1;
00306
00307 swband = 0;
00308 pskipped = 0;
00309
00310 i__1 = *nsweep;
00311 for (i__ = 1; i__ <= i__1; ++i__) {
00312
00313
00314 mxaapq = 0.f;
00315 mxsinj = 0.f;
00316 iswrot = 0;
00317
00318 notrot = 0;
00319 pskipped = 0;
00320
00321 i__2 = nbl;
00322 for (ibr = 1; ibr <= i__2; ++ibr) {
00323 igl = (ibr - 1) * kbl + 1;
00324
00325
00326 i__4 = lkahead, i__5 = nbl - ibr;
00327 i__3 = min(i__4,i__5);
00328 for (ir1 = 0; ir1 <= i__3; ++ir1) {
00329
00330 igl += ir1 * kbl;
00331
00332
00333 i__5 = igl + kbl - 1, i__6 = *n - 1;
00334 i__4 = min(i__5,i__6);
00335 for (p = igl; p <= i__4; ++p) {
00336
00337 i__5 = *n - p + 1;
00338 q = isamax_(&i__5, &sva[p], &c__1) + p - 1;
00339 if (p != q) {
00340 sswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 +
00341 1], &c__1);
00342 if (rsvec) {
00343 sswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
00344 v_dim1 + 1], &c__1);
00345 }
00346 temp1 = sva[p];
00347 sva[p] = sva[q];
00348 sva[q] = temp1;
00349 temp1 = d__[p];
00350 d__[p] = d__[q];
00351 d__[q] = temp1;
00352 }
00353
00354 if (ir1 == 0) {
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368 if (sva[p] < rootbig && sva[p] > rootsfmin) {
00369 sva[p] = snrm2_(m, &a[p * a_dim1 + 1], &c__1) *
00370 d__[p];
00371 } else {
00372 temp1 = 0.f;
00373 aapp = 0.f;
00374 slassq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
00375 aapp);
00376 sva[p] = temp1 * sqrt(aapp) * d__[p];
00377 }
00378 aapp = sva[p];
00379 } else {
00380 aapp = sva[p];
00381 }
00382
00383 if (aapp > 0.f) {
00384
00385 pskipped = 0;
00386
00387
00388 i__6 = igl + kbl - 1;
00389 i__5 = min(i__6,*n);
00390 for (q = p + 1; q <= i__5; ++q) {
00391
00392 aaqq = sva[q];
00393 if (aaqq > 0.f) {
00394
00395 aapp0 = aapp;
00396 if (aaqq >= 1.f) {
00397 rotok = small * aapp <= aaqq;
00398 if (aapp < big / aaqq) {
00399 aapq = sdot_(m, &a[p * a_dim1 + 1], &
00400 c__1, &a[q * a_dim1 + 1], &
00401 c__1) * d__[p] * d__[q] /
00402 aaqq / aapp;
00403 } else {
00404 scopy_(m, &a[p * a_dim1 + 1], &c__1, &
00405 work[1], &c__1);
00406 slascl_("G", &c__0, &c__0, &aapp, &
00407 d__[p], m, &c__1, &work[1],
00408 lda, &ierr);
00409 aapq = sdot_(m, &work[1], &c__1, &a[q
00410 * a_dim1 + 1], &c__1) * d__[q]
00411 / aaqq;
00412 }
00413 } else {
00414 rotok = aapp <= aaqq / small;
00415 if (aapp > small / aaqq) {
00416 aapq = sdot_(m, &a[p * a_dim1 + 1], &
00417 c__1, &a[q * a_dim1 + 1], &
00418 c__1) * d__[p] * d__[q] /
00419 aaqq / aapp;
00420 } else {
00421 scopy_(m, &a[q * a_dim1 + 1], &c__1, &
00422 work[1], &c__1);
00423 slascl_("G", &c__0, &c__0, &aaqq, &
00424 d__[q], m, &c__1, &work[1],
00425 lda, &ierr);
00426 aapq = sdot_(m, &work[1], &c__1, &a[p
00427 * a_dim1 + 1], &c__1) * d__[p]
00428 / aapp;
00429 }
00430 }
00431
00432
00433 r__1 = mxaapq, r__2 = dabs(aapq);
00434 mxaapq = dmax(r__1,r__2);
00435
00436
00437
00438 if (dabs(aapq) > *tol) {
00439
00440
00441
00442
00443 if (ir1 == 0) {
00444 notrot = 0;
00445 pskipped = 0;
00446 ++iswrot;
00447 }
00448
00449 if (rotok) {
00450
00451 aqoap = aaqq / aapp;
00452 apoaq = aapp / aaqq;
00453 theta = (r__1 = aqoap - apoaq, dabs(
00454 r__1)) * -.5f / aapq;
00455
00456 if (dabs(theta) > bigtheta) {
00457
00458 t = .5f / theta;
00459 fastr[2] = t * d__[p] / d__[q];
00460 fastr[3] = -t * d__[q] / d__[p];
00461 srotm_(m, &a[p * a_dim1 + 1], &
00462 c__1, &a[q * a_dim1 + 1],
00463 &c__1, fastr);
00464 if (rsvec) {
00465 srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
00466 v_dim1 + 1], &c__1, fastr);
00467 }
00468
00469 r__1 = 0.f, r__2 = t * apoaq *
00470 aapq + 1.f;
00471 sva[q] = aaqq * sqrt((dmax(r__1,
00472 r__2)));
00473 aapp *= sqrt(1.f - t * aqoap *
00474 aapq);
00475
00476 r__1 = mxsinj, r__2 = dabs(t);
00477 mxsinj = dmax(r__1,r__2);
00478
00479 } else {
00480
00481
00482
00483 thsign = -r_sign(&c_b42, &aapq);
00484 t = 1.f / (theta + thsign * sqrt(
00485 theta * theta + 1.f));
00486 cs = sqrt(1.f / (t * t + 1.f));
00487 sn = t * cs;
00488
00489
00490 r__1 = mxsinj, r__2 = dabs(sn);
00491 mxsinj = dmax(r__1,r__2);
00492
00493 r__1 = 0.f, r__2 = t * apoaq *
00494 aapq + 1.f;
00495 sva[q] = aaqq * sqrt((dmax(r__1,
00496 r__2)));
00497
00498 r__1 = 0.f, r__2 = 1.f - t *
00499 aqoap * aapq;
00500 aapp *= sqrt((dmax(r__1,r__2)));
00501
00502 apoaq = d__[p] / d__[q];
00503 aqoap = d__[q] / d__[p];
00504 if (d__[p] >= 1.f) {
00505 if (d__[q] >= 1.f) {
00506 fastr[2] = t * apoaq;
00507 fastr[3] = -t * aqoap;
00508 d__[p] *= cs;
00509 d__[q] *= cs;
00510 srotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
00511 a_dim1 + 1], &c__1, fastr);
00512 if (rsvec) {
00513 srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
00514 q * v_dim1 + 1], &c__1, fastr);
00515 }
00516 } else {
00517 r__1 = -t * aqoap;
00518 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
00519 p * a_dim1 + 1], &c__1);
00520 r__1 = cs * sn * apoaq;
00521 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
00522 q * a_dim1 + 1], &c__1);
00523 d__[p] *= cs;
00524 d__[q] /= cs;
00525 if (rsvec) {
00526 r__1 = -t * aqoap;
00527 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
00528 c__1, &v[p * v_dim1 + 1], &c__1);
00529 r__1 = cs * sn * apoaq;
00530 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
00531 c__1, &v[q * v_dim1 + 1], &c__1);
00532 }
00533 }
00534 } else {
00535 if (d__[q] >= 1.f) {
00536 r__1 = t * apoaq;
00537 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
00538 q * a_dim1 + 1], &c__1);
00539 r__1 = -cs * sn * aqoap;
00540 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
00541 p * a_dim1 + 1], &c__1);
00542 d__[p] /= cs;
00543 d__[q] *= cs;
00544 if (rsvec) {
00545 r__1 = t * apoaq;
00546 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
00547 c__1, &v[q * v_dim1 + 1], &c__1);
00548 r__1 = -cs * sn * aqoap;
00549 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
00550 c__1, &v[p * v_dim1 + 1], &c__1);
00551 }
00552 } else {
00553 if (d__[p] >= d__[q]) {
00554 r__1 = -t * aqoap;
00555 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1,
00556 &a[p * a_dim1 + 1], &c__1);
00557 r__1 = cs * sn * apoaq;
00558 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1,
00559 &a[q * a_dim1 + 1], &c__1);
00560 d__[p] *= cs;
00561 d__[q] /= cs;
00562 if (rsvec) {
00563 r__1 = -t * aqoap;
00564 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1],
00565 &c__1, &v[p * v_dim1 + 1], &
00566 c__1);
00567 r__1 = cs * sn * apoaq;
00568 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1],
00569 &c__1, &v[q * v_dim1 + 1], &
00570 c__1);
00571 }
00572 } else {
00573 r__1 = t * apoaq;
00574 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1,
00575 &a[q * a_dim1 + 1], &c__1);
00576 r__1 = -cs * sn * aqoap;
00577 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1,
00578 &a[p * a_dim1 + 1], &c__1);
00579 d__[p] /= cs;
00580 d__[q] *= cs;
00581 if (rsvec) {
00582 r__1 = t * apoaq;
00583 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1],
00584 &c__1, &v[q * v_dim1 + 1], &
00585 c__1);
00586 r__1 = -cs * sn * aqoap;
00587 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1],
00588 &c__1, &v[p * v_dim1 + 1], &
00589 c__1);
00590 }
00591 }
00592 }
00593 }
00594 }
00595
00596 } else {
00597
00598 scopy_(m, &a[p * a_dim1 + 1], &c__1, &
00599 work[1], &c__1);
00600 slascl_("G", &c__0, &c__0, &aapp, &
00601 c_b42, m, &c__1, &work[1],
00602 lda, &ierr);
00603 slascl_("G", &c__0, &c__0, &aaqq, &
00604 c_b42, m, &c__1, &a[q *
00605 a_dim1 + 1], lda, &ierr);
00606 temp1 = -aapq * d__[p] / d__[q];
00607 saxpy_(m, &temp1, &work[1], &c__1, &a[
00608 q * a_dim1 + 1], &c__1);
00609 slascl_("G", &c__0, &c__0, &c_b42, &
00610 aaqq, m, &c__1, &a[q * a_dim1
00611 + 1], lda, &ierr);
00612
00613 r__1 = 0.f, r__2 = 1.f - aapq * aapq;
00614 sva[q] = aaqq * sqrt((dmax(r__1,r__2))
00615 );
00616 mxsinj = dmax(mxsinj,*sfmin);
00617 }
00618
00619
00620
00621
00622
00623 r__1 = sva[q] / aaqq;
00624 if (r__1 * r__1 <= rooteps) {
00625 if (aaqq < rootbig && aaqq >
00626 rootsfmin) {
00627 sva[q] = snrm2_(m, &a[q * a_dim1
00628 + 1], &c__1) * d__[q];
00629 } else {
00630 t = 0.f;
00631 aaqq = 0.f;
00632 slassq_(m, &a[q * a_dim1 + 1], &
00633 c__1, &t, &aaqq);
00634 sva[q] = t * sqrt(aaqq) * d__[q];
00635 }
00636 }
00637 if (aapp / aapp0 <= rooteps) {
00638 if (aapp < rootbig && aapp >
00639 rootsfmin) {
00640 aapp = snrm2_(m, &a[p * a_dim1 +
00641 1], &c__1) * d__[p];
00642 } else {
00643 t = 0.f;
00644 aapp = 0.f;
00645 slassq_(m, &a[p * a_dim1 + 1], &
00646 c__1, &t, &aapp);
00647 aapp = t * sqrt(aapp) * d__[p];
00648 }
00649 sva[p] = aapp;
00650 }
00651
00652 } else {
00653
00654 if (ir1 == 0) {
00655 ++notrot;
00656 }
00657 ++pskipped;
00658 }
00659 } else {
00660
00661 if (ir1 == 0) {
00662 ++notrot;
00663 }
00664 ++pskipped;
00665 }
00666
00667 if (i__ <= swband && pskipped > rowskip) {
00668 if (ir1 == 0) {
00669 aapp = -aapp;
00670 }
00671 notrot = 0;
00672 goto L2103;
00673 }
00674
00675
00676 }
00677
00678
00679 L2103:
00680
00681 sva[p] = aapp;
00682 } else {
00683 sva[p] = aapp;
00684 if (ir1 == 0 && aapp == 0.f) {
00685
00686 i__5 = igl + kbl - 1;
00687 notrot = notrot + min(i__5,*n) - p;
00688 }
00689 }
00690
00691
00692 }
00693
00694
00695
00696 }
00697
00698
00699
00700
00701
00702 igl = (ibr - 1) * kbl + 1;
00703
00704 i__3 = nbl;
00705 for (jbc = ibr + 1; jbc <= i__3; ++jbc) {
00706
00707 jgl = (jbc - 1) * kbl + 1;
00708
00709
00710
00711 ijblsk = 0;
00712
00713 i__5 = igl + kbl - 1;
00714 i__4 = min(i__5,*n);
00715 for (p = igl; p <= i__4; ++p) {
00716
00717 aapp = sva[p];
00718
00719 if (aapp > 0.f) {
00720
00721 pskipped = 0;
00722
00723
00724 i__6 = jgl + kbl - 1;
00725 i__5 = min(i__6,*n);
00726 for (q = jgl; q <= i__5; ++q) {
00727
00728 aaqq = sva[q];
00729
00730 if (aaqq > 0.f) {
00731 aapp0 = aapp;
00732
00733
00734
00735
00736
00737 if (aaqq >= 1.f) {
00738 if (aapp >= aaqq) {
00739 rotok = small * aapp <= aaqq;
00740 } else {
00741 rotok = small * aaqq <= aapp;
00742 }
00743 if (aapp < big / aaqq) {
00744 aapq = sdot_(m, &a[p * a_dim1 + 1], &
00745 c__1, &a[q * a_dim1 + 1], &
00746 c__1) * d__[p] * d__[q] /
00747 aaqq / aapp;
00748 } else {
00749 scopy_(m, &a[p * a_dim1 + 1], &c__1, &
00750 work[1], &c__1);
00751 slascl_("G", &c__0, &c__0, &aapp, &
00752 d__[p], m, &c__1, &work[1],
00753 lda, &ierr);
00754 aapq = sdot_(m, &work[1], &c__1, &a[q
00755 * a_dim1 + 1], &c__1) * d__[q]
00756 / aaqq;
00757 }
00758 } else {
00759 if (aapp >= aaqq) {
00760 rotok = aapp <= aaqq / small;
00761 } else {
00762 rotok = aaqq <= aapp / small;
00763 }
00764 if (aapp > small / aaqq) {
00765 aapq = sdot_(m, &a[p * a_dim1 + 1], &
00766 c__1, &a[q * a_dim1 + 1], &
00767 c__1) * d__[p] * d__[q] /
00768 aaqq / aapp;
00769 } else {
00770 scopy_(m, &a[q * a_dim1 + 1], &c__1, &
00771 work[1], &c__1);
00772 slascl_("G", &c__0, &c__0, &aaqq, &
00773 d__[q], m, &c__1, &work[1],
00774 lda, &ierr);
00775 aapq = sdot_(m, &work[1], &c__1, &a[p
00776 * a_dim1 + 1], &c__1) * d__[p]
00777 / aapp;
00778 }
00779 }
00780
00781
00782 r__1 = mxaapq, r__2 = dabs(aapq);
00783 mxaapq = dmax(r__1,r__2);
00784
00785
00786
00787 if (dabs(aapq) > *tol) {
00788 notrot = 0;
00789
00790 pskipped = 0;
00791 ++iswrot;
00792
00793 if (rotok) {
00794
00795 aqoap = aaqq / aapp;
00796 apoaq = aapp / aaqq;
00797 theta = (r__1 = aqoap - apoaq, dabs(
00798 r__1)) * -.5f / aapq;
00799 if (aaqq > aapp0) {
00800 theta = -theta;
00801 }
00802
00803 if (dabs(theta) > bigtheta) {
00804 t = .5f / theta;
00805 fastr[2] = t * d__[p] / d__[q];
00806 fastr[3] = -t * d__[q] / d__[p];
00807 srotm_(m, &a[p * a_dim1 + 1], &
00808 c__1, &a[q * a_dim1 + 1],
00809 &c__1, fastr);
00810 if (rsvec) {
00811 srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
00812 v_dim1 + 1], &c__1, fastr);
00813 }
00814
00815 r__1 = 0.f, r__2 = t * apoaq *
00816 aapq + 1.f;
00817 sva[q] = aaqq * sqrt((dmax(r__1,
00818 r__2)));
00819
00820 r__1 = 0.f, r__2 = 1.f - t *
00821 aqoap * aapq;
00822 aapp *= sqrt((dmax(r__1,r__2)));
00823
00824 r__1 = mxsinj, r__2 = dabs(t);
00825 mxsinj = dmax(r__1,r__2);
00826 } else {
00827
00828
00829
00830 thsign = -r_sign(&c_b42, &aapq);
00831 if (aaqq > aapp0) {
00832 thsign = -thsign;
00833 }
00834 t = 1.f / (theta + thsign * sqrt(
00835 theta * theta + 1.f));
00836 cs = sqrt(1.f / (t * t + 1.f));
00837 sn = t * cs;
00838
00839 r__1 = mxsinj, r__2 = dabs(sn);
00840 mxsinj = dmax(r__1,r__2);
00841
00842 r__1 = 0.f, r__2 = t * apoaq *
00843 aapq + 1.f;
00844 sva[q] = aaqq * sqrt((dmax(r__1,
00845 r__2)));
00846 aapp *= sqrt(1.f - t * aqoap *
00847 aapq);
00848
00849 apoaq = d__[p] / d__[q];
00850 aqoap = d__[q] / d__[p];
00851 if (d__[p] >= 1.f) {
00852
00853 if (d__[q] >= 1.f) {
00854 fastr[2] = t * apoaq;
00855 fastr[3] = -t * aqoap;
00856 d__[p] *= cs;
00857 d__[q] *= cs;
00858 srotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
00859 a_dim1 + 1], &c__1, fastr);
00860 if (rsvec) {
00861 srotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
00862 q * v_dim1 + 1], &c__1, fastr);
00863 }
00864 } else {
00865 r__1 = -t * aqoap;
00866 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
00867 p * a_dim1 + 1], &c__1);
00868 r__1 = cs * sn * apoaq;
00869 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
00870 q * a_dim1 + 1], &c__1);
00871 if (rsvec) {
00872 r__1 = -t * aqoap;
00873 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
00874 c__1, &v[p * v_dim1 + 1], &c__1);
00875 r__1 = cs * sn * apoaq;
00876 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
00877 c__1, &v[q * v_dim1 + 1], &c__1);
00878 }
00879 d__[p] *= cs;
00880 d__[q] /= cs;
00881 }
00882 } else {
00883 if (d__[q] >= 1.f) {
00884 r__1 = t * apoaq;
00885 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1, &a[
00886 q * a_dim1 + 1], &c__1);
00887 r__1 = -cs * sn * aqoap;
00888 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1, &a[
00889 p * a_dim1 + 1], &c__1);
00890 if (rsvec) {
00891 r__1 = t * apoaq;
00892 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1], &
00893 c__1, &v[q * v_dim1 + 1], &c__1);
00894 r__1 = -cs * sn * aqoap;
00895 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1], &
00896 c__1, &v[p * v_dim1 + 1], &c__1);
00897 }
00898 d__[p] /= cs;
00899 d__[q] *= cs;
00900 } else {
00901 if (d__[p] >= d__[q]) {
00902 r__1 = -t * aqoap;
00903 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1,
00904 &a[p * a_dim1 + 1], &c__1);
00905 r__1 = cs * sn * apoaq;
00906 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1,
00907 &a[q * a_dim1 + 1], &c__1);
00908 d__[p] *= cs;
00909 d__[q] /= cs;
00910 if (rsvec) {
00911 r__1 = -t * aqoap;
00912 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1],
00913 &c__1, &v[p * v_dim1 + 1], &
00914 c__1);
00915 r__1 = cs * sn * apoaq;
00916 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1],
00917 &c__1, &v[q * v_dim1 + 1], &
00918 c__1);
00919 }
00920 } else {
00921 r__1 = t * apoaq;
00922 saxpy_(m, &r__1, &a[p * a_dim1 + 1], &c__1,
00923 &a[q * a_dim1 + 1], &c__1);
00924 r__1 = -cs * sn * aqoap;
00925 saxpy_(m, &r__1, &a[q * a_dim1 + 1], &c__1,
00926 &a[p * a_dim1 + 1], &c__1);
00927 d__[p] /= cs;
00928 d__[q] *= cs;
00929 if (rsvec) {
00930 r__1 = t * apoaq;
00931 saxpy_(&mvl, &r__1, &v[p * v_dim1 + 1],
00932 &c__1, &v[q * v_dim1 + 1], &
00933 c__1);
00934 r__1 = -cs * sn * aqoap;
00935 saxpy_(&mvl, &r__1, &v[q * v_dim1 + 1],
00936 &c__1, &v[p * v_dim1 + 1], &
00937 c__1);
00938 }
00939 }
00940 }
00941 }
00942 }
00943
00944 } else {
00945 if (aapp > aaqq) {
00946 scopy_(m, &a[p * a_dim1 + 1], &
00947 c__1, &work[1], &c__1);
00948 slascl_("G", &c__0, &c__0, &aapp,
00949 &c_b42, m, &c__1, &work[1]
00950 , lda, &ierr);
00951 slascl_("G", &c__0, &c__0, &aaqq,
00952 &c_b42, m, &c__1, &a[q *
00953 a_dim1 + 1], lda, &ierr);
00954 temp1 = -aapq * d__[p] / d__[q];
00955 saxpy_(m, &temp1, &work[1], &c__1,
00956 &a[q * a_dim1 + 1], &
00957 c__1);
00958 slascl_("G", &c__0, &c__0, &c_b42,
00959 &aaqq, m, &c__1, &a[q *
00960 a_dim1 + 1], lda, &ierr);
00961
00962 r__1 = 0.f, r__2 = 1.f - aapq *
00963 aapq;
00964 sva[q] = aaqq * sqrt((dmax(r__1,
00965 r__2)));
00966 mxsinj = dmax(mxsinj,*sfmin);
00967 } else {
00968 scopy_(m, &a[q * a_dim1 + 1], &
00969 c__1, &work[1], &c__1);
00970 slascl_("G", &c__0, &c__0, &aaqq,
00971 &c_b42, m, &c__1, &work[1]
00972 , lda, &ierr);
00973 slascl_("G", &c__0, &c__0, &aapp,
00974 &c_b42, m, &c__1, &a[p *
00975 a_dim1 + 1], lda, &ierr);
00976 temp1 = -aapq * d__[q] / d__[p];
00977 saxpy_(m, &temp1, &work[1], &c__1,
00978 &a[p * a_dim1 + 1], &
00979 c__1);
00980 slascl_("G", &c__0, &c__0, &c_b42,
00981 &aapp, m, &c__1, &a[p *
00982 a_dim1 + 1], lda, &ierr);
00983
00984 r__1 = 0.f, r__2 = 1.f - aapq *
00985 aapq;
00986 sva[p] = aapp * sqrt((dmax(r__1,
00987 r__2)));
00988 mxsinj = dmax(mxsinj,*sfmin);
00989 }
00990 }
00991
00992
00993
00994
00995
00996 r__1 = sva[q] / aaqq;
00997 if (r__1 * r__1 <= rooteps) {
00998 if (aaqq < rootbig && aaqq >
00999 rootsfmin) {
01000 sva[q] = snrm2_(m, &a[q * a_dim1
01001 + 1], &c__1) * d__[q];
01002 } else {
01003 t = 0.f;
01004 aaqq = 0.f;
01005 slassq_(m, &a[q * a_dim1 + 1], &
01006 c__1, &t, &aaqq);
01007 sva[q] = t * sqrt(aaqq) * d__[q];
01008 }
01009 }
01010
01011 r__1 = aapp / aapp0;
01012 if (r__1 * r__1 <= rooteps) {
01013 if (aapp < rootbig && aapp >
01014 rootsfmin) {
01015 aapp = snrm2_(m, &a[p * a_dim1 +
01016 1], &c__1) * d__[p];
01017 } else {
01018 t = 0.f;
01019 aapp = 0.f;
01020 slassq_(m, &a[p * a_dim1 + 1], &
01021 c__1, &t, &aapp);
01022 aapp = t * sqrt(aapp) * d__[p];
01023 }
01024 sva[p] = aapp;
01025 }
01026
01027 } else {
01028 ++notrot;
01029 ++pskipped;
01030 ++ijblsk;
01031 }
01032 } else {
01033 ++notrot;
01034 ++pskipped;
01035 ++ijblsk;
01036 }
01037
01038 if (i__ <= swband && ijblsk >= blskip) {
01039 sva[p] = aapp;
01040 notrot = 0;
01041 goto L2011;
01042 }
01043 if (i__ <= swband && pskipped > rowskip) {
01044 aapp = -aapp;
01045 notrot = 0;
01046 goto L2203;
01047 }
01048
01049
01050 }
01051
01052 L2203:
01053
01054 sva[p] = aapp;
01055
01056 } else {
01057 if (aapp == 0.f) {
01058
01059 i__5 = jgl + kbl - 1;
01060 notrot = notrot + min(i__5,*n) - jgl + 1;
01061 }
01062 if (aapp < 0.f) {
01063 notrot = 0;
01064 }
01065 }
01066
01067 }
01068
01069
01070 }
01071
01072 L2011:
01073
01074
01075 i__4 = igl + kbl - 1;
01076 i__3 = min(i__4,*n);
01077 for (p = igl; p <= i__3; ++p) {
01078 sva[p] = (r__1 = sva[p], dabs(r__1));
01079
01080 }
01081
01082
01083 }
01084
01085
01086
01087 if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
01088 sva[*n] = snrm2_(m, &a[*n * a_dim1 + 1], &c__1) * d__[*n];
01089 } else {
01090 t = 0.f;
01091 aapp = 0.f;
01092 slassq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
01093 sva[*n] = t * sqrt(aapp) * d__[*n];
01094 }
01095
01096
01097
01098 if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
01099 swband = i__;
01100 }
01101
01102 if (i__ > swband + 1 && mxaapq < (real) (*n) * *tol && (real) (*n) *
01103 mxaapq * mxsinj < *tol) {
01104 goto L1994;
01105 }
01106
01107 if (notrot >= emptsw) {
01108 goto L1994;
01109 }
01110
01111 }
01112
01113
01114
01115 *info = *nsweep - 1;
01116 goto L1995;
01117 L1994:
01118
01119
01120
01121 *info = 0;
01122
01123 L1995:
01124
01125
01126 i__1 = *n - 1;
01127 for (p = 1; p <= i__1; ++p) {
01128 i__2 = *n - p + 1;
01129 q = isamax_(&i__2, &sva[p], &c__1) + p - 1;
01130 if (p != q) {
01131 temp1 = sva[p];
01132 sva[p] = sva[q];
01133 sva[q] = temp1;
01134 temp1 = d__[p];
01135 d__[p] = d__[q];
01136 d__[q] = temp1;
01137 sswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
01138 if (rsvec) {
01139 sswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
01140 c__1);
01141 }
01142 }
01143
01144 }
01145
01146 return 0;
01147
01148
01149
01150 }