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_b9 = 0.;
00019 static doublereal c_b10 = 1.;
00020 static integer c__1 = 1;
00021
00022 int dsbtrd_(char *vect, char *uplo, integer *n, integer *kd,
00023 doublereal *ab, integer *ldab, doublereal *d__, doublereal *e,
00024 doublereal *q, integer *ldq, doublereal *work, integer *info)
00025 {
00026
00027 integer ab_dim1, ab_offset, q_dim1, q_offset, i__1, i__2, i__3, i__4,
00028 i__5;
00029
00030
00031 integer i__, j, k, l, i2, j1, j2, nq, nr, kd1, ibl, iqb, kdn, jin, nrt,
00032 kdm1, inca, jend, lend, jinc, incx, last;
00033 doublereal temp;
00034 extern int drot_(integer *, doublereal *, integer *,
00035 doublereal *, integer *, doublereal *, doublereal *);
00036 integer j1end, j1inc, iqend;
00037 extern logical lsame_(char *, char *);
00038 logical initq, wantq, upper;
00039 extern int dlar2v_(integer *, doublereal *, doublereal *,
00040 doublereal *, integer *, doublereal *, doublereal *, integer *);
00041 integer iqaend;
00042 extern int dlaset_(char *, integer *, integer *,
00043 doublereal *, doublereal *, doublereal *, integer *),
00044 dlartg_(doublereal *, doublereal *, doublereal *, doublereal *,
00045 doublereal *), xerbla_(char *, integer *), dlargv_(
00046 integer *, doublereal *, integer *, doublereal *, integer *,
00047 doublereal *, integer *), dlartv_(integer *, doublereal *,
00048 integer *, doublereal *, integer *, doublereal *, doublereal *,
00049 integer *);
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 ab_dim1 = *ldab;
00153 ab_offset = 1 + ab_dim1;
00154 ab -= ab_offset;
00155 --d__;
00156 --e;
00157 q_dim1 = *ldq;
00158 q_offset = 1 + q_dim1;
00159 q -= q_offset;
00160 --work;
00161
00162
00163 initq = lsame_(vect, "V");
00164 wantq = initq || lsame_(vect, "U");
00165 upper = lsame_(uplo, "U");
00166 kd1 = *kd + 1;
00167 kdm1 = *kd - 1;
00168 incx = *ldab - 1;
00169 iqend = 1;
00170
00171 *info = 0;
00172 if (! wantq && ! lsame_(vect, "N")) {
00173 *info = -1;
00174 } else if (! upper && ! lsame_(uplo, "L")) {
00175 *info = -2;
00176 } else if (*n < 0) {
00177 *info = -3;
00178 } else if (*kd < 0) {
00179 *info = -4;
00180 } else if (*ldab < kd1) {
00181 *info = -6;
00182 } else if (*ldq < max(1,*n) && wantq) {
00183 *info = -10;
00184 }
00185 if (*info != 0) {
00186 i__1 = -(*info);
00187 xerbla_("DSBTRD", &i__1);
00188 return 0;
00189 }
00190
00191
00192
00193 if (*n == 0) {
00194 return 0;
00195 }
00196
00197
00198
00199 if (initq) {
00200 dlaset_("Full", n, n, &c_b9, &c_b10, &q[q_offset], ldq);
00201 }
00202
00203
00204
00205
00206
00207
00208
00209 inca = kd1 * *ldab;
00210
00211 i__1 = *n - 1;
00212 kdn = min(i__1,*kd);
00213 if (upper) {
00214
00215 if (*kd > 1) {
00216
00217
00218
00219 nr = 0;
00220 j1 = kdn + 2;
00221 j2 = 1;
00222
00223 i__1 = *n - 2;
00224 for (i__ = 1; i__ <= i__1; ++i__) {
00225
00226
00227
00228 for (k = kdn + 1; k >= 2; --k) {
00229 j1 += kdn;
00230 j2 += kdn;
00231
00232 if (nr > 0) {
00233
00234
00235
00236
00237 dlargv_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &inca, &
00238 work[j1], &kd1, &d__[j1], &kd1);
00239
00240
00241
00242
00243
00244
00245
00246 if (nr >= (*kd << 1) - 1) {
00247 i__2 = *kd - 1;
00248 for (l = 1; l <= i__2; ++l) {
00249 dlartv_(&nr, &ab[l + 1 + (j1 - 1) * ab_dim1],
00250 &inca, &ab[l + j1 * ab_dim1], &inca, &
00251 d__[j1], &work[j1], &kd1);
00252
00253 }
00254
00255 } else {
00256 jend = j1 + (nr - 1) * kd1;
00257 i__2 = jend;
00258 i__3 = kd1;
00259 for (jinc = j1; i__3 < 0 ? jinc >= i__2 : jinc <=
00260 i__2; jinc += i__3) {
00261 drot_(&kdm1, &ab[(jinc - 1) * ab_dim1 + 2], &
00262 c__1, &ab[jinc * ab_dim1 + 1], &c__1,
00263 &d__[jinc], &work[jinc]);
00264
00265 }
00266 }
00267 }
00268
00269
00270 if (k > 2) {
00271 if (k <= *n - i__ + 1) {
00272
00273
00274
00275
00276 dlartg_(&ab[*kd - k + 3 + (i__ + k - 2) * ab_dim1]
00277 , &ab[*kd - k + 2 + (i__ + k - 1) *
00278 ab_dim1], &d__[i__ + k - 1], &work[i__ +
00279 k - 1], &temp);
00280 ab[*kd - k + 3 + (i__ + k - 2) * ab_dim1] = temp;
00281
00282
00283
00284 i__3 = k - 3;
00285 drot_(&i__3, &ab[*kd - k + 4 + (i__ + k - 2) *
00286 ab_dim1], &c__1, &ab[*kd - k + 3 + (i__ +
00287 k - 1) * ab_dim1], &c__1, &d__[i__ + k -
00288 1], &work[i__ + k - 1]);
00289 }
00290 ++nr;
00291 j1 = j1 - kdn - 1;
00292 }
00293
00294
00295
00296
00297 if (nr > 0) {
00298 dlar2v_(&nr, &ab[kd1 + (j1 - 1) * ab_dim1], &ab[kd1 +
00299 j1 * ab_dim1], &ab[*kd + j1 * ab_dim1], &inca,
00300 &d__[j1], &work[j1], &kd1);
00301 }
00302
00303
00304
00305 if (nr > 0) {
00306 if ((*kd << 1) - 1 < nr) {
00307
00308
00309
00310
00311 i__3 = *kd - 1;
00312 for (l = 1; l <= i__3; ++l) {
00313 if (j2 + l > *n) {
00314 nrt = nr - 1;
00315 } else {
00316 nrt = nr;
00317 }
00318 if (nrt > 0) {
00319 dlartv_(&nrt, &ab[*kd - l + (j1 + l) *
00320 ab_dim1], &inca, &ab[*kd - l + 1
00321 + (j1 + l) * ab_dim1], &inca, &
00322 d__[j1], &work[j1], &kd1);
00323 }
00324
00325 }
00326 } else {
00327 j1end = j1 + kd1 * (nr - 2);
00328 if (j1end >= j1) {
00329 i__3 = j1end;
00330 i__2 = kd1;
00331 for (jin = j1; i__2 < 0 ? jin >= i__3 : jin <=
00332 i__3; jin += i__2) {
00333 i__4 = *kd - 1;
00334 drot_(&i__4, &ab[*kd - 1 + (jin + 1) *
00335 ab_dim1], &incx, &ab[*kd + (jin +
00336 1) * ab_dim1], &incx, &d__[jin], &
00337 work[jin]);
00338
00339 }
00340 }
00341
00342 i__2 = kdm1, i__3 = *n - j2;
00343 lend = min(i__2,i__3);
00344 last = j1end + kd1;
00345 if (lend > 0) {
00346 drot_(&lend, &ab[*kd - 1 + (last + 1) *
00347 ab_dim1], &incx, &ab[*kd + (last + 1)
00348 * ab_dim1], &incx, &d__[last], &work[
00349 last]);
00350 }
00351 }
00352 }
00353
00354 if (wantq) {
00355
00356
00357
00358 if (initq) {
00359
00360
00361
00362
00363 iqend = max(iqend,j2);
00364
00365 i__2 = 0, i__3 = k - 3;
00366 i2 = max(i__2,i__3);
00367 iqaend = i__ * *kd + 1;
00368 if (k == 2) {
00369 iqaend += *kd;
00370 }
00371 iqaend = min(iqaend,iqend);
00372 i__2 = j2;
00373 i__3 = kd1;
00374 for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j
00375 += i__3) {
00376 ibl = i__ - i2 / kdm1;
00377 ++i2;
00378
00379 i__4 = 1, i__5 = j - ibl;
00380 iqb = max(i__4,i__5);
00381 nq = iqaend + 1 - iqb;
00382
00383 i__4 = iqaend + *kd;
00384 iqaend = min(i__4,iqend);
00385 drot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1,
00386 &q[iqb + j * q_dim1], &c__1, &d__[j],
00387 &work[j]);
00388
00389 }
00390 } else {
00391
00392 i__3 = j2;
00393 i__2 = kd1;
00394 for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j
00395 += i__2) {
00396 drot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
00397 j * q_dim1 + 1], &c__1, &d__[j], &
00398 work[j]);
00399
00400 }
00401 }
00402
00403 }
00404
00405 if (j2 + kdn > *n) {
00406
00407
00408
00409 --nr;
00410 j2 = j2 - kdn - 1;
00411 }
00412
00413 i__2 = j2;
00414 i__3 = kd1;
00415 for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j += i__3)
00416 {
00417
00418
00419
00420
00421 work[j + *kd] = work[j] * ab[(j + *kd) * ab_dim1 + 1];
00422 ab[(j + *kd) * ab_dim1 + 1] = d__[j] * ab[(j + *kd) *
00423 ab_dim1 + 1];
00424
00425 }
00426
00427 }
00428
00429 }
00430 }
00431
00432 if (*kd > 0) {
00433
00434
00435
00436 i__1 = *n - 1;
00437 for (i__ = 1; i__ <= i__1; ++i__) {
00438 e[i__] = ab[*kd + (i__ + 1) * ab_dim1];
00439
00440 }
00441 } else {
00442
00443
00444
00445 i__1 = *n - 1;
00446 for (i__ = 1; i__ <= i__1; ++i__) {
00447 e[i__] = 0.;
00448
00449 }
00450 }
00451
00452
00453
00454 i__1 = *n;
00455 for (i__ = 1; i__ <= i__1; ++i__) {
00456 d__[i__] = ab[kd1 + i__ * ab_dim1];
00457
00458 }
00459
00460 } else {
00461
00462 if (*kd > 1) {
00463
00464
00465
00466 nr = 0;
00467 j1 = kdn + 2;
00468 j2 = 1;
00469
00470 i__1 = *n - 2;
00471 for (i__ = 1; i__ <= i__1; ++i__) {
00472
00473
00474
00475 for (k = kdn + 1; k >= 2; --k) {
00476 j1 += kdn;
00477 j2 += kdn;
00478
00479 if (nr > 0) {
00480
00481
00482
00483
00484 dlargv_(&nr, &ab[kd1 + (j1 - kd1) * ab_dim1], &inca, &
00485 work[j1], &kd1, &d__[j1], &kd1);
00486
00487
00488
00489
00490
00491
00492
00493 if (nr > (*kd << 1) - 1) {
00494 i__3 = *kd - 1;
00495 for (l = 1; l <= i__3; ++l) {
00496 dlartv_(&nr, &ab[kd1 - l + (j1 - kd1 + l) *
00497 ab_dim1], &inca, &ab[kd1 - l + 1 + (
00498 j1 - kd1 + l) * ab_dim1], &inca, &d__[
00499 j1], &work[j1], &kd1);
00500
00501 }
00502 } else {
00503 jend = j1 + kd1 * (nr - 1);
00504 i__3 = jend;
00505 i__2 = kd1;
00506 for (jinc = j1; i__2 < 0 ? jinc >= i__3 : jinc <=
00507 i__3; jinc += i__2) {
00508 drot_(&kdm1, &ab[*kd + (jinc - *kd) * ab_dim1]
00509 , &incx, &ab[kd1 + (jinc - *kd) *
00510 ab_dim1], &incx, &d__[jinc], &work[
00511 jinc]);
00512
00513 }
00514 }
00515
00516 }
00517
00518 if (k > 2) {
00519 if (k <= *n - i__ + 1) {
00520
00521
00522
00523
00524 dlartg_(&ab[k - 1 + i__ * ab_dim1], &ab[k + i__ *
00525 ab_dim1], &d__[i__ + k - 1], &work[i__ +
00526 k - 1], &temp);
00527 ab[k - 1 + i__ * ab_dim1] = temp;
00528
00529
00530
00531 i__2 = k - 3;
00532 i__3 = *ldab - 1;
00533 i__4 = *ldab - 1;
00534 drot_(&i__2, &ab[k - 2 + (i__ + 1) * ab_dim1], &
00535 i__3, &ab[k - 1 + (i__ + 1) * ab_dim1], &
00536 i__4, &d__[i__ + k - 1], &work[i__ + k -
00537 1]);
00538 }
00539 ++nr;
00540 j1 = j1 - kdn - 1;
00541 }
00542
00543
00544
00545
00546 if (nr > 0) {
00547 dlar2v_(&nr, &ab[(j1 - 1) * ab_dim1 + 1], &ab[j1 *
00548 ab_dim1 + 1], &ab[(j1 - 1) * ab_dim1 + 2], &
00549 inca, &d__[j1], &work[j1], &kd1);
00550 }
00551
00552
00553
00554
00555
00556
00557
00558 if (nr > 0) {
00559 if (nr > (*kd << 1) - 1) {
00560 i__2 = *kd - 1;
00561 for (l = 1; l <= i__2; ++l) {
00562 if (j2 + l > *n) {
00563 nrt = nr - 1;
00564 } else {
00565 nrt = nr;
00566 }
00567 if (nrt > 0) {
00568 dlartv_(&nrt, &ab[l + 2 + (j1 - 1) *
00569 ab_dim1], &inca, &ab[l + 1 + j1 *
00570 ab_dim1], &inca, &d__[j1], &work[
00571 j1], &kd1);
00572 }
00573
00574 }
00575 } else {
00576 j1end = j1 + kd1 * (nr - 2);
00577 if (j1end >= j1) {
00578 i__2 = j1end;
00579 i__3 = kd1;
00580 for (j1inc = j1; i__3 < 0 ? j1inc >= i__2 :
00581 j1inc <= i__2; j1inc += i__3) {
00582 drot_(&kdm1, &ab[(j1inc - 1) * ab_dim1 +
00583 3], &c__1, &ab[j1inc * ab_dim1 +
00584 2], &c__1, &d__[j1inc], &work[
00585 j1inc]);
00586
00587 }
00588 }
00589
00590 i__3 = kdm1, i__2 = *n - j2;
00591 lend = min(i__3,i__2);
00592 last = j1end + kd1;
00593 if (lend > 0) {
00594 drot_(&lend, &ab[(last - 1) * ab_dim1 + 3], &
00595 c__1, &ab[last * ab_dim1 + 2], &c__1,
00596 &d__[last], &work[last]);
00597 }
00598 }
00599 }
00600
00601
00602
00603 if (wantq) {
00604
00605
00606
00607 if (initq) {
00608
00609
00610
00611
00612 iqend = max(iqend,j2);
00613
00614 i__3 = 0, i__2 = k - 3;
00615 i2 = max(i__3,i__2);
00616 iqaend = i__ * *kd + 1;
00617 if (k == 2) {
00618 iqaend += *kd;
00619 }
00620 iqaend = min(iqaend,iqend);
00621 i__3 = j2;
00622 i__2 = kd1;
00623 for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j
00624 += i__2) {
00625 ibl = i__ - i2 / kdm1;
00626 ++i2;
00627
00628 i__4 = 1, i__5 = j - ibl;
00629 iqb = max(i__4,i__5);
00630 nq = iqaend + 1 - iqb;
00631
00632 i__4 = iqaend + *kd;
00633 iqaend = min(i__4,iqend);
00634 drot_(&nq, &q[iqb + (j - 1) * q_dim1], &c__1,
00635 &q[iqb + j * q_dim1], &c__1, &d__[j],
00636 &work[j]);
00637
00638 }
00639 } else {
00640
00641 i__2 = j2;
00642 i__3 = kd1;
00643 for (j = j1; i__3 < 0 ? j >= i__2 : j <= i__2; j
00644 += i__3) {
00645 drot_(n, &q[(j - 1) * q_dim1 + 1], &c__1, &q[
00646 j * q_dim1 + 1], &c__1, &d__[j], &
00647 work[j]);
00648
00649 }
00650 }
00651 }
00652
00653 if (j2 + kdn > *n) {
00654
00655
00656
00657 --nr;
00658 j2 = j2 - kdn - 1;
00659 }
00660
00661 i__3 = j2;
00662 i__2 = kd1;
00663 for (j = j1; i__2 < 0 ? j >= i__3 : j <= i__3; j += i__2)
00664 {
00665
00666
00667
00668
00669 work[j + *kd] = work[j] * ab[kd1 + j * ab_dim1];
00670 ab[kd1 + j * ab_dim1] = d__[j] * ab[kd1 + j * ab_dim1]
00671 ;
00672
00673 }
00674
00675 }
00676
00677 }
00678 }
00679
00680 if (*kd > 0) {
00681
00682
00683
00684 i__1 = *n - 1;
00685 for (i__ = 1; i__ <= i__1; ++i__) {
00686 e[i__] = ab[i__ * ab_dim1 + 2];
00687
00688 }
00689 } else {
00690
00691
00692
00693 i__1 = *n - 1;
00694 for (i__ = 1; i__ <= i__1; ++i__) {
00695 e[i__] = 0.;
00696
00697 }
00698 }
00699
00700
00701
00702 i__1 = *n;
00703 for (i__ = 1; i__ <= i__1; ++i__) {
00704 d__[i__] = ab[i__ * ab_dim1 + 1];
00705
00706 }
00707 }
00708
00709 return 0;
00710
00711
00712
00713 }