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 complex c_b1 = {0.f,0.f};
00019 static complex c_b2 = {1.f,0.f};
00020 static integer c__1 = 1;
00021
00022 int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc,
00023 integer *kl, integer *ku, complex *ab, integer *ldab, real *d__,
00024 real *e, complex *q, integer *ldq, complex *pt, integer *ldpt,
00025 complex *c__, integer *ldc, complex *work, real *rwork, integer *info)
00026 {
00027
00028 integer ab_dim1, ab_offset, c_dim1, c_offset, pt_dim1, pt_offset, q_dim1,
00029 q_offset, i__1, i__2, i__3, i__4, i__5, i__6, i__7;
00030 complex q__1, q__2, q__3;
00031
00032
00033 void r_cnjg(complex *, complex *);
00034 double c_abs(complex *);
00035
00036
00037 integer i__, j, l;
00038 complex t;
00039 integer j1, j2, kb;
00040 complex ra, rb;
00041 real rc;
00042 integer kk, ml, nr, mu;
00043 complex rs;
00044 integer kb1, ml0, mu0, klm, kun, nrt, klu1, inca;
00045 real abst;
00046 extern int crot_(integer *, complex *, integer *,
00047 complex *, integer *, real *, complex *), cscal_(integer *,
00048 complex *, complex *, integer *);
00049 extern logical lsame_(char *, char *);
00050 logical wantb, wantc;
00051 integer minmn;
00052 logical wantq;
00053 extern int claset_(char *, integer *, integer *, complex
00054 *, complex *, complex *, integer *), clartg_(complex *,
00055 complex *, real *, complex *, complex *), xerbla_(char *, integer
00056 *), clargv_(integer *, complex *, integer *, complex *,
00057 integer *, real *, integer *), clartv_(integer *, complex *,
00058 integer *, complex *, integer *, real *, complex *, integer *);
00059 logical wantpt;
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
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 ab_dim1 = *ldab;
00174 ab_offset = 1 + ab_dim1;
00175 ab -= ab_offset;
00176 --d__;
00177 --e;
00178 q_dim1 = *ldq;
00179 q_offset = 1 + q_dim1;
00180 q -= q_offset;
00181 pt_dim1 = *ldpt;
00182 pt_offset = 1 + pt_dim1;
00183 pt -= pt_offset;
00184 c_dim1 = *ldc;
00185 c_offset = 1 + c_dim1;
00186 c__ -= c_offset;
00187 --work;
00188 --rwork;
00189
00190
00191 wantb = lsame_(vect, "B");
00192 wantq = lsame_(vect, "Q") || wantb;
00193 wantpt = lsame_(vect, "P") || wantb;
00194 wantc = *ncc > 0;
00195 klu1 = *kl + *ku + 1;
00196 *info = 0;
00197 if (! wantq && ! wantpt && ! lsame_(vect, "N")) {
00198 *info = -1;
00199 } else if (*m < 0) {
00200 *info = -2;
00201 } else if (*n < 0) {
00202 *info = -3;
00203 } else if (*ncc < 0) {
00204 *info = -4;
00205 } else if (*kl < 0) {
00206 *info = -5;
00207 } else if (*ku < 0) {
00208 *info = -6;
00209 } else if (*ldab < klu1) {
00210 *info = -8;
00211 } else if (*ldq < 1 || wantq && *ldq < max(1,*m)) {
00212 *info = -12;
00213 } else if (*ldpt < 1 || wantpt && *ldpt < max(1,*n)) {
00214 *info = -14;
00215 } else if (*ldc < 1 || wantc && *ldc < max(1,*m)) {
00216 *info = -16;
00217 }
00218 if (*info != 0) {
00219 i__1 = -(*info);
00220 xerbla_("CGBBRD", &i__1);
00221 return 0;
00222 }
00223
00224
00225
00226 if (wantq) {
00227 claset_("Full", m, m, &c_b1, &c_b2, &q[q_offset], ldq);
00228 }
00229 if (wantpt) {
00230 claset_("Full", n, n, &c_b1, &c_b2, &pt[pt_offset], ldpt);
00231 }
00232
00233
00234
00235 if (*m == 0 || *n == 0) {
00236 return 0;
00237 }
00238
00239 minmn = min(*m,*n);
00240
00241 if (*kl + *ku > 1) {
00242
00243
00244
00245
00246
00247 if (*ku > 0) {
00248 ml0 = 1;
00249 mu0 = 2;
00250 } else {
00251 ml0 = 2;
00252 mu0 = 1;
00253 }
00254
00255
00256
00257
00258
00259
00260
00261
00262 i__1 = *m - 1;
00263 klm = min(i__1,*kl);
00264
00265 i__1 = *n - 1;
00266 kun = min(i__1,*ku);
00267 kb = klm + kun;
00268 kb1 = kb + 1;
00269 inca = kb1 * *ldab;
00270 nr = 0;
00271 j1 = klm + 2;
00272 j2 = 1 - kun;
00273
00274 i__1 = minmn;
00275 for (i__ = 1; i__ <= i__1; ++i__) {
00276
00277
00278
00279 ml = klm + 1;
00280 mu = kun + 1;
00281 i__2 = kb;
00282 for (kk = 1; kk <= i__2; ++kk) {
00283 j1 += kb;
00284 j2 += kb;
00285
00286
00287
00288
00289 if (nr > 0) {
00290 clargv_(&nr, &ab[klu1 + (j1 - klm - 1) * ab_dim1], &inca,
00291 &work[j1], &kb1, &rwork[j1], &kb1);
00292 }
00293
00294
00295
00296 i__3 = kb;
00297 for (l = 1; l <= i__3; ++l) {
00298 if (j2 - klm + l - 1 > *n) {
00299 nrt = nr - 1;
00300 } else {
00301 nrt = nr;
00302 }
00303 if (nrt > 0) {
00304 clartv_(&nrt, &ab[klu1 - l + (j1 - klm + l - 1) *
00305 ab_dim1], &inca, &ab[klu1 - l + 1 + (j1 - klm
00306 + l - 1) * ab_dim1], &inca, &rwork[j1], &work[
00307 j1], &kb1);
00308 }
00309
00310 }
00311
00312 if (ml > ml0) {
00313 if (ml <= *m - i__ + 1) {
00314
00315
00316
00317
00318 clartg_(&ab[*ku + ml - 1 + i__ * ab_dim1], &ab[*ku +
00319 ml + i__ * ab_dim1], &rwork[i__ + ml - 1], &
00320 work[i__ + ml - 1], &ra);
00321 i__3 = *ku + ml - 1 + i__ * ab_dim1;
00322 ab[i__3].r = ra.r, ab[i__3].i = ra.i;
00323 if (i__ < *n) {
00324
00325 i__4 = *ku + ml - 2, i__5 = *n - i__;
00326 i__3 = min(i__4,i__5);
00327 i__6 = *ldab - 1;
00328 i__7 = *ldab - 1;
00329 crot_(&i__3, &ab[*ku + ml - 2 + (i__ + 1) *
00330 ab_dim1], &i__6, &ab[*ku + ml - 1 + (i__
00331 + 1) * ab_dim1], &i__7, &rwork[i__ + ml -
00332 1], &work[i__ + ml - 1]);
00333 }
00334 }
00335 ++nr;
00336 j1 -= kb1;
00337 }
00338
00339 if (wantq) {
00340
00341
00342
00343 i__3 = j2;
00344 i__4 = kb1;
00345 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4)
00346 {
00347 r_cnjg(&q__1, &work[j]);
00348 crot_(m, &q[(j - 1) * q_dim1 + 1], &c__1, &q[j *
00349 q_dim1 + 1], &c__1, &rwork[j], &q__1);
00350
00351 }
00352 }
00353
00354 if (wantc) {
00355
00356
00357
00358 i__4 = j2;
00359 i__3 = kb1;
00360 for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3)
00361 {
00362 crot_(ncc, &c__[j - 1 + c_dim1], ldc, &c__[j + c_dim1]
00363 , ldc, &rwork[j], &work[j]);
00364
00365 }
00366 }
00367
00368 if (j2 + kun > *n) {
00369
00370
00371
00372 --nr;
00373 j2 -= kb1;
00374 }
00375
00376 i__3 = j2;
00377 i__4 = kb1;
00378 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
00379
00380
00381
00382
00383 i__5 = j + kun;
00384 i__6 = j;
00385 i__7 = (j + kun) * ab_dim1 + 1;
00386 q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[
00387 i__7].i, q__1.i = work[i__6].r * ab[i__7].i +
00388 work[i__6].i * ab[i__7].r;
00389 work[i__5].r = q__1.r, work[i__5].i = q__1.i;
00390 i__5 = (j + kun) * ab_dim1 + 1;
00391 i__6 = j;
00392 i__7 = (j + kun) * ab_dim1 + 1;
00393 q__1.r = rwork[i__6] * ab[i__7].r, q__1.i = rwork[i__6] *
00394 ab[i__7].i;
00395 ab[i__5].r = q__1.r, ab[i__5].i = q__1.i;
00396
00397 }
00398
00399
00400
00401
00402 if (nr > 0) {
00403 clargv_(&nr, &ab[(j1 + kun - 1) * ab_dim1 + 1], &inca, &
00404 work[j1 + kun], &kb1, &rwork[j1 + kun], &kb1);
00405 }
00406
00407
00408
00409 i__4 = kb;
00410 for (l = 1; l <= i__4; ++l) {
00411 if (j2 + l - 1 > *m) {
00412 nrt = nr - 1;
00413 } else {
00414 nrt = nr;
00415 }
00416 if (nrt > 0) {
00417 clartv_(&nrt, &ab[l + 1 + (j1 + kun - 1) * ab_dim1], &
00418 inca, &ab[l + (j1 + kun) * ab_dim1], &inca, &
00419 rwork[j1 + kun], &work[j1 + kun], &kb1);
00420 }
00421
00422 }
00423
00424 if (ml == ml0 && mu > mu0) {
00425 if (mu <= *n - i__ + 1) {
00426
00427
00428
00429
00430 clartg_(&ab[*ku - mu + 3 + (i__ + mu - 2) * ab_dim1],
00431 &ab[*ku - mu + 2 + (i__ + mu - 1) * ab_dim1],
00432 &rwork[i__ + mu - 1], &work[i__ + mu - 1], &
00433 ra);
00434 i__4 = *ku - mu + 3 + (i__ + mu - 2) * ab_dim1;
00435 ab[i__4].r = ra.r, ab[i__4].i = ra.i;
00436
00437 i__3 = *kl + mu - 2, i__5 = *m - i__;
00438 i__4 = min(i__3,i__5);
00439 crot_(&i__4, &ab[*ku - mu + 4 + (i__ + mu - 2) *
00440 ab_dim1], &c__1, &ab[*ku - mu + 3 + (i__ + mu
00441 - 1) * ab_dim1], &c__1, &rwork[i__ + mu - 1],
00442 &work[i__ + mu - 1]);
00443 }
00444 ++nr;
00445 j1 -= kb1;
00446 }
00447
00448 if (wantpt) {
00449
00450
00451
00452 i__4 = j2;
00453 i__3 = kb1;
00454 for (j = j1; i__3 < 0 ? j >= i__4 : j <= i__4; j += i__3)
00455 {
00456 r_cnjg(&q__1, &work[j + kun]);
00457 crot_(n, &pt[j + kun - 1 + pt_dim1], ldpt, &pt[j +
00458 kun + pt_dim1], ldpt, &rwork[j + kun], &q__1);
00459
00460 }
00461 }
00462
00463 if (j2 + kb > *m) {
00464
00465
00466
00467 --nr;
00468 j2 -= kb1;
00469 }
00470
00471 i__3 = j2;
00472 i__4 = kb1;
00473 for (j = j1; i__4 < 0 ? j >= i__3 : j <= i__3; j += i__4) {
00474
00475
00476
00477
00478 i__5 = j + kb;
00479 i__6 = j + kun;
00480 i__7 = klu1 + (j + kun) * ab_dim1;
00481 q__1.r = work[i__6].r * ab[i__7].r - work[i__6].i * ab[
00482 i__7].i, q__1.i = work[i__6].r * ab[i__7].i +
00483 work[i__6].i * ab[i__7].r;
00484 work[i__5].r = q__1.r, work[i__5].i = q__1.i;
00485 i__5 = klu1 + (j + kun) * ab_dim1;
00486 i__6 = j + kun;
00487 i__7 = klu1 + (j + kun) * ab_dim1;
00488 q__1.r = rwork[i__6] * ab[i__7].r, q__1.i = rwork[i__6] *
00489 ab[i__7].i;
00490 ab[i__5].r = q__1.r, ab[i__5].i = q__1.i;
00491
00492 }
00493
00494 if (ml > ml0) {
00495 --ml;
00496 } else {
00497 --mu;
00498 }
00499
00500 }
00501
00502 }
00503 }
00504
00505 if (*ku == 0 && *kl > 0) {
00506
00507
00508
00509
00510
00511
00512
00513
00514 i__2 = *m - 1;
00515 i__1 = min(i__2,*n);
00516 for (i__ = 1; i__ <= i__1; ++i__) {
00517 clartg_(&ab[i__ * ab_dim1 + 1], &ab[i__ * ab_dim1 + 2], &rc, &rs,
00518 &ra);
00519 i__2 = i__ * ab_dim1 + 1;
00520 ab[i__2].r = ra.r, ab[i__2].i = ra.i;
00521 if (i__ < *n) {
00522 i__2 = i__ * ab_dim1 + 2;
00523 i__4 = (i__ + 1) * ab_dim1 + 1;
00524 q__1.r = rs.r * ab[i__4].r - rs.i * ab[i__4].i, q__1.i = rs.r
00525 * ab[i__4].i + rs.i * ab[i__4].r;
00526 ab[i__2].r = q__1.r, ab[i__2].i = q__1.i;
00527 i__2 = (i__ + 1) * ab_dim1 + 1;
00528 i__4 = (i__ + 1) * ab_dim1 + 1;
00529 q__1.r = rc * ab[i__4].r, q__1.i = rc * ab[i__4].i;
00530 ab[i__2].r = q__1.r, ab[i__2].i = q__1.i;
00531 }
00532 if (wantq) {
00533 r_cnjg(&q__1, &rs);
00534 crot_(m, &q[i__ * q_dim1 + 1], &c__1, &q[(i__ + 1) * q_dim1 +
00535 1], &c__1, &rc, &q__1);
00536 }
00537 if (wantc) {
00538 crot_(ncc, &c__[i__ + c_dim1], ldc, &c__[i__ + 1 + c_dim1],
00539 ldc, &rc, &rs);
00540 }
00541
00542 }
00543 } else {
00544
00545
00546
00547
00548 if (*ku > 0 && *m < *n) {
00549
00550
00551
00552
00553 i__1 = *ku + (*m + 1) * ab_dim1;
00554 rb.r = ab[i__1].r, rb.i = ab[i__1].i;
00555 for (i__ = *m; i__ >= 1; --i__) {
00556 clartg_(&ab[*ku + 1 + i__ * ab_dim1], &rb, &rc, &rs, &ra);
00557 i__1 = *ku + 1 + i__ * ab_dim1;
00558 ab[i__1].r = ra.r, ab[i__1].i = ra.i;
00559 if (i__ > 1) {
00560 r_cnjg(&q__3, &rs);
00561 q__2.r = -q__3.r, q__2.i = -q__3.i;
00562 i__1 = *ku + i__ * ab_dim1;
00563 q__1.r = q__2.r * ab[i__1].r - q__2.i * ab[i__1].i,
00564 q__1.i = q__2.r * ab[i__1].i + q__2.i * ab[i__1]
00565 .r;
00566 rb.r = q__1.r, rb.i = q__1.i;
00567 i__1 = *ku + i__ * ab_dim1;
00568 i__2 = *ku + i__ * ab_dim1;
00569 q__1.r = rc * ab[i__2].r, q__1.i = rc * ab[i__2].i;
00570 ab[i__1].r = q__1.r, ab[i__1].i = q__1.i;
00571 }
00572 if (wantpt) {
00573 r_cnjg(&q__1, &rs);
00574 crot_(n, &pt[i__ + pt_dim1], ldpt, &pt[*m + 1 + pt_dim1],
00575 ldpt, &rc, &q__1);
00576 }
00577
00578 }
00579 }
00580 }
00581
00582
00583
00584
00585 i__1 = *ku + 1 + ab_dim1;
00586 t.r = ab[i__1].r, t.i = ab[i__1].i;
00587 i__1 = minmn;
00588 for (i__ = 1; i__ <= i__1; ++i__) {
00589 abst = c_abs(&t);
00590 d__[i__] = abst;
00591 if (abst != 0.f) {
00592 q__1.r = t.r / abst, q__1.i = t.i / abst;
00593 t.r = q__1.r, t.i = q__1.i;
00594 } else {
00595 t.r = 1.f, t.i = 0.f;
00596 }
00597 if (wantq) {
00598 cscal_(m, &t, &q[i__ * q_dim1 + 1], &c__1);
00599 }
00600 if (wantc) {
00601 r_cnjg(&q__1, &t);
00602 cscal_(ncc, &q__1, &c__[i__ + c_dim1], ldc);
00603 }
00604 if (i__ < minmn) {
00605 if (*ku == 0 && *kl == 0) {
00606 e[i__] = 0.f;
00607 i__2 = (i__ + 1) * ab_dim1 + 1;
00608 t.r = ab[i__2].r, t.i = ab[i__2].i;
00609 } else {
00610 if (*ku == 0) {
00611 i__2 = i__ * ab_dim1 + 2;
00612 r_cnjg(&q__2, &t);
00613 q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i,
00614 q__1.i = ab[i__2].r * q__2.i + ab[i__2].i *
00615 q__2.r;
00616 t.r = q__1.r, t.i = q__1.i;
00617 } else {
00618 i__2 = *ku + (i__ + 1) * ab_dim1;
00619 r_cnjg(&q__2, &t);
00620 q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i,
00621 q__1.i = ab[i__2].r * q__2.i + ab[i__2].i *
00622 q__2.r;
00623 t.r = q__1.r, t.i = q__1.i;
00624 }
00625 abst = c_abs(&t);
00626 e[i__] = abst;
00627 if (abst != 0.f) {
00628 q__1.r = t.r / abst, q__1.i = t.i / abst;
00629 t.r = q__1.r, t.i = q__1.i;
00630 } else {
00631 t.r = 1.f, t.i = 0.f;
00632 }
00633 if (wantpt) {
00634 cscal_(n, &t, &pt[i__ + 1 + pt_dim1], ldpt);
00635 }
00636 i__2 = *ku + 1 + (i__ + 1) * ab_dim1;
00637 r_cnjg(&q__2, &t);
00638 q__1.r = ab[i__2].r * q__2.r - ab[i__2].i * q__2.i, q__1.i =
00639 ab[i__2].r * q__2.i + ab[i__2].i * q__2.r;
00640 t.r = q__1.r, t.i = q__1.i;
00641 }
00642 }
00643
00644 }
00645 return 0;
00646
00647
00648
00649 }