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