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