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 = 1.f;
00019 static real c_b10 = 0.f;
00020 static integer c__2 = 2;
00021
00022 int clalsa_(integer *icompq, integer *smlsiz, integer *n,
00023 integer *nrhs, complex *b, integer *ldb, complex *bx, integer *ldbx,
00024 real *u, integer *ldu, real *vt, integer *k, real *difl, real *difr,
00025 real *z__, real *poles, integer *givptr, integer *givcol, integer *
00026 ldgcol, integer *perm, real *givnum, real *c__, real *s, real *rwork,
00027 integer *iwork, integer *info)
00028 {
00029
00030 integer givcol_dim1, givcol_offset, perm_dim1, perm_offset, difl_dim1,
00031 difl_offset, difr_dim1, difr_offset, givnum_dim1, givnum_offset,
00032 poles_dim1, poles_offset, u_dim1, u_offset, vt_dim1, vt_offset,
00033 z_dim1, z_offset, b_dim1, b_offset, bx_dim1, bx_offset, i__1,
00034 i__2, i__3, i__4, i__5, i__6;
00035 complex q__1;
00036
00037
00038 double r_imag(complex *);
00039 integer pow_ii(integer *, integer *);
00040
00041
00042 integer i__, j, i1, ic, lf, nd, ll, nl, nr, im1, nlf, nrf, lvl, ndb1,
00043 nlp1, lvl2, nrp1, jcol, nlvl, sqre, jrow, jimag, jreal, inode,
00044 ndiml;
00045 extern int sgemm_(char *, char *, integer *, integer *,
00046 integer *, real *, real *, integer *, real *, integer *, real *,
00047 real *, integer *);
00048 integer ndimr;
00049 extern int ccopy_(integer *, complex *, integer *,
00050 complex *, integer *), clals0_(integer *, integer *, integer *,
00051 integer *, integer *, complex *, integer *, complex *, integer *,
00052 integer *, integer *, integer *, integer *, real *, integer *,
00053 real *, real *, real *, real *, integer *, real *, real *, real *,
00054 integer *), xerbla_(char *, integer *), slasdt_(integer *
00055 , integer *, integer *, integer *, integer *, integer *, integer *
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
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 b_dim1 = *ldb;
00217 b_offset = 1 + b_dim1;
00218 b -= b_offset;
00219 bx_dim1 = *ldbx;
00220 bx_offset = 1 + bx_dim1;
00221 bx -= bx_offset;
00222 givnum_dim1 = *ldu;
00223 givnum_offset = 1 + givnum_dim1;
00224 givnum -= givnum_offset;
00225 poles_dim1 = *ldu;
00226 poles_offset = 1 + poles_dim1;
00227 poles -= poles_offset;
00228 z_dim1 = *ldu;
00229 z_offset = 1 + z_dim1;
00230 z__ -= z_offset;
00231 difr_dim1 = *ldu;
00232 difr_offset = 1 + difr_dim1;
00233 difr -= difr_offset;
00234 difl_dim1 = *ldu;
00235 difl_offset = 1 + difl_dim1;
00236 difl -= difl_offset;
00237 vt_dim1 = *ldu;
00238 vt_offset = 1 + vt_dim1;
00239 vt -= vt_offset;
00240 u_dim1 = *ldu;
00241 u_offset = 1 + u_dim1;
00242 u -= u_offset;
00243 --k;
00244 --givptr;
00245 perm_dim1 = *ldgcol;
00246 perm_offset = 1 + perm_dim1;
00247 perm -= perm_offset;
00248 givcol_dim1 = *ldgcol;
00249 givcol_offset = 1 + givcol_dim1;
00250 givcol -= givcol_offset;
00251 --c__;
00252 --s;
00253 --rwork;
00254 --iwork;
00255
00256
00257 *info = 0;
00258
00259 if (*icompq < 0 || *icompq > 1) {
00260 *info = -1;
00261 } else if (*smlsiz < 3) {
00262 *info = -2;
00263 } else if (*n < *smlsiz) {
00264 *info = -3;
00265 } else if (*nrhs < 1) {
00266 *info = -4;
00267 } else if (*ldb < *n) {
00268 *info = -6;
00269 } else if (*ldbx < *n) {
00270 *info = -8;
00271 } else if (*ldu < *n) {
00272 *info = -10;
00273 } else if (*ldgcol < *n) {
00274 *info = -19;
00275 }
00276 if (*info != 0) {
00277 i__1 = -(*info);
00278 xerbla_("CLALSA", &i__1);
00279 return 0;
00280 }
00281
00282
00283
00284 inode = 1;
00285 ndiml = inode + *n;
00286 ndimr = ndiml + *n;
00287
00288 slasdt_(n, &nlvl, &nd, &iwork[inode], &iwork[ndiml], &iwork[ndimr],
00289 smlsiz);
00290
00291
00292
00293
00294 if (*icompq == 1) {
00295 goto L170;
00296 }
00297
00298
00299
00300
00301
00302
00303 ndb1 = (nd + 1) / 2;
00304 i__1 = nd;
00305 for (i__ = ndb1; i__ <= i__1; ++i__) {
00306
00307
00308
00309
00310
00311
00312
00313 i1 = i__ - 1;
00314 ic = iwork[inode + i1];
00315 nl = iwork[ndiml + i1];
00316 nr = iwork[ndimr + i1];
00317 nlf = ic - nl;
00318 nrf = ic + 1;
00319
00320
00321
00322
00323
00324
00325
00326 j = nl * *nrhs << 1;
00327 i__2 = *nrhs;
00328 for (jcol = 1; jcol <= i__2; ++jcol) {
00329 i__3 = nlf + nl - 1;
00330 for (jrow = nlf; jrow <= i__3; ++jrow) {
00331 ++j;
00332 i__4 = jrow + jcol * b_dim1;
00333 rwork[j] = b[i__4].r;
00334
00335 }
00336
00337 }
00338 sgemm_("T", "N", &nl, nrhs, &nl, &c_b9, &u[nlf + u_dim1], ldu, &rwork[
00339 (nl * *nrhs << 1) + 1], &nl, &c_b10, &rwork[1], &nl);
00340 j = nl * *nrhs << 1;
00341 i__2 = *nrhs;
00342 for (jcol = 1; jcol <= i__2; ++jcol) {
00343 i__3 = nlf + nl - 1;
00344 for (jrow = nlf; jrow <= i__3; ++jrow) {
00345 ++j;
00346 rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
00347
00348 }
00349
00350 }
00351 sgemm_("T", "N", &nl, nrhs, &nl, &c_b9, &u[nlf + u_dim1], ldu, &rwork[
00352 (nl * *nrhs << 1) + 1], &nl, &c_b10, &rwork[nl * *nrhs + 1], &
00353 nl);
00354 jreal = 0;
00355 jimag = nl * *nrhs;
00356 i__2 = *nrhs;
00357 for (jcol = 1; jcol <= i__2; ++jcol) {
00358 i__3 = nlf + nl - 1;
00359 for (jrow = nlf; jrow <= i__3; ++jrow) {
00360 ++jreal;
00361 ++jimag;
00362 i__4 = jrow + jcol * bx_dim1;
00363 i__5 = jreal;
00364 i__6 = jimag;
00365 q__1.r = rwork[i__5], q__1.i = rwork[i__6];
00366 bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
00367
00368 }
00369
00370 }
00371
00372
00373
00374
00375
00376
00377
00378 j = nr * *nrhs << 1;
00379 i__2 = *nrhs;
00380 for (jcol = 1; jcol <= i__2; ++jcol) {
00381 i__3 = nrf + nr - 1;
00382 for (jrow = nrf; jrow <= i__3; ++jrow) {
00383 ++j;
00384 i__4 = jrow + jcol * b_dim1;
00385 rwork[j] = b[i__4].r;
00386
00387 }
00388
00389 }
00390 sgemm_("T", "N", &nr, nrhs, &nr, &c_b9, &u[nrf + u_dim1], ldu, &rwork[
00391 (nr * *nrhs << 1) + 1], &nr, &c_b10, &rwork[1], &nr);
00392 j = nr * *nrhs << 1;
00393 i__2 = *nrhs;
00394 for (jcol = 1; jcol <= i__2; ++jcol) {
00395 i__3 = nrf + nr - 1;
00396 for (jrow = nrf; jrow <= i__3; ++jrow) {
00397 ++j;
00398 rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
00399
00400 }
00401
00402 }
00403 sgemm_("T", "N", &nr, nrhs, &nr, &c_b9, &u[nrf + u_dim1], ldu, &rwork[
00404 (nr * *nrhs << 1) + 1], &nr, &c_b10, &rwork[nr * *nrhs + 1], &
00405 nr);
00406 jreal = 0;
00407 jimag = nr * *nrhs;
00408 i__2 = *nrhs;
00409 for (jcol = 1; jcol <= i__2; ++jcol) {
00410 i__3 = nrf + nr - 1;
00411 for (jrow = nrf; jrow <= i__3; ++jrow) {
00412 ++jreal;
00413 ++jimag;
00414 i__4 = jrow + jcol * bx_dim1;
00415 i__5 = jreal;
00416 i__6 = jimag;
00417 q__1.r = rwork[i__5], q__1.i = rwork[i__6];
00418 bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
00419
00420 }
00421
00422 }
00423
00424
00425 }
00426
00427
00428
00429
00430 i__1 = nd;
00431 for (i__ = 1; i__ <= i__1; ++i__) {
00432 ic = iwork[inode + i__ - 1];
00433 ccopy_(nrhs, &b[ic + b_dim1], ldb, &bx[ic + bx_dim1], ldbx);
00434
00435 }
00436
00437
00438
00439
00440 j = pow_ii(&c__2, &nlvl);
00441 sqre = 0;
00442
00443 for (lvl = nlvl; lvl >= 1; --lvl) {
00444 lvl2 = (lvl << 1) - 1;
00445
00446
00447
00448
00449 if (lvl == 1) {
00450 lf = 1;
00451 ll = 1;
00452 } else {
00453 i__1 = lvl - 1;
00454 lf = pow_ii(&c__2, &i__1);
00455 ll = (lf << 1) - 1;
00456 }
00457 i__1 = ll;
00458 for (i__ = lf; i__ <= i__1; ++i__) {
00459 im1 = i__ - 1;
00460 ic = iwork[inode + im1];
00461 nl = iwork[ndiml + im1];
00462 nr = iwork[ndimr + im1];
00463 nlf = ic - nl;
00464 nrf = ic + 1;
00465 --j;
00466 clals0_(icompq, &nl, &nr, &sqre, nrhs, &bx[nlf + bx_dim1], ldbx, &
00467 b[nlf + b_dim1], ldb, &perm[nlf + lvl * perm_dim1], &
00468 givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, &
00469 givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 *
00470 poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf +
00471 lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[
00472 j], &s[j], &rwork[1], info);
00473
00474 }
00475
00476 }
00477 goto L330;
00478
00479
00480
00481 L170:
00482
00483
00484
00485
00486 j = 0;
00487 i__1 = nlvl;
00488 for (lvl = 1; lvl <= i__1; ++lvl) {
00489 lvl2 = (lvl << 1) - 1;
00490
00491
00492
00493
00494 if (lvl == 1) {
00495 lf = 1;
00496 ll = 1;
00497 } else {
00498 i__2 = lvl - 1;
00499 lf = pow_ii(&c__2, &i__2);
00500 ll = (lf << 1) - 1;
00501 }
00502 i__2 = lf;
00503 for (i__ = ll; i__ >= i__2; --i__) {
00504 im1 = i__ - 1;
00505 ic = iwork[inode + im1];
00506 nl = iwork[ndiml + im1];
00507 nr = iwork[ndimr + im1];
00508 nlf = ic - nl;
00509 nrf = ic + 1;
00510 if (i__ == ll) {
00511 sqre = 0;
00512 } else {
00513 sqre = 1;
00514 }
00515 ++j;
00516 clals0_(icompq, &nl, &nr, &sqre, nrhs, &b[nlf + b_dim1], ldb, &bx[
00517 nlf + bx_dim1], ldbx, &perm[nlf + lvl * perm_dim1], &
00518 givptr[j], &givcol[nlf + lvl2 * givcol_dim1], ldgcol, &
00519 givnum[nlf + lvl2 * givnum_dim1], ldu, &poles[nlf + lvl2 *
00520 poles_dim1], &difl[nlf + lvl * difl_dim1], &difr[nlf +
00521 lvl2 * difr_dim1], &z__[nlf + lvl * z_dim1], &k[j], &c__[
00522 j], &s[j], &rwork[1], info);
00523
00524 }
00525
00526 }
00527
00528
00529
00530
00531
00532 ndb1 = (nd + 1) / 2;
00533 i__1 = nd;
00534 for (i__ = ndb1; i__ <= i__1; ++i__) {
00535 i1 = i__ - 1;
00536 ic = iwork[inode + i1];
00537 nl = iwork[ndiml + i1];
00538 nr = iwork[ndimr + i1];
00539 nlp1 = nl + 1;
00540 if (i__ == nd) {
00541 nrp1 = nr;
00542 } else {
00543 nrp1 = nr + 1;
00544 }
00545 nlf = ic - nl;
00546 nrf = ic + 1;
00547
00548
00549
00550
00551
00552
00553
00554 j = nlp1 * *nrhs << 1;
00555 i__2 = *nrhs;
00556 for (jcol = 1; jcol <= i__2; ++jcol) {
00557 i__3 = nlf + nlp1 - 1;
00558 for (jrow = nlf; jrow <= i__3; ++jrow) {
00559 ++j;
00560 i__4 = jrow + jcol * b_dim1;
00561 rwork[j] = b[i__4].r;
00562
00563 }
00564
00565 }
00566 sgemm_("T", "N", &nlp1, nrhs, &nlp1, &c_b9, &vt[nlf + vt_dim1], ldu, &
00567 rwork[(nlp1 * *nrhs << 1) + 1], &nlp1, &c_b10, &rwork[1], &
00568 nlp1);
00569 j = nlp1 * *nrhs << 1;
00570 i__2 = *nrhs;
00571 for (jcol = 1; jcol <= i__2; ++jcol) {
00572 i__3 = nlf + nlp1 - 1;
00573 for (jrow = nlf; jrow <= i__3; ++jrow) {
00574 ++j;
00575 rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
00576
00577 }
00578
00579 }
00580 sgemm_("T", "N", &nlp1, nrhs, &nlp1, &c_b9, &vt[nlf + vt_dim1], ldu, &
00581 rwork[(nlp1 * *nrhs << 1) + 1], &nlp1, &c_b10, &rwork[nlp1 * *
00582 nrhs + 1], &nlp1);
00583 jreal = 0;
00584 jimag = nlp1 * *nrhs;
00585 i__2 = *nrhs;
00586 for (jcol = 1; jcol <= i__2; ++jcol) {
00587 i__3 = nlf + nlp1 - 1;
00588 for (jrow = nlf; jrow <= i__3; ++jrow) {
00589 ++jreal;
00590 ++jimag;
00591 i__4 = jrow + jcol * bx_dim1;
00592 i__5 = jreal;
00593 i__6 = jimag;
00594 q__1.r = rwork[i__5], q__1.i = rwork[i__6];
00595 bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
00596
00597 }
00598
00599 }
00600
00601
00602
00603
00604
00605
00606
00607 j = nrp1 * *nrhs << 1;
00608 i__2 = *nrhs;
00609 for (jcol = 1; jcol <= i__2; ++jcol) {
00610 i__3 = nrf + nrp1 - 1;
00611 for (jrow = nrf; jrow <= i__3; ++jrow) {
00612 ++j;
00613 i__4 = jrow + jcol * b_dim1;
00614 rwork[j] = b[i__4].r;
00615
00616 }
00617
00618 }
00619 sgemm_("T", "N", &nrp1, nrhs, &nrp1, &c_b9, &vt[nrf + vt_dim1], ldu, &
00620 rwork[(nrp1 * *nrhs << 1) + 1], &nrp1, &c_b10, &rwork[1], &
00621 nrp1);
00622 j = nrp1 * *nrhs << 1;
00623 i__2 = *nrhs;
00624 for (jcol = 1; jcol <= i__2; ++jcol) {
00625 i__3 = nrf + nrp1 - 1;
00626 for (jrow = nrf; jrow <= i__3; ++jrow) {
00627 ++j;
00628 rwork[j] = r_imag(&b[jrow + jcol * b_dim1]);
00629
00630 }
00631
00632 }
00633 sgemm_("T", "N", &nrp1, nrhs, &nrp1, &c_b9, &vt[nrf + vt_dim1], ldu, &
00634 rwork[(nrp1 * *nrhs << 1) + 1], &nrp1, &c_b10, &rwork[nrp1 * *
00635 nrhs + 1], &nrp1);
00636 jreal = 0;
00637 jimag = nrp1 * *nrhs;
00638 i__2 = *nrhs;
00639 for (jcol = 1; jcol <= i__2; ++jcol) {
00640 i__3 = nrf + nrp1 - 1;
00641 for (jrow = nrf; jrow <= i__3; ++jrow) {
00642 ++jreal;
00643 ++jimag;
00644 i__4 = jrow + jcol * bx_dim1;
00645 i__5 = jreal;
00646 i__6 = jimag;
00647 q__1.r = rwork[i__5], q__1.i = rwork[i__6];
00648 bx[i__4].r = q__1.r, bx[i__4].i = q__1.i;
00649
00650 }
00651
00652 }
00653
00654
00655 }
00656
00657 L330:
00658
00659 return 0;
00660
00661
00662
00663 }