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