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 doublereal c_b17 = 0.;
00019 static doublereal c_b18 = 1.;
00020 static integer c__1 = 1;
00021 static integer c__0 = 0;
00022 static integer c__2 = 2;
00023
00024 int dgesvj_(char *joba, char *jobu, char *jobv, integer *m,
00025 integer *n, doublereal *a, integer *lda, doublereal *sva, integer *mv,
00026 doublereal *v, integer *ldv, doublereal *work, integer *lwork,
00027 integer *info)
00028 {
00029
00030 integer a_dim1, a_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4, i__5;
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;
00040 integer n2, n4;
00041 doublereal rootsfmin;
00042 integer n34;
00043 doublereal cs, sn;
00044 integer ir1, jbc;
00045 doublereal big;
00046 integer kbl, igl, ibr, jgl, nbl;
00047 doublereal tol;
00048 integer mvl;
00049 doublereal aapp, aapq, aaqq;
00050 extern doublereal ddot_(integer *, doublereal *, integer *, doublereal *,
00051 integer *);
00052 doublereal ctol;
00053 integer ierr;
00054 doublereal aapp0;
00055 extern doublereal dnrm2_(integer *, doublereal *, integer *);
00056 doublereal temp1;
00057 extern int dscal_(integer *, doublereal *, doublereal *,
00058 integer *);
00059 doublereal scale, large, apoaq, aqoap;
00060 extern logical lsame_(char *, char *);
00061 doublereal theta, small, sfmin;
00062 logical lsvec;
00063 extern int dcopy_(integer *, doublereal *, integer *,
00064 doublereal *, integer *);
00065 doublereal fastr[5];
00066 extern int dswap_(integer *, doublereal *, integer *,
00067 doublereal *, integer *);
00068 logical applv, rsvec;
00069 extern int daxpy_(integer *, doublereal *, doublereal *,
00070 integer *, doublereal *, integer *);
00071 logical uctol;
00072 extern int drotm_(integer *, doublereal *, integer *,
00073 doublereal *, integer *, doublereal *);
00074 logical lower, upper, rotok;
00075 extern int dgsvj0_(char *, integer *, integer *,
00076 doublereal *, integer *, doublereal *, doublereal *, integer *,
00077 doublereal *, integer *, doublereal *, doublereal *, doublereal *,
00078 integer *, doublereal *, integer *, integer *), dgsvj1_(
00079 char *, integer *, integer *, integer *, doublereal *, integer *,
00080 doublereal *, doublereal *, integer *, doublereal *, integer *,
00081 doublereal *, doublereal *, doublereal *, integer *, doublereal *,
00082 integer *, integer *);
00083 extern doublereal dlamch_(char *);
00084 extern int dlascl_(char *, integer *, integer *,
00085 doublereal *, doublereal *, integer *, integer *, doublereal *,
00086 integer *, integer *);
00087 extern integer idamax_(integer *, doublereal *, integer *);
00088 extern int dlaset_(char *, integer *, integer *,
00089 doublereal *, doublereal *, doublereal *, integer *),
00090 xerbla_(char *, integer *);
00091 integer ijblsk, swband, blskip;
00092 doublereal mxaapq;
00093 extern int dlassq_(integer *, doublereal *, integer *,
00094 doublereal *, doublereal *);
00095 doublereal thsign, mxsinj;
00096 integer emptsw, notrot, iswrot, lkahead;
00097 logical goscale, noscale;
00098 doublereal rootbig, epsilon, rooteps;
00099 integer rowskip;
00100 doublereal roottol;
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
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384 --sva;
00385 a_dim1 = *lda;
00386 a_offset = 1 + a_dim1;
00387 a -= a_offset;
00388 v_dim1 = *ldv;
00389 v_offset = 1 + v_dim1;
00390 v -= v_offset;
00391 --work;
00392
00393
00394 lsvec = lsame_(jobu, "U");
00395 uctol = lsame_(jobu, "C");
00396 rsvec = lsame_(jobv, "V");
00397 applv = lsame_(jobv, "A");
00398 upper = lsame_(joba, "U");
00399 lower = lsame_(joba, "L");
00400
00401 if (! (upper || lower || lsame_(joba, "G"))) {
00402 *info = -1;
00403 } else if (! (lsvec || uctol || lsame_(jobu, "N")))
00404 {
00405 *info = -2;
00406 } else if (! (rsvec || applv || lsame_(jobv, "N")))
00407 {
00408 *info = -3;
00409 } else if (*m < 0) {
00410 *info = -4;
00411 } else if (*n < 0 || *n > *m) {
00412 *info = -5;
00413 } else if (*lda < *m) {
00414 *info = -7;
00415 } else if (*mv < 0) {
00416 *info = -9;
00417 } else if (rsvec && *ldv < *n || applv && *ldv < *mv) {
00418 *info = -11;
00419 } else if (uctol && work[1] <= 1.) {
00420 *info = -12;
00421 } else {
00422
00423 i__1 = *m + *n;
00424 if (*lwork < max(i__1,6)) {
00425 *info = -13;
00426 } else {
00427 *info = 0;
00428 }
00429 }
00430
00431
00432 if (*info != 0) {
00433 i__1 = -(*info);
00434 xerbla_("DGESVJ", &i__1);
00435 return 0;
00436 }
00437
00438
00439
00440 if (*m == 0 || *n == 0) {
00441 return 0;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451 if (uctol) {
00452
00453 ctol = work[1];
00454 } else {
00455
00456 if (lsvec || rsvec || applv) {
00457 ctol = sqrt((doublereal) (*m));
00458 } else {
00459 ctol = (doublereal) (*m);
00460 }
00461 }
00462
00463
00464
00465 epsilon = dlamch_("Epsilon");
00466 rooteps = sqrt(epsilon);
00467 sfmin = dlamch_("SafeMinimum");
00468 rootsfmin = sqrt(sfmin);
00469 small = sfmin / epsilon;
00470 big = dlamch_("Overflow");
00471
00472 rootbig = 1. / rootsfmin;
00473 large = big / sqrt((doublereal) (*m * *n));
00474 bigtheta = 1. / rooteps;
00475
00476 tol = ctol * epsilon;
00477 roottol = sqrt(tol);
00478
00479 if ((doublereal) (*m) * epsilon >= 1.) {
00480 *info = -5;
00481 i__1 = -(*info);
00482 xerbla_("DGESVJ", &i__1);
00483 return 0;
00484 }
00485
00486
00487
00488 if (rsvec) {
00489 mvl = *n;
00490 dlaset_("A", &mvl, n, &c_b17, &c_b18, &v[v_offset], ldv);
00491 } else if (applv) {
00492 mvl = *mv;
00493 }
00494 rsvec = rsvec || applv;
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505 scale = 1. / sqrt((doublereal) (*m) * (doublereal) (*n));
00506 noscale = TRUE_;
00507 goscale = TRUE_;
00508
00509 if (lower) {
00510
00511 i__1 = *n;
00512 for (p = 1; p <= i__1; ++p) {
00513 aapp = 0.;
00514 aaqq = 0.;
00515 i__2 = *m - p + 1;
00516 dlassq_(&i__2, &a[p + p * a_dim1], &c__1, &aapp, &aaqq);
00517 if (aapp > big) {
00518 *info = -6;
00519 i__2 = -(*info);
00520 xerbla_("DGESVJ", &i__2);
00521 return 0;
00522 }
00523 aaqq = sqrt(aaqq);
00524 if (aapp < big / aaqq && noscale) {
00525 sva[p] = aapp * aaqq;
00526 } else {
00527 noscale = FALSE_;
00528 sva[p] = aapp * (aaqq * scale);
00529 if (goscale) {
00530 goscale = FALSE_;
00531 i__2 = p - 1;
00532 for (q = 1; q <= i__2; ++q) {
00533 sva[q] *= scale;
00534
00535 }
00536 }
00537 }
00538
00539 }
00540 } else if (upper) {
00541
00542 i__1 = *n;
00543 for (p = 1; p <= i__1; ++p) {
00544 aapp = 0.;
00545 aaqq = 0.;
00546 dlassq_(&p, &a[p * a_dim1 + 1], &c__1, &aapp, &aaqq);
00547 if (aapp > big) {
00548 *info = -6;
00549 i__2 = -(*info);
00550 xerbla_("DGESVJ", &i__2);
00551 return 0;
00552 }
00553 aaqq = sqrt(aaqq);
00554 if (aapp < big / aaqq && noscale) {
00555 sva[p] = aapp * aaqq;
00556 } else {
00557 noscale = FALSE_;
00558 sva[p] = aapp * (aaqq * scale);
00559 if (goscale) {
00560 goscale = FALSE_;
00561 i__2 = p - 1;
00562 for (q = 1; q <= i__2; ++q) {
00563 sva[q] *= scale;
00564
00565 }
00566 }
00567 }
00568
00569 }
00570 } else {
00571
00572 i__1 = *n;
00573 for (p = 1; p <= i__1; ++p) {
00574 aapp = 0.;
00575 aaqq = 0.;
00576 dlassq_(m, &a[p * a_dim1 + 1], &c__1, &aapp, &aaqq);
00577 if (aapp > big) {
00578 *info = -6;
00579 i__2 = -(*info);
00580 xerbla_("DGESVJ", &i__2);
00581 return 0;
00582 }
00583 aaqq = sqrt(aaqq);
00584 if (aapp < big / aaqq && noscale) {
00585 sva[p] = aapp * aaqq;
00586 } else {
00587 noscale = FALSE_;
00588 sva[p] = aapp * (aaqq * scale);
00589 if (goscale) {
00590 goscale = FALSE_;
00591 i__2 = p - 1;
00592 for (q = 1; q <= i__2; ++q) {
00593 sva[q] *= scale;
00594
00595 }
00596 }
00597 }
00598
00599 }
00600 }
00601
00602 if (noscale) {
00603 scale = 1.;
00604 }
00605
00606
00607
00608
00609
00610 aapp = 0.;
00611 aaqq = big;
00612 i__1 = *n;
00613 for (p = 1; p <= i__1; ++p) {
00614 if (sva[p] != 0.) {
00615
00616 d__1 = aaqq, d__2 = sva[p];
00617 aaqq = min(d__1,d__2);
00618 }
00619
00620 d__1 = aapp, d__2 = sva[p];
00621 aapp = max(d__1,d__2);
00622
00623 }
00624
00625
00626
00627 if (aapp == 0.) {
00628 if (lsvec) {
00629 dlaset_("G", m, n, &c_b17, &c_b18, &a[a_offset], lda);
00630 }
00631 work[1] = 1.;
00632 work[2] = 0.;
00633 work[3] = 0.;
00634 work[4] = 0.;
00635 work[5] = 0.;
00636 work[6] = 0.;
00637 return 0;
00638 }
00639
00640
00641
00642 if (*n == 1) {
00643 if (lsvec) {
00644 dlascl_("G", &c__0, &c__0, &sva[1], &scale, m, &c__1, &a[a_dim1 +
00645 1], lda, &ierr);
00646 }
00647 work[1] = 1. / scale;
00648 if (sva[1] >= sfmin) {
00649 work[2] = 1.;
00650 } else {
00651 work[2] = 0.;
00652 }
00653 work[3] = 0.;
00654 work[4] = 0.;
00655 work[5] = 0.;
00656 work[6] = 0.;
00657 return 0;
00658 }
00659
00660
00661
00662
00663 sn = sqrt(sfmin / epsilon);
00664 temp1 = sqrt(big / (doublereal) (*n));
00665 if (aapp <= sn || aaqq >= temp1 || sn <= aaqq && aapp <= temp1) {
00666
00667 d__1 = big, d__2 = temp1 / aapp;
00668 temp1 = min(d__1,d__2);
00669
00670
00671 } else if (aaqq <= sn && aapp <= temp1) {
00672
00673 d__1 = sn / aaqq, d__2 = big / (aapp * sqrt((doublereal) (*n)));
00674 temp1 = min(d__1,d__2);
00675
00676
00677 } else if (aaqq >= sn && aapp >= temp1) {
00678
00679 d__1 = sn / aaqq, d__2 = temp1 / aapp;
00680 temp1 = max(d__1,d__2);
00681
00682
00683 } else if (aaqq <= sn && aapp >= temp1) {
00684
00685 d__1 = sn / aaqq, d__2 = big / (sqrt((doublereal) (*n)) * aapp);
00686 temp1 = min(d__1,d__2);
00687
00688
00689 } else {
00690 temp1 = 1.;
00691 }
00692
00693
00694
00695 if (temp1 != 1.) {
00696 dlascl_("G", &c__0, &c__0, &c_b18, &temp1, n, &c__1, &sva[1], n, &
00697 ierr);
00698 }
00699 scale = temp1 * scale;
00700 if (scale != 1.) {
00701 dlascl_(joba, &c__0, &c__0, &c_b18, &scale, m, n, &a[a_offset], lda, &
00702 ierr);
00703 scale = 1. / scale;
00704 }
00705
00706
00707
00708 emptsw = *n * (*n - 1) / 2;
00709 notrot = 0;
00710 fastr[0] = 0.;
00711
00712
00713
00714
00715
00716 i__1 = *n;
00717 for (q = 1; q <= i__1; ++q) {
00718 work[q] = 1.;
00719
00720 }
00721
00722
00723 swband = 3;
00724
00725
00726
00727
00728
00729
00730
00731 kbl = min(8,*n);
00732
00733
00734
00735
00736
00737 nbl = *n / kbl;
00738 if (nbl * kbl != *n) {
00739 ++nbl;
00740 }
00741
00742
00743 i__1 = kbl;
00744 blskip = i__1 * i__1;
00745
00746
00747 rowskip = min(5,kbl);
00748
00749
00750 lkahead = 1;
00751
00752
00753
00754
00755
00756
00757
00758
00759 i__1 = 64, i__2 = kbl << 2;
00760 if ((lower || upper) && *n > max(i__1,i__2)) {
00761
00762
00763 n4 = *n / 4;
00764 n2 = *n / 2;
00765 n34 = n4 * 3;
00766 if (applv) {
00767 q = 0;
00768 } else {
00769 q = 1;
00770 }
00771
00772 if (lower) {
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782 i__1 = *m - n34;
00783 i__2 = *n - n34;
00784 i__3 = *lwork - *n;
00785 dgsvj0_(jobv, &i__1, &i__2, &a[n34 + 1 + (n34 + 1) * a_dim1], lda,
00786 &work[n34 + 1], &sva[n34 + 1], &mvl, &v[n34 * q + 1 + (
00787 n34 + 1) * v_dim1], ldv, &epsilon, &sfmin, &tol, &c__2, &
00788 work[*n + 1], &i__3, &ierr);
00789
00790 i__1 = *m - n2;
00791 i__2 = n34 - n2;
00792 i__3 = *lwork - *n;
00793 dgsvj0_(jobv, &i__1, &i__2, &a[n2 + 1 + (n2 + 1) * a_dim1], lda, &
00794 work[n2 + 1], &sva[n2 + 1], &mvl, &v[n2 * q + 1 + (n2 + 1)
00795 * v_dim1], ldv, &epsilon, &sfmin, &tol, &c__2, &work[*n
00796 + 1], &i__3, &ierr);
00797
00798 i__1 = *m - n2;
00799 i__2 = *n - n2;
00800 i__3 = *lwork - *n;
00801 dgsvj1_(jobv, &i__1, &i__2, &n4, &a[n2 + 1 + (n2 + 1) * a_dim1],
00802 lda, &work[n2 + 1], &sva[n2 + 1], &mvl, &v[n2 * q + 1 + (
00803 n2 + 1) * v_dim1], ldv, &epsilon, &sfmin, &tol, &c__1, &
00804 work[*n + 1], &i__3, &ierr);
00805
00806 i__1 = *m - n4;
00807 i__2 = n2 - n4;
00808 i__3 = *lwork - *n;
00809 dgsvj0_(jobv, &i__1, &i__2, &a[n4 + 1 + (n4 + 1) * a_dim1], lda, &
00810 work[n4 + 1], &sva[n4 + 1], &mvl, &v[n4 * q + 1 + (n4 + 1)
00811 * v_dim1], ldv, &epsilon, &sfmin, &tol, &c__1, &work[*n
00812 + 1], &i__3, &ierr);
00813
00814 i__1 = *lwork - *n;
00815 dgsvj0_(jobv, m, &n4, &a[a_offset], lda, &work[1], &sva[1], &mvl,
00816 &v[v_offset], ldv, &epsilon, &sfmin, &tol, &c__1, &work[*
00817 n + 1], &i__1, &ierr);
00818
00819 i__1 = *lwork - *n;
00820 dgsvj1_(jobv, m, &n2, &n4, &a[a_offset], lda, &work[1], &sva[1], &
00821 mvl, &v[v_offset], ldv, &epsilon, &sfmin, &tol, &c__1, &
00822 work[*n + 1], &i__1, &ierr);
00823
00824
00825 } else if (upper) {
00826
00827
00828 i__1 = *lwork - *n;
00829 dgsvj0_(jobv, &n4, &n4, &a[a_offset], lda, &work[1], &sva[1], &
00830 mvl, &v[v_offset], ldv, &epsilon, &sfmin, &tol, &c__2, &
00831 work[*n + 1], &i__1, &ierr);
00832
00833 i__1 = *lwork - *n;
00834 dgsvj0_(jobv, &n2, &n4, &a[(n4 + 1) * a_dim1 + 1], lda, &work[n4
00835 + 1], &sva[n4 + 1], &mvl, &v[n4 * q + 1 + (n4 + 1) *
00836 v_dim1], ldv, &epsilon, &sfmin, &tol, &c__1, &work[*n + 1]
00837 , &i__1, &ierr);
00838
00839 i__1 = *lwork - *n;
00840 dgsvj1_(jobv, &n2, &n2, &n4, &a[a_offset], lda, &work[1], &sva[1],
00841 &mvl, &v[v_offset], ldv, &epsilon, &sfmin, &tol, &c__1, &
00842 work[*n + 1], &i__1, &ierr);
00843
00844 i__1 = n2 + n4;
00845 i__2 = *lwork - *n;
00846 dgsvj0_(jobv, &i__1, &n4, &a[(n2 + 1) * a_dim1 + 1], lda, &work[
00847 n2 + 1], &sva[n2 + 1], &mvl, &v[n2 * q + 1 + (n2 + 1) *
00848 v_dim1], ldv, &epsilon, &sfmin, &tol, &c__1, &work[*n + 1]
00849 , &i__2, &ierr);
00850 }
00851
00852 }
00853
00854
00855
00856 for (i__ = 1; i__ <= 30; ++i__) {
00857
00858
00859
00860 mxaapq = 0.;
00861 mxsinj = 0.;
00862 iswrot = 0;
00863
00864 notrot = 0;
00865 pskipped = 0;
00866
00867
00868
00869
00870
00871
00872 i__1 = nbl;
00873 for (ibr = 1; ibr <= i__1; ++ibr) {
00874
00875 igl = (ibr - 1) * kbl + 1;
00876
00877
00878 i__3 = lkahead, i__4 = nbl - ibr;
00879 i__2 = min(i__3,i__4);
00880 for (ir1 = 0; ir1 <= i__2; ++ir1) {
00881
00882 igl += ir1 * kbl;
00883
00884
00885 i__4 = igl + kbl - 1, i__5 = *n - 1;
00886 i__3 = min(i__4,i__5);
00887 for (p = igl; p <= i__3; ++p) {
00888
00889
00890
00891 i__4 = *n - p + 1;
00892 q = idamax_(&i__4, &sva[p], &c__1) + p - 1;
00893 if (p != q) {
00894 dswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 +
00895 1], &c__1);
00896 if (rsvec) {
00897 dswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
00898 v_dim1 + 1], &c__1);
00899 }
00900 temp1 = sva[p];
00901 sva[p] = sva[q];
00902 sva[q] = temp1;
00903 temp1 = work[p];
00904 work[p] = work[q];
00905 work[q] = temp1;
00906 }
00907
00908 if (ir1 == 0) {
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922 if (sva[p] < rootbig && sva[p] > rootsfmin) {
00923 sva[p] = dnrm2_(m, &a[p * a_dim1 + 1], &c__1) *
00924 work[p];
00925 } else {
00926 temp1 = 0.;
00927 aapp = 0.;
00928 dlassq_(m, &a[p * a_dim1 + 1], &c__1, &temp1, &
00929 aapp);
00930 sva[p] = temp1 * sqrt(aapp) * work[p];
00931 }
00932 aapp = sva[p];
00933 } else {
00934 aapp = sva[p];
00935 }
00936
00937 if (aapp > 0.) {
00938
00939 pskipped = 0;
00940
00941
00942 i__5 = igl + kbl - 1;
00943 i__4 = min(i__5,*n);
00944 for (q = p + 1; q <= i__4; ++q) {
00945
00946 aaqq = sva[q];
00947
00948 if (aaqq > 0.) {
00949
00950 aapp0 = aapp;
00951 if (aaqq >= 1.) {
00952 rotok = small * aapp <= aaqq;
00953 if (aapp < big / aaqq) {
00954 aapq = ddot_(m, &a[p * a_dim1 + 1], &
00955 c__1, &a[q * a_dim1 + 1], &
00956 c__1) * work[p] * work[q] /
00957 aaqq / aapp;
00958 } else {
00959 dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
00960 work[*n + 1], &c__1);
00961 dlascl_("G", &c__0, &c__0, &aapp, &
00962 work[p], m, &c__1, &work[*n +
00963 1], lda, &ierr);
00964 aapq = ddot_(m, &work[*n + 1], &c__1,
00965 &a[q * a_dim1 + 1], &c__1) *
00966 work[q] / aaqq;
00967 }
00968 } else {
00969 rotok = aapp <= aaqq / small;
00970 if (aapp > small / aaqq) {
00971 aapq = ddot_(m, &a[p * a_dim1 + 1], &
00972 c__1, &a[q * a_dim1 + 1], &
00973 c__1) * work[p] * work[q] /
00974 aaqq / aapp;
00975 } else {
00976 dcopy_(m, &a[q * a_dim1 + 1], &c__1, &
00977 work[*n + 1], &c__1);
00978 dlascl_("G", &c__0, &c__0, &aaqq, &
00979 work[q], m, &c__1, &work[*n +
00980 1], lda, &ierr);
00981 aapq = ddot_(m, &work[*n + 1], &c__1,
00982 &a[p * a_dim1 + 1], &c__1) *
00983 work[p] / aapp;
00984 }
00985 }
00986
00987
00988 d__1 = mxaapq, d__2 = abs(aapq);
00989 mxaapq = max(d__1,d__2);
00990
00991
00992
00993 if (abs(aapq) > tol) {
00994
00995
00996
00997
00998 if (ir1 == 0) {
00999 notrot = 0;
01000 pskipped = 0;
01001 ++iswrot;
01002 }
01003
01004 if (rotok) {
01005
01006 aqoap = aaqq / aapp;
01007 apoaq = aapp / aaqq;
01008 theta = (d__1 = aqoap - apoaq, abs(
01009 d__1)) * -.5 / aapq;
01010
01011 if (abs(theta) > bigtheta) {
01012
01013 t = .5 / theta;
01014 fastr[2] = t * work[p] / work[q];
01015 fastr[3] = -t * work[q] / work[p];
01016 drotm_(m, &a[p * a_dim1 + 1], &
01017 c__1, &a[q * a_dim1 + 1],
01018 &c__1, fastr);
01019 if (rsvec) {
01020 drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
01021 v_dim1 + 1], &c__1, fastr);
01022 }
01023
01024 d__1 = 0., d__2 = t * apoaq *
01025 aapq + 1.;
01026 sva[q] = aaqq * sqrt((max(d__1,
01027 d__2)));
01028 aapp *= sqrt(1. - t * aqoap *
01029 aapq);
01030
01031 d__1 = mxsinj, d__2 = abs(t);
01032 mxsinj = max(d__1,d__2);
01033
01034 } else {
01035
01036
01037
01038 thsign = -d_sign(&c_b18, &aapq);
01039 t = 1. / (theta + thsign * sqrt(
01040 theta * theta + 1.));
01041 cs = sqrt(1. / (t * t + 1.));
01042 sn = t * cs;
01043
01044
01045 d__1 = mxsinj, d__2 = abs(sn);
01046 mxsinj = max(d__1,d__2);
01047
01048 d__1 = 0., d__2 = t * apoaq *
01049 aapq + 1.;
01050 sva[q] = aaqq * sqrt((max(d__1,
01051 d__2)));
01052
01053 d__1 = 0., d__2 = 1. - t * aqoap *
01054 aapq;
01055 aapp *= sqrt((max(d__1,d__2)));
01056
01057 apoaq = work[p] / work[q];
01058 aqoap = work[q] / work[p];
01059 if (work[p] >= 1.) {
01060 if (work[q] >= 1.) {
01061 fastr[2] = t * apoaq;
01062 fastr[3] = -t * aqoap;
01063 work[p] *= cs;
01064 work[q] *= cs;
01065 drotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
01066 a_dim1 + 1], &c__1, fastr);
01067 if (rsvec) {
01068 drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
01069 q * v_dim1 + 1], &c__1, fastr);
01070 }
01071 } else {
01072 d__1 = -t * aqoap;
01073 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
01074 p * a_dim1 + 1], &c__1);
01075 d__1 = cs * sn * apoaq;
01076 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
01077 q * a_dim1 + 1], &c__1);
01078 work[p] *= cs;
01079 work[q] /= cs;
01080 if (rsvec) {
01081 d__1 = -t * aqoap;
01082 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
01083 c__1, &v[p * v_dim1 + 1], &c__1);
01084 d__1 = cs * sn * apoaq;
01085 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
01086 c__1, &v[q * v_dim1 + 1], &c__1);
01087 }
01088 }
01089 } else {
01090 if (work[q] >= 1.) {
01091 d__1 = t * apoaq;
01092 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
01093 q * a_dim1 + 1], &c__1);
01094 d__1 = -cs * sn * aqoap;
01095 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
01096 p * a_dim1 + 1], &c__1);
01097 work[p] /= cs;
01098 work[q] *= cs;
01099 if (rsvec) {
01100 d__1 = t * apoaq;
01101 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
01102 c__1, &v[q * v_dim1 + 1], &c__1);
01103 d__1 = -cs * sn * aqoap;
01104 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
01105 c__1, &v[p * v_dim1 + 1], &c__1);
01106 }
01107 } else {
01108 if (work[p] >= work[q]) {
01109 d__1 = -t * aqoap;
01110 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
01111 &a[p * a_dim1 + 1], &c__1);
01112 d__1 = cs * sn * apoaq;
01113 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
01114 &a[q * a_dim1 + 1], &c__1);
01115 work[p] *= cs;
01116 work[q] /= cs;
01117 if (rsvec) {
01118 d__1 = -t * aqoap;
01119 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
01120 &c__1, &v[p * v_dim1 + 1], &
01121 c__1);
01122 d__1 = cs * sn * apoaq;
01123 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
01124 &c__1, &v[q * v_dim1 + 1], &
01125 c__1);
01126 }
01127 } else {
01128 d__1 = t * apoaq;
01129 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
01130 &a[q * a_dim1 + 1], &c__1);
01131 d__1 = -cs * sn * aqoap;
01132 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
01133 &a[p * a_dim1 + 1], &c__1);
01134 work[p] /= cs;
01135 work[q] *= cs;
01136 if (rsvec) {
01137 d__1 = t * apoaq;
01138 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
01139 &c__1, &v[q * v_dim1 + 1], &
01140 c__1);
01141 d__1 = -cs * sn * aqoap;
01142 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
01143 &c__1, &v[p * v_dim1 + 1], &
01144 c__1);
01145 }
01146 }
01147 }
01148 }
01149 }
01150
01151 } else {
01152
01153 dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
01154 work[*n + 1], &c__1);
01155 dlascl_("G", &c__0, &c__0, &aapp, &
01156 c_b18, m, &c__1, &work[*n + 1]
01157 , lda, &ierr);
01158 dlascl_("G", &c__0, &c__0, &aaqq, &
01159 c_b18, m, &c__1, &a[q *
01160 a_dim1 + 1], lda, &ierr);
01161 temp1 = -aapq * work[p] / work[q];
01162 daxpy_(m, &temp1, &work[*n + 1], &
01163 c__1, &a[q * a_dim1 + 1], &
01164 c__1);
01165 dlascl_("G", &c__0, &c__0, &c_b18, &
01166 aaqq, m, &c__1, &a[q * a_dim1
01167 + 1], lda, &ierr);
01168
01169 d__1 = 0., d__2 = 1. - aapq * aapq;
01170 sva[q] = aaqq * sqrt((max(d__1,d__2)))
01171 ;
01172 mxsinj = max(mxsinj,sfmin);
01173 }
01174
01175
01176
01177
01178
01179
01180 d__1 = sva[q] / aaqq;
01181 if (d__1 * d__1 <= rooteps) {
01182 if (aaqq < rootbig && aaqq >
01183 rootsfmin) {
01184 sva[q] = dnrm2_(m, &a[q * a_dim1
01185 + 1], &c__1) * work[q];
01186 } else {
01187 t = 0.;
01188 aaqq = 0.;
01189 dlassq_(m, &a[q * a_dim1 + 1], &
01190 c__1, &t, &aaqq);
01191 sva[q] = t * sqrt(aaqq) * work[q];
01192 }
01193 }
01194 if (aapp / aapp0 <= rooteps) {
01195 if (aapp < rootbig && aapp >
01196 rootsfmin) {
01197 aapp = dnrm2_(m, &a[p * a_dim1 +
01198 1], &c__1) * work[p];
01199 } else {
01200 t = 0.;
01201 aapp = 0.;
01202 dlassq_(m, &a[p * a_dim1 + 1], &
01203 c__1, &t, &aapp);
01204 aapp = t * sqrt(aapp) * work[p];
01205 }
01206 sva[p] = aapp;
01207 }
01208
01209 } else {
01210
01211 if (ir1 == 0) {
01212 ++notrot;
01213 }
01214
01215 ++pskipped;
01216 }
01217 } else {
01218
01219 if (ir1 == 0) {
01220 ++notrot;
01221 }
01222 ++pskipped;
01223 }
01224
01225 if (i__ <= swband && pskipped > rowskip) {
01226 if (ir1 == 0) {
01227 aapp = -aapp;
01228 }
01229 notrot = 0;
01230 goto L2103;
01231 }
01232
01233
01234 }
01235
01236
01237 L2103:
01238
01239
01240 sva[p] = aapp;
01241
01242 } else {
01243 sva[p] = aapp;
01244 if (ir1 == 0 && aapp == 0.) {
01245
01246 i__4 = igl + kbl - 1;
01247 notrot = notrot + min(i__4,*n) - p;
01248 }
01249 }
01250
01251
01252 }
01253
01254
01255
01256 }
01257
01258
01259
01260
01261 igl = (ibr - 1) * kbl + 1;
01262
01263 i__2 = nbl;
01264 for (jbc = ibr + 1; jbc <= i__2; ++jbc) {
01265
01266 jgl = (jbc - 1) * kbl + 1;
01267
01268
01269
01270 ijblsk = 0;
01271
01272 i__4 = igl + kbl - 1;
01273 i__3 = min(i__4,*n);
01274 for (p = igl; p <= i__3; ++p) {
01275
01276 aapp = sva[p];
01277 if (aapp > 0.) {
01278
01279 pskipped = 0;
01280
01281
01282 i__5 = jgl + kbl - 1;
01283 i__4 = min(i__5,*n);
01284 for (q = jgl; q <= i__4; ++q) {
01285
01286 aaqq = sva[q];
01287 if (aaqq > 0.) {
01288 aapp0 = aapp;
01289
01290
01291
01292
01293
01294 if (aaqq >= 1.) {
01295 if (aapp >= aaqq) {
01296 rotok = small * aapp <= aaqq;
01297 } else {
01298 rotok = small * aaqq <= aapp;
01299 }
01300 if (aapp < big / aaqq) {
01301 aapq = ddot_(m, &a[p * a_dim1 + 1], &
01302 c__1, &a[q * a_dim1 + 1], &
01303 c__1) * work[p] * work[q] /
01304 aaqq / aapp;
01305 } else {
01306 dcopy_(m, &a[p * a_dim1 + 1], &c__1, &
01307 work[*n + 1], &c__1);
01308 dlascl_("G", &c__0, &c__0, &aapp, &
01309 work[p], m, &c__1, &work[*n +
01310 1], lda, &ierr);
01311 aapq = ddot_(m, &work[*n + 1], &c__1,
01312 &a[q * a_dim1 + 1], &c__1) *
01313 work[q] / aaqq;
01314 }
01315 } else {
01316 if (aapp >= aaqq) {
01317 rotok = aapp <= aaqq / small;
01318 } else {
01319 rotok = aaqq <= aapp / small;
01320 }
01321 if (aapp > small / aaqq) {
01322 aapq = ddot_(m, &a[p * a_dim1 + 1], &
01323 c__1, &a[q * a_dim1 + 1], &
01324 c__1) * work[p] * work[q] /
01325 aaqq / aapp;
01326 } else {
01327 dcopy_(m, &a[q * a_dim1 + 1], &c__1, &
01328 work[*n + 1], &c__1);
01329 dlascl_("G", &c__0, &c__0, &aaqq, &
01330 work[q], m, &c__1, &work[*n +
01331 1], lda, &ierr);
01332 aapq = ddot_(m, &work[*n + 1], &c__1,
01333 &a[p * a_dim1 + 1], &c__1) *
01334 work[p] / aapp;
01335 }
01336 }
01337
01338
01339 d__1 = mxaapq, d__2 = abs(aapq);
01340 mxaapq = max(d__1,d__2);
01341
01342
01343
01344 if (abs(aapq) > tol) {
01345 notrot = 0;
01346
01347 pskipped = 0;
01348 ++iswrot;
01349
01350 if (rotok) {
01351
01352 aqoap = aaqq / aapp;
01353 apoaq = aapp / aaqq;
01354 theta = (d__1 = aqoap - apoaq, abs(
01355 d__1)) * -.5 / aapq;
01356 if (aaqq > aapp0) {
01357 theta = -theta;
01358 }
01359
01360 if (abs(theta) > bigtheta) {
01361 t = .5 / theta;
01362 fastr[2] = t * work[p] / work[q];
01363 fastr[3] = -t * work[q] / work[p];
01364 drotm_(m, &a[p * a_dim1 + 1], &
01365 c__1, &a[q * a_dim1 + 1],
01366 &c__1, fastr);
01367 if (rsvec) {
01368 drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q *
01369 v_dim1 + 1], &c__1, fastr);
01370 }
01371
01372 d__1 = 0., d__2 = t * apoaq *
01373 aapq + 1.;
01374 sva[q] = aaqq * sqrt((max(d__1,
01375 d__2)));
01376
01377 d__1 = 0., d__2 = 1. - t * aqoap *
01378 aapq;
01379 aapp *= sqrt((max(d__1,d__2)));
01380
01381 d__1 = mxsinj, d__2 = abs(t);
01382 mxsinj = max(d__1,d__2);
01383 } else {
01384
01385
01386
01387 thsign = -d_sign(&c_b18, &aapq);
01388 if (aaqq > aapp0) {
01389 thsign = -thsign;
01390 }
01391 t = 1. / (theta + thsign * sqrt(
01392 theta * theta + 1.));
01393 cs = sqrt(1. / (t * t + 1.));
01394 sn = t * cs;
01395
01396 d__1 = mxsinj, d__2 = abs(sn);
01397 mxsinj = max(d__1,d__2);
01398
01399 d__1 = 0., d__2 = t * apoaq *
01400 aapq + 1.;
01401 sva[q] = aaqq * sqrt((max(d__1,
01402 d__2)));
01403 aapp *= sqrt(1. - t * aqoap *
01404 aapq);
01405
01406 apoaq = work[p] / work[q];
01407 aqoap = work[q] / work[p];
01408 if (work[p] >= 1.) {
01409
01410 if (work[q] >= 1.) {
01411 fastr[2] = t * apoaq;
01412 fastr[3] = -t * aqoap;
01413 work[p] *= cs;
01414 work[q] *= cs;
01415 drotm_(m, &a[p * a_dim1 + 1], &c__1, &a[q *
01416 a_dim1 + 1], &c__1, fastr);
01417 if (rsvec) {
01418 drotm_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[
01419 q * v_dim1 + 1], &c__1, fastr);
01420 }
01421 } else {
01422 d__1 = -t * aqoap;
01423 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
01424 p * a_dim1 + 1], &c__1);
01425 d__1 = cs * sn * apoaq;
01426 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
01427 q * a_dim1 + 1], &c__1);
01428 if (rsvec) {
01429 d__1 = -t * aqoap;
01430 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
01431 c__1, &v[p * v_dim1 + 1], &c__1);
01432 d__1 = cs * sn * apoaq;
01433 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
01434 c__1, &v[q * v_dim1 + 1], &c__1);
01435 }
01436 work[p] *= cs;
01437 work[q] /= cs;
01438 }
01439 } else {
01440 if (work[q] >= 1.) {
01441 d__1 = t * apoaq;
01442 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1, &a[
01443 q * a_dim1 + 1], &c__1);
01444 d__1 = -cs * sn * aqoap;
01445 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1, &a[
01446 p * a_dim1 + 1], &c__1);
01447 if (rsvec) {
01448 d__1 = t * apoaq;
01449 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1], &
01450 c__1, &v[q * v_dim1 + 1], &c__1);
01451 d__1 = -cs * sn * aqoap;
01452 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1], &
01453 c__1, &v[p * v_dim1 + 1], &c__1);
01454 }
01455 work[p] /= cs;
01456 work[q] *= cs;
01457 } else {
01458 if (work[p] >= work[q]) {
01459 d__1 = -t * aqoap;
01460 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
01461 &a[p * a_dim1 + 1], &c__1);
01462 d__1 = cs * sn * apoaq;
01463 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
01464 &a[q * a_dim1 + 1], &c__1);
01465 work[p] *= cs;
01466 work[q] /= cs;
01467 if (rsvec) {
01468 d__1 = -t * aqoap;
01469 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
01470 &c__1, &v[p * v_dim1 + 1], &
01471 c__1);
01472 d__1 = cs * sn * apoaq;
01473 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
01474 &c__1, &v[q * v_dim1 + 1], &
01475 c__1);
01476 }
01477 } else {
01478 d__1 = t * apoaq;
01479 daxpy_(m, &d__1, &a[p * a_dim1 + 1], &c__1,
01480 &a[q * a_dim1 + 1], &c__1);
01481 d__1 = -cs * sn * aqoap;
01482 daxpy_(m, &d__1, &a[q * a_dim1 + 1], &c__1,
01483 &a[p * a_dim1 + 1], &c__1);
01484 work[p] /= cs;
01485 work[q] *= cs;
01486 if (rsvec) {
01487 d__1 = t * apoaq;
01488 daxpy_(&mvl, &d__1, &v[p * v_dim1 + 1],
01489 &c__1, &v[q * v_dim1 + 1], &
01490 c__1);
01491 d__1 = -cs * sn * aqoap;
01492 daxpy_(&mvl, &d__1, &v[q * v_dim1 + 1],
01493 &c__1, &v[p * v_dim1 + 1], &
01494 c__1);
01495 }
01496 }
01497 }
01498 }
01499 }
01500
01501 } else {
01502 if (aapp > aaqq) {
01503 dcopy_(m, &a[p * a_dim1 + 1], &
01504 c__1, &work[*n + 1], &
01505 c__1);
01506 dlascl_("G", &c__0, &c__0, &aapp,
01507 &c_b18, m, &c__1, &work[*
01508 n + 1], lda, &ierr);
01509 dlascl_("G", &c__0, &c__0, &aaqq,
01510 &c_b18, m, &c__1, &a[q *
01511 a_dim1 + 1], lda, &ierr);
01512 temp1 = -aapq * work[p] / work[q];
01513 daxpy_(m, &temp1, &work[*n + 1], &
01514 c__1, &a[q * a_dim1 + 1],
01515 &c__1);
01516 dlascl_("G", &c__0, &c__0, &c_b18,
01517 &aaqq, m, &c__1, &a[q *
01518 a_dim1 + 1], lda, &ierr);
01519
01520 d__1 = 0., d__2 = 1. - aapq *
01521 aapq;
01522 sva[q] = aaqq * sqrt((max(d__1,
01523 d__2)));
01524 mxsinj = max(mxsinj,sfmin);
01525 } else {
01526 dcopy_(m, &a[q * a_dim1 + 1], &
01527 c__1, &work[*n + 1], &
01528 c__1);
01529 dlascl_("G", &c__0, &c__0, &aaqq,
01530 &c_b18, m, &c__1, &work[*
01531 n + 1], lda, &ierr);
01532 dlascl_("G", &c__0, &c__0, &aapp,
01533 &c_b18, m, &c__1, &a[p *
01534 a_dim1 + 1], lda, &ierr);
01535 temp1 = -aapq * work[q] / work[p];
01536 daxpy_(m, &temp1, &work[*n + 1], &
01537 c__1, &a[p * a_dim1 + 1],
01538 &c__1);
01539 dlascl_("G", &c__0, &c__0, &c_b18,
01540 &aapp, m, &c__1, &a[p *
01541 a_dim1 + 1], lda, &ierr);
01542
01543 d__1 = 0., d__2 = 1. - aapq *
01544 aapq;
01545 sva[p] = aapp * sqrt((max(d__1,
01546 d__2)));
01547 mxsinj = max(mxsinj,sfmin);
01548 }
01549 }
01550
01551
01552
01553
01554
01555 d__1 = sva[q] / aaqq;
01556 if (d__1 * d__1 <= rooteps) {
01557 if (aaqq < rootbig && aaqq >
01558 rootsfmin) {
01559 sva[q] = dnrm2_(m, &a[q * a_dim1
01560 + 1], &c__1) * work[q];
01561 } else {
01562 t = 0.;
01563 aaqq = 0.;
01564 dlassq_(m, &a[q * a_dim1 + 1], &
01565 c__1, &t, &aaqq);
01566 sva[q] = t * sqrt(aaqq) * work[q];
01567 }
01568 }
01569
01570 d__1 = aapp / aapp0;
01571 if (d__1 * d__1 <= rooteps) {
01572 if (aapp < rootbig && aapp >
01573 rootsfmin) {
01574 aapp = dnrm2_(m, &a[p * a_dim1 +
01575 1], &c__1) * work[p];
01576 } else {
01577 t = 0.;
01578 aapp = 0.;
01579 dlassq_(m, &a[p * a_dim1 + 1], &
01580 c__1, &t, &aapp);
01581 aapp = t * sqrt(aapp) * work[p];
01582 }
01583 sva[p] = aapp;
01584 }
01585
01586 } else {
01587 ++notrot;
01588
01589 ++pskipped;
01590 ++ijblsk;
01591 }
01592 } else {
01593 ++notrot;
01594 ++pskipped;
01595 ++ijblsk;
01596 }
01597
01598 if (i__ <= swband && ijblsk >= blskip) {
01599 sva[p] = aapp;
01600 notrot = 0;
01601 goto L2011;
01602 }
01603 if (i__ <= swband && pskipped > rowskip) {
01604 aapp = -aapp;
01605 notrot = 0;
01606 goto L2203;
01607 }
01608
01609
01610 }
01611
01612 L2203:
01613
01614 sva[p] = aapp;
01615
01616 } else {
01617
01618 if (aapp == 0.) {
01619
01620 i__4 = jgl + kbl - 1;
01621 notrot = notrot + min(i__4,*n) - jgl + 1;
01622 }
01623 if (aapp < 0.) {
01624 notrot = 0;
01625 }
01626
01627 }
01628
01629
01630 }
01631
01632
01633 }
01634
01635 L2011:
01636
01637
01638 i__3 = igl + kbl - 1;
01639 i__2 = min(i__3,*n);
01640 for (p = igl; p <= i__2; ++p) {
01641 sva[p] = (d__1 = sva[p], abs(d__1));
01642
01643 }
01644
01645
01646 }
01647
01648
01649
01650 if (sva[*n] < rootbig && sva[*n] > rootsfmin) {
01651 sva[*n] = dnrm2_(m, &a[*n * a_dim1 + 1], &c__1) * work[*n];
01652 } else {
01653 t = 0.;
01654 aapp = 0.;
01655 dlassq_(m, &a[*n * a_dim1 + 1], &c__1, &t, &aapp);
01656 sva[*n] = t * sqrt(aapp) * work[*n];
01657 }
01658
01659
01660
01661 if (i__ < swband && (mxaapq <= roottol || iswrot <= *n)) {
01662 swband = i__;
01663 }
01664
01665 if (i__ > swband + 1 && mxaapq < sqrt((doublereal) (*n)) * tol && (
01666 doublereal) (*n) * mxaapq * mxsinj < tol) {
01667 goto L1994;
01668 }
01669
01670 if (notrot >= emptsw) {
01671 goto L1994;
01672 }
01673
01674
01675 }
01676
01677
01678
01679 *info = 29;
01680 goto L1995;
01681
01682 L1994:
01683
01684
01685
01686 *info = 0;
01687
01688 L1995:
01689
01690
01691
01692
01693 n2 = 0;
01694 n4 = 0;
01695 i__1 = *n - 1;
01696 for (p = 1; p <= i__1; ++p) {
01697 i__2 = *n - p + 1;
01698 q = idamax_(&i__2, &sva[p], &c__1) + p - 1;
01699 if (p != q) {
01700 temp1 = sva[p];
01701 sva[p] = sva[q];
01702 sva[q] = temp1;
01703 temp1 = work[p];
01704 work[p] = work[q];
01705 work[q] = temp1;
01706 dswap_(m, &a[p * a_dim1 + 1], &c__1, &a[q * a_dim1 + 1], &c__1);
01707 if (rsvec) {
01708 dswap_(&mvl, &v[p * v_dim1 + 1], &c__1, &v[q * v_dim1 + 1], &
01709 c__1);
01710 }
01711 }
01712 if (sva[p] != 0.) {
01713 ++n4;
01714 if (sva[p] * scale > sfmin) {
01715 ++n2;
01716 }
01717 }
01718
01719 }
01720 if (sva[*n] != 0.) {
01721 ++n4;
01722 if (sva[*n] * scale > sfmin) {
01723 ++n2;
01724 }
01725 }
01726
01727
01728
01729 if (lsvec || uctol) {
01730 i__1 = n2;
01731 for (p = 1; p <= i__1; ++p) {
01732 d__1 = work[p] / sva[p];
01733 dscal_(m, &d__1, &a[p * a_dim1 + 1], &c__1);
01734
01735 }
01736 }
01737
01738
01739
01740 if (rsvec) {
01741 if (applv) {
01742 i__1 = *n;
01743 for (p = 1; p <= i__1; ++p) {
01744 dscal_(&mvl, &work[p], &v[p * v_dim1 + 1], &c__1);
01745
01746 }
01747 } else {
01748 i__1 = *n;
01749 for (p = 1; p <= i__1; ++p) {
01750 temp1 = 1. / dnrm2_(&mvl, &v[p * v_dim1 + 1], &c__1);
01751 dscal_(&mvl, &temp1, &v[p * v_dim1 + 1], &c__1);
01752
01753 }
01754 }
01755 }
01756
01757
01758 if (scale > 1. && sva[1] < big / scale || scale < 1. && sva[n2] > sfmin /
01759 scale) {
01760 i__1 = *n;
01761 for (p = 1; p <= i__1; ++p) {
01762 sva[p] = scale * sva[p];
01763
01764 }
01765 scale = 1.;
01766 }
01767
01768 work[1] = scale;
01769
01770
01771
01772
01773 work[2] = (doublereal) n4;
01774
01775
01776 work[3] = (doublereal) n2;
01777
01778
01779
01780
01781 work[4] = (doublereal) i__;
01782
01783
01784 work[5] = mxaapq;
01785
01786
01787
01788 work[6] = mxsinj;
01789
01790
01791
01792 return 0;
01793
01794
01795
01796 }