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_b5 = -1.;
00019 static integer c__1 = 1;
00020 static doublereal c_b13 = 1.;
00021 static doublereal c_b15 = 0.;
00022 static integer c__0 = 0;
00023
00024 int zlals0_(integer *icompq, integer *nl, integer *nr,
00025 integer *sqre, integer *nrhs, doublecomplex *b, integer *ldb,
00026 doublecomplex *bx, integer *ldbx, integer *perm, integer *givptr,
00027 integer *givcol, integer *ldgcol, doublereal *givnum, integer *ldgnum,
00028 doublereal *poles, doublereal *difl, doublereal *difr, doublereal *
00029 z__, integer *k, doublereal *c__, doublereal *s, doublereal *rwork,
00030 integer *info)
00031 {
00032
00033 integer givcol_dim1, givcol_offset, difr_dim1, difr_offset, givnum_dim1,
00034 givnum_offset, poles_dim1, poles_offset, b_dim1, b_offset,
00035 bx_dim1, bx_offset, i__1, i__2, i__3, i__4, i__5;
00036 doublereal d__1;
00037 doublecomplex z__1;
00038
00039
00040 double d_imag(doublecomplex *);
00041
00042
00043 integer i__, j, m, n;
00044 doublereal dj;
00045 integer nlp1, jcol;
00046 doublereal temp;
00047 integer jrow;
00048 extern doublereal dnrm2_(integer *, doublereal *, integer *);
00049 doublereal diflj, difrj, dsigj;
00050 extern int dgemv_(char *, integer *, integer *,
00051 doublereal *, doublereal *, integer *, doublereal *, integer *,
00052 doublereal *, doublereal *, integer *), zdrot_(integer *,
00053 doublecomplex *, integer *, doublecomplex *, integer *,
00054 doublereal *, doublereal *);
00055 extern doublereal dlamc3_(doublereal *, doublereal *);
00056 extern int zcopy_(integer *, doublecomplex *, integer *,
00057 doublecomplex *, integer *), xerbla_(char *, integer *);
00058 doublereal dsigjp;
00059 extern int zdscal_(integer *, doublereal *,
00060 doublecomplex *, integer *), zlascl_(char *, integer *, integer *,
00061 doublereal *, doublereal *, integer *, integer *, doublecomplex *
00062 , integer *, integer *), zlacpy_(char *, integer *,
00063 integer *, doublecomplex *, integer *, doublecomplex *, integer *);
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
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235 b_dim1 = *ldb;
00236 b_offset = 1 + b_dim1;
00237 b -= b_offset;
00238 bx_dim1 = *ldbx;
00239 bx_offset = 1 + bx_dim1;
00240 bx -= bx_offset;
00241 --perm;
00242 givcol_dim1 = *ldgcol;
00243 givcol_offset = 1 + givcol_dim1;
00244 givcol -= givcol_offset;
00245 difr_dim1 = *ldgnum;
00246 difr_offset = 1 + difr_dim1;
00247 difr -= difr_offset;
00248 poles_dim1 = *ldgnum;
00249 poles_offset = 1 + poles_dim1;
00250 poles -= poles_offset;
00251 givnum_dim1 = *ldgnum;
00252 givnum_offset = 1 + givnum_dim1;
00253 givnum -= givnum_offset;
00254 --difl;
00255 --z__;
00256 --rwork;
00257
00258
00259 *info = 0;
00260
00261 if (*icompq < 0 || *icompq > 1) {
00262 *info = -1;
00263 } else if (*nl < 1) {
00264 *info = -2;
00265 } else if (*nr < 1) {
00266 *info = -3;
00267 } else if (*sqre < 0 || *sqre > 1) {
00268 *info = -4;
00269 }
00270
00271 n = *nl + *nr + 1;
00272
00273 if (*nrhs < 1) {
00274 *info = -5;
00275 } else if (*ldb < n) {
00276 *info = -7;
00277 } else if (*ldbx < n) {
00278 *info = -9;
00279 } else if (*givptr < 0) {
00280 *info = -11;
00281 } else if (*ldgcol < n) {
00282 *info = -13;
00283 } else if (*ldgnum < n) {
00284 *info = -15;
00285 } else if (*k < 1) {
00286 *info = -20;
00287 }
00288 if (*info != 0) {
00289 i__1 = -(*info);
00290 xerbla_("ZLALS0", &i__1);
00291 return 0;
00292 }
00293
00294 m = n + *sqre;
00295 nlp1 = *nl + 1;
00296
00297 if (*icompq == 0) {
00298
00299
00300
00301
00302
00303 i__1 = *givptr;
00304 for (i__ = 1; i__ <= i__1; ++i__) {
00305 zdrot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, &
00306 b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ +
00307 (givnum_dim1 << 1)], &givnum[i__ + givnum_dim1]);
00308
00309 }
00310
00311
00312
00313 zcopy_(nrhs, &b[nlp1 + b_dim1], ldb, &bx[bx_dim1 + 1], ldbx);
00314 i__1 = n;
00315 for (i__ = 2; i__ <= i__1; ++i__) {
00316 zcopy_(nrhs, &b[perm[i__] + b_dim1], ldb, &bx[i__ + bx_dim1],
00317 ldbx);
00318
00319 }
00320
00321
00322
00323
00324 if (*k == 1) {
00325 zcopy_(nrhs, &bx[bx_offset], ldbx, &b[b_offset], ldb);
00326 if (z__[1] < 0.) {
00327 zdscal_(nrhs, &c_b5, &b[b_offset], ldb);
00328 }
00329 } else {
00330 i__1 = *k;
00331 for (j = 1; j <= i__1; ++j) {
00332 diflj = difl[j];
00333 dj = poles[j + poles_dim1];
00334 dsigj = -poles[j + (poles_dim1 << 1)];
00335 if (j < *k) {
00336 difrj = -difr[j + difr_dim1];
00337 dsigjp = -poles[j + 1 + (poles_dim1 << 1)];
00338 }
00339 if (z__[j] == 0. || poles[j + (poles_dim1 << 1)] == 0.) {
00340 rwork[j] = 0.;
00341 } else {
00342 rwork[j] = -poles[j + (poles_dim1 << 1)] * z__[j] / diflj
00343 / (poles[j + (poles_dim1 << 1)] + dj);
00344 }
00345 i__2 = j - 1;
00346 for (i__ = 1; i__ <= i__2; ++i__) {
00347 if (z__[i__] == 0. || poles[i__ + (poles_dim1 << 1)] ==
00348 0.) {
00349 rwork[i__] = 0.;
00350 } else {
00351 rwork[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__]
00352 / (dlamc3_(&poles[i__ + (poles_dim1 << 1)], &
00353 dsigj) - diflj) / (poles[i__ + (poles_dim1 <<
00354 1)] + dj);
00355 }
00356
00357 }
00358 i__2 = *k;
00359 for (i__ = j + 1; i__ <= i__2; ++i__) {
00360 if (z__[i__] == 0. || poles[i__ + (poles_dim1 << 1)] ==
00361 0.) {
00362 rwork[i__] = 0.;
00363 } else {
00364 rwork[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__]
00365 / (dlamc3_(&poles[i__ + (poles_dim1 << 1)], &
00366 dsigjp) + difrj) / (poles[i__ + (poles_dim1 <<
00367 1)] + dj);
00368 }
00369
00370 }
00371 rwork[1] = -1.;
00372 temp = dnrm2_(k, &rwork[1], &c__1);
00373
00374
00375
00376
00377
00378
00379
00380 i__ = *k + (*nrhs << 1);
00381 i__2 = *nrhs;
00382 for (jcol = 1; jcol <= i__2; ++jcol) {
00383 i__3 = *k;
00384 for (jrow = 1; jrow <= i__3; ++jrow) {
00385 ++i__;
00386 i__4 = jrow + jcol * bx_dim1;
00387 rwork[i__] = bx[i__4].r;
00388
00389 }
00390
00391 }
00392 dgemv_("T", k, nrhs, &c_b13, &rwork[*k + 1 + (*nrhs << 1)], k,
00393 &rwork[1], &c__1, &c_b15, &rwork[*k + 1], &c__1);
00394 i__ = *k + (*nrhs << 1);
00395 i__2 = *nrhs;
00396 for (jcol = 1; jcol <= i__2; ++jcol) {
00397 i__3 = *k;
00398 for (jrow = 1; jrow <= i__3; ++jrow) {
00399 ++i__;
00400 rwork[i__] = d_imag(&bx[jrow + jcol * bx_dim1]);
00401
00402 }
00403
00404 }
00405 dgemv_("T", k, nrhs, &c_b13, &rwork[*k + 1 + (*nrhs << 1)], k,
00406 &rwork[1], &c__1, &c_b15, &rwork[*k + 1 + *nrhs], &
00407 c__1);
00408 i__2 = *nrhs;
00409 for (jcol = 1; jcol <= i__2; ++jcol) {
00410 i__3 = j + jcol * b_dim1;
00411 i__4 = jcol + *k;
00412 i__5 = jcol + *k + *nrhs;
00413 z__1.r = rwork[i__4], z__1.i = rwork[i__5];
00414 b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00415
00416 }
00417 zlascl_("G", &c__0, &c__0, &temp, &c_b13, &c__1, nrhs, &b[j +
00418 b_dim1], ldb, info);
00419
00420 }
00421 }
00422
00423
00424
00425 if (*k < max(m,n)) {
00426 i__1 = n - *k;
00427 zlacpy_("A", &i__1, nrhs, &bx[*k + 1 + bx_dim1], ldbx, &b[*k + 1
00428 + b_dim1], ldb);
00429 }
00430 } else {
00431
00432
00433
00434
00435
00436
00437 if (*k == 1) {
00438 zcopy_(nrhs, &b[b_offset], ldb, &bx[bx_offset], ldbx);
00439 } else {
00440 i__1 = *k;
00441 for (j = 1; j <= i__1; ++j) {
00442 dsigj = poles[j + (poles_dim1 << 1)];
00443 if (z__[j] == 0.) {
00444 rwork[j] = 0.;
00445 } else {
00446 rwork[j] = -z__[j] / difl[j] / (dsigj + poles[j +
00447 poles_dim1]) / difr[j + (difr_dim1 << 1)];
00448 }
00449 i__2 = j - 1;
00450 for (i__ = 1; i__ <= i__2; ++i__) {
00451 if (z__[j] == 0.) {
00452 rwork[i__] = 0.;
00453 } else {
00454 d__1 = -poles[i__ + 1 + (poles_dim1 << 1)];
00455 rwork[i__] = z__[j] / (dlamc3_(&dsigj, &d__1) - difr[
00456 i__ + difr_dim1]) / (dsigj + poles[i__ +
00457 poles_dim1]) / difr[i__ + (difr_dim1 << 1)];
00458 }
00459
00460 }
00461 i__2 = *k;
00462 for (i__ = j + 1; i__ <= i__2; ++i__) {
00463 if (z__[j] == 0.) {
00464 rwork[i__] = 0.;
00465 } else {
00466 d__1 = -poles[i__ + (poles_dim1 << 1)];
00467 rwork[i__] = z__[j] / (dlamc3_(&dsigj, &d__1) - difl[
00468 i__]) / (dsigj + poles[i__ + poles_dim1]) /
00469 difr[i__ + (difr_dim1 << 1)];
00470 }
00471
00472 }
00473
00474
00475
00476
00477
00478
00479
00480 i__ = *k + (*nrhs << 1);
00481 i__2 = *nrhs;
00482 for (jcol = 1; jcol <= i__2; ++jcol) {
00483 i__3 = *k;
00484 for (jrow = 1; jrow <= i__3; ++jrow) {
00485 ++i__;
00486 i__4 = jrow + jcol * b_dim1;
00487 rwork[i__] = b[i__4].r;
00488
00489 }
00490
00491 }
00492 dgemv_("T", k, nrhs, &c_b13, &rwork[*k + 1 + (*nrhs << 1)], k,
00493 &rwork[1], &c__1, &c_b15, &rwork[*k + 1], &c__1);
00494 i__ = *k + (*nrhs << 1);
00495 i__2 = *nrhs;
00496 for (jcol = 1; jcol <= i__2; ++jcol) {
00497 i__3 = *k;
00498 for (jrow = 1; jrow <= i__3; ++jrow) {
00499 ++i__;
00500 rwork[i__] = d_imag(&b[jrow + jcol * b_dim1]);
00501
00502 }
00503
00504 }
00505 dgemv_("T", k, nrhs, &c_b13, &rwork[*k + 1 + (*nrhs << 1)], k,
00506 &rwork[1], &c__1, &c_b15, &rwork[*k + 1 + *nrhs], &
00507 c__1);
00508 i__2 = *nrhs;
00509 for (jcol = 1; jcol <= i__2; ++jcol) {
00510 i__3 = j + jcol * bx_dim1;
00511 i__4 = jcol + *k;
00512 i__5 = jcol + *k + *nrhs;
00513 z__1.r = rwork[i__4], z__1.i = rwork[i__5];
00514 bx[i__3].r = z__1.r, bx[i__3].i = z__1.i;
00515
00516 }
00517
00518 }
00519 }
00520
00521
00522
00523
00524 if (*sqre == 1) {
00525 zcopy_(nrhs, &b[m + b_dim1], ldb, &bx[m + bx_dim1], ldbx);
00526 zdrot_(nrhs, &bx[bx_dim1 + 1], ldbx, &bx[m + bx_dim1], ldbx, c__,
00527 s);
00528 }
00529 if (*k < max(m,n)) {
00530 i__1 = n - *k;
00531 zlacpy_("A", &i__1, nrhs, &b[*k + 1 + b_dim1], ldb, &bx[*k + 1 +
00532 bx_dim1], ldbx);
00533 }
00534
00535
00536
00537 zcopy_(nrhs, &bx[bx_dim1 + 1], ldbx, &b[nlp1 + b_dim1], ldb);
00538 if (*sqre == 1) {
00539 zcopy_(nrhs, &bx[m + bx_dim1], ldbx, &b[m + b_dim1], ldb);
00540 }
00541 i__1 = n;
00542 for (i__ = 2; i__ <= i__1; ++i__) {
00543 zcopy_(nrhs, &bx[i__ + bx_dim1], ldbx, &b[perm[i__] + b_dim1],
00544 ldb);
00545
00546 }
00547
00548
00549
00550 for (i__ = *givptr; i__ >= 1; --i__) {
00551 d__1 = -givnum[i__ + givnum_dim1];
00552 zdrot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, &
00553 b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ +
00554 (givnum_dim1 << 1)], &d__1);
00555
00556 }
00557 }
00558
00559 return 0;
00560
00561
00562
00563 }