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