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_b5 = -1.f;
00019 static integer c__1 = 1;
00020 static real c_b11 = 1.f;
00021 static real c_b13 = 0.f;
00022 static integer c__0 = 0;
00023
00024 int slals0_(integer *icompq, integer *nl, integer *nr,
00025 integer *sqre, integer *nrhs, real *b, integer *ldb, real *bx,
00026 integer *ldbx, integer *perm, integer *givptr, integer *givcol,
00027 integer *ldgcol, real *givnum, integer *ldgnum, real *poles, real *
00028 difl, real *difr, real *z__, integer *k, real *c__, real *s, real *
00029 work, integer *info)
00030 {
00031
00032 integer givcol_dim1, givcol_offset, b_dim1, b_offset, bx_dim1, bx_offset,
00033 difr_dim1, difr_offset, givnum_dim1, givnum_offset, poles_dim1,
00034 poles_offset, i__1, i__2;
00035 real r__1;
00036
00037
00038 integer i__, j, m, n;
00039 real dj;
00040 integer nlp1;
00041 real temp;
00042 extern int srot_(integer *, real *, integer *, real *,
00043 integer *, real *, real *);
00044 extern doublereal snrm2_(integer *, real *, integer *);
00045 real diflj, difrj, dsigj;
00046 extern int sscal_(integer *, real *, real *, integer *),
00047 sgemv_(char *, integer *, integer *, real *, real *, integer *,
00048 real *, integer *, real *, real *, integer *), scopy_(
00049 integer *, real *, integer *, real *, integer *);
00050 extern doublereal slamc3_(real *, real *);
00051 extern int xerbla_(char *, integer *);
00052 real dsigjp;
00053 extern int slascl_(char *, integer *, integer *, real *,
00054 real *, integer *, integer *, real *, integer *, integer *), slacpy_(char *, integer *, integer *, real *, integer *,
00055 real *, 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
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 b_dim1 = *ldb;
00227 b_offset = 1 + b_dim1;
00228 b -= b_offset;
00229 bx_dim1 = *ldbx;
00230 bx_offset = 1 + bx_dim1;
00231 bx -= bx_offset;
00232 --perm;
00233 givcol_dim1 = *ldgcol;
00234 givcol_offset = 1 + givcol_dim1;
00235 givcol -= givcol_offset;
00236 difr_dim1 = *ldgnum;
00237 difr_offset = 1 + difr_dim1;
00238 difr -= difr_offset;
00239 poles_dim1 = *ldgnum;
00240 poles_offset = 1 + poles_dim1;
00241 poles -= poles_offset;
00242 givnum_dim1 = *ldgnum;
00243 givnum_offset = 1 + givnum_dim1;
00244 givnum -= givnum_offset;
00245 --difl;
00246 --z__;
00247 --work;
00248
00249
00250 *info = 0;
00251
00252 if (*icompq < 0 || *icompq > 1) {
00253 *info = -1;
00254 } else if (*nl < 1) {
00255 *info = -2;
00256 } else if (*nr < 1) {
00257 *info = -3;
00258 } else if (*sqre < 0 || *sqre > 1) {
00259 *info = -4;
00260 }
00261
00262 n = *nl + *nr + 1;
00263
00264 if (*nrhs < 1) {
00265 *info = -5;
00266 } else if (*ldb < n) {
00267 *info = -7;
00268 } else if (*ldbx < n) {
00269 *info = -9;
00270 } else if (*givptr < 0) {
00271 *info = -11;
00272 } else if (*ldgcol < n) {
00273 *info = -13;
00274 } else if (*ldgnum < n) {
00275 *info = -15;
00276 } else if (*k < 1) {
00277 *info = -20;
00278 }
00279 if (*info != 0) {
00280 i__1 = -(*info);
00281 xerbla_("SLALS0", &i__1);
00282 return 0;
00283 }
00284
00285 m = n + *sqre;
00286 nlp1 = *nl + 1;
00287
00288 if (*icompq == 0) {
00289
00290
00291
00292
00293
00294 i__1 = *givptr;
00295 for (i__ = 1; i__ <= i__1; ++i__) {
00296 srot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, &
00297 b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ +
00298 (givnum_dim1 << 1)], &givnum[i__ + givnum_dim1]);
00299
00300 }
00301
00302
00303
00304 scopy_(nrhs, &b[nlp1 + b_dim1], ldb, &bx[bx_dim1 + 1], ldbx);
00305 i__1 = n;
00306 for (i__ = 2; i__ <= i__1; ++i__) {
00307 scopy_(nrhs, &b[perm[i__] + b_dim1], ldb, &bx[i__ + bx_dim1],
00308 ldbx);
00309
00310 }
00311
00312
00313
00314
00315 if (*k == 1) {
00316 scopy_(nrhs, &bx[bx_offset], ldbx, &b[b_offset], ldb);
00317 if (z__[1] < 0.f) {
00318 sscal_(nrhs, &c_b5, &b[b_offset], ldb);
00319 }
00320 } else {
00321 i__1 = *k;
00322 for (j = 1; j <= i__1; ++j) {
00323 diflj = difl[j];
00324 dj = poles[j + poles_dim1];
00325 dsigj = -poles[j + (poles_dim1 << 1)];
00326 if (j < *k) {
00327 difrj = -difr[j + difr_dim1];
00328 dsigjp = -poles[j + 1 + (poles_dim1 << 1)];
00329 }
00330 if (z__[j] == 0.f || poles[j + (poles_dim1 << 1)] == 0.f) {
00331 work[j] = 0.f;
00332 } else {
00333 work[j] = -poles[j + (poles_dim1 << 1)] * z__[j] / diflj /
00334 (poles[j + (poles_dim1 << 1)] + dj);
00335 }
00336 i__2 = j - 1;
00337 for (i__ = 1; i__ <= i__2; ++i__) {
00338 if (z__[i__] == 0.f || poles[i__ + (poles_dim1 << 1)] ==
00339 0.f) {
00340 work[i__] = 0.f;
00341 } else {
00342 work[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__]
00343 / (slamc3_(&poles[i__ + (poles_dim1 << 1)], &
00344 dsigj) - diflj) / (poles[i__ + (poles_dim1 <<
00345 1)] + dj);
00346 }
00347
00348 }
00349 i__2 = *k;
00350 for (i__ = j + 1; i__ <= i__2; ++i__) {
00351 if (z__[i__] == 0.f || poles[i__ + (poles_dim1 << 1)] ==
00352 0.f) {
00353 work[i__] = 0.f;
00354 } else {
00355 work[i__] = poles[i__ + (poles_dim1 << 1)] * z__[i__]
00356 / (slamc3_(&poles[i__ + (poles_dim1 << 1)], &
00357 dsigjp) + difrj) / (poles[i__ + (poles_dim1 <<
00358 1)] + dj);
00359 }
00360
00361 }
00362 work[1] = -1.f;
00363 temp = snrm2_(k, &work[1], &c__1);
00364 sgemv_("T", k, nrhs, &c_b11, &bx[bx_offset], ldbx, &work[1], &
00365 c__1, &c_b13, &b[j + b_dim1], ldb);
00366 slascl_("G", &c__0, &c__0, &temp, &c_b11, &c__1, nrhs, &b[j +
00367 b_dim1], ldb, info);
00368
00369 }
00370 }
00371
00372
00373
00374 if (*k < max(m,n)) {
00375 i__1 = n - *k;
00376 slacpy_("A", &i__1, nrhs, &bx[*k + 1 + bx_dim1], ldbx, &b[*k + 1
00377 + b_dim1], ldb);
00378 }
00379 } else {
00380
00381
00382
00383
00384
00385
00386 if (*k == 1) {
00387 scopy_(nrhs, &b[b_offset], ldb, &bx[bx_offset], ldbx);
00388 } else {
00389 i__1 = *k;
00390 for (j = 1; j <= i__1; ++j) {
00391 dsigj = poles[j + (poles_dim1 << 1)];
00392 if (z__[j] == 0.f) {
00393 work[j] = 0.f;
00394 } else {
00395 work[j] = -z__[j] / difl[j] / (dsigj + poles[j +
00396 poles_dim1]) / difr[j + (difr_dim1 << 1)];
00397 }
00398 i__2 = j - 1;
00399 for (i__ = 1; i__ <= i__2; ++i__) {
00400 if (z__[j] == 0.f) {
00401 work[i__] = 0.f;
00402 } else {
00403 r__1 = -poles[i__ + 1 + (poles_dim1 << 1)];
00404 work[i__] = z__[j] / (slamc3_(&dsigj, &r__1) - difr[
00405 i__ + difr_dim1]) / (dsigj + poles[i__ +
00406 poles_dim1]) / difr[i__ + (difr_dim1 << 1)];
00407 }
00408
00409 }
00410 i__2 = *k;
00411 for (i__ = j + 1; i__ <= i__2; ++i__) {
00412 if (z__[j] == 0.f) {
00413 work[i__] = 0.f;
00414 } else {
00415 r__1 = -poles[i__ + (poles_dim1 << 1)];
00416 work[i__] = z__[j] / (slamc3_(&dsigj, &r__1) - difl[
00417 i__]) / (dsigj + poles[i__ + poles_dim1]) /
00418 difr[i__ + (difr_dim1 << 1)];
00419 }
00420
00421 }
00422 sgemv_("T", k, nrhs, &c_b11, &b[b_offset], ldb, &work[1], &
00423 c__1, &c_b13, &bx[j + bx_dim1], ldbx);
00424
00425 }
00426 }
00427
00428
00429
00430
00431 if (*sqre == 1) {
00432 scopy_(nrhs, &b[m + b_dim1], ldb, &bx[m + bx_dim1], ldbx);
00433 srot_(nrhs, &bx[bx_dim1 + 1], ldbx, &bx[m + bx_dim1], ldbx, c__,
00434 s);
00435 }
00436 if (*k < max(m,n)) {
00437 i__1 = n - *k;
00438 slacpy_("A", &i__1, nrhs, &b[*k + 1 + b_dim1], ldb, &bx[*k + 1 +
00439 bx_dim1], ldbx);
00440 }
00441
00442
00443
00444 scopy_(nrhs, &bx[bx_dim1 + 1], ldbx, &b[nlp1 + b_dim1], ldb);
00445 if (*sqre == 1) {
00446 scopy_(nrhs, &bx[m + bx_dim1], ldbx, &b[m + b_dim1], ldb);
00447 }
00448 i__1 = n;
00449 for (i__ = 2; i__ <= i__1; ++i__) {
00450 scopy_(nrhs, &bx[i__ + bx_dim1], ldbx, &b[perm[i__] + b_dim1],
00451 ldb);
00452
00453 }
00454
00455
00456
00457 for (i__ = *givptr; i__ >= 1; --i__) {
00458 r__1 = -givnum[i__ + givnum_dim1];
00459 srot_(nrhs, &b[givcol[i__ + (givcol_dim1 << 1)] + b_dim1], ldb, &
00460 b[givcol[i__ + givcol_dim1] + b_dim1], ldb, &givnum[i__ +
00461 (givnum_dim1 << 1)], &r__1);
00462
00463 }
00464 }
00465
00466 return 0;
00467
00468
00469
00470 }