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 integer c__2 = 2;
00019 static integer c__1 = 1;
00020
00021 int ztgsy2_(char *trans, integer *ijob, integer *m, integer *
00022 n, doublecomplex *a, integer *lda, doublecomplex *b, integer *ldb,
00023 doublecomplex *c__, integer *ldc, doublecomplex *d__, integer *ldd,
00024 doublecomplex *e, integer *lde, doublecomplex *f, integer *ldf,
00025 doublereal *scale, doublereal *rdsum, doublereal *rdscal, integer *
00026 info)
00027 {
00028
00029 integer a_dim1, a_offset, b_dim1, b_offset, c_dim1, c_offset, d_dim1,
00030 d_offset, e_dim1, e_offset, f_dim1, f_offset, i__1, i__2, i__3,
00031 i__4;
00032 doublecomplex z__1, z__2, z__3, z__4, z__5, z__6;
00033
00034
00035 void d_cnjg(doublecomplex *, doublecomplex *);
00036
00037
00038 integer i__, j, k;
00039 doublecomplex z__[4] , rhs[2];
00040 integer ierr, ipiv[2], jpiv[2];
00041 doublecomplex alpha;
00042 extern logical lsame_(char *, char *);
00043 extern int zscal_(integer *, doublecomplex *,
00044 doublecomplex *, integer *), zaxpy_(integer *, doublecomplex *,
00045 doublecomplex *, integer *, doublecomplex *, integer *), zgesc2_(
00046 integer *, doublecomplex *, integer *, doublecomplex *, integer *,
00047 integer *, doublereal *), zgetc2_(integer *, doublecomplex *,
00048 integer *, integer *, integer *, integer *);
00049 doublereal scaloc;
00050 extern int xerbla_(char *, integer *), zlatdf_(
00051 integer *, integer *, doublecomplex *, integer *, doublecomplex *,
00052 doublereal *, doublereal *, integer *, integer *);
00053 logical notran;
00054
00055
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
00227
00228
00229
00230
00231 a_dim1 = *lda;
00232 a_offset = 1 + a_dim1;
00233 a -= a_offset;
00234 b_dim1 = *ldb;
00235 b_offset = 1 + b_dim1;
00236 b -= b_offset;
00237 c_dim1 = *ldc;
00238 c_offset = 1 + c_dim1;
00239 c__ -= c_offset;
00240 d_dim1 = *ldd;
00241 d_offset = 1 + d_dim1;
00242 d__ -= d_offset;
00243 e_dim1 = *lde;
00244 e_offset = 1 + e_dim1;
00245 e -= e_offset;
00246 f_dim1 = *ldf;
00247 f_offset = 1 + f_dim1;
00248 f -= f_offset;
00249
00250
00251 *info = 0;
00252 ierr = 0;
00253 notran = lsame_(trans, "N");
00254 if (! notran && ! lsame_(trans, "C")) {
00255 *info = -1;
00256 } else if (notran) {
00257 if (*ijob < 0 || *ijob > 2) {
00258 *info = -2;
00259 }
00260 }
00261 if (*info == 0) {
00262 if (*m <= 0) {
00263 *info = -3;
00264 } else if (*n <= 0) {
00265 *info = -4;
00266 } else if (*lda < max(1,*m)) {
00267 *info = -5;
00268 } else if (*ldb < max(1,*n)) {
00269 *info = -8;
00270 } else if (*ldc < max(1,*m)) {
00271 *info = -10;
00272 } else if (*ldd < max(1,*m)) {
00273 *info = -12;
00274 } else if (*lde < max(1,*n)) {
00275 *info = -14;
00276 } else if (*ldf < max(1,*m)) {
00277 *info = -16;
00278 }
00279 }
00280 if (*info != 0) {
00281 i__1 = -(*info);
00282 xerbla_("ZTGSY2", &i__1);
00283 return 0;
00284 }
00285
00286 if (notran) {
00287
00288
00289
00290
00291
00292
00293 *scale = 1.;
00294 scaloc = 1.;
00295 i__1 = *n;
00296 for (j = 1; j <= i__1; ++j) {
00297 for (i__ = *m; i__ >= 1; --i__) {
00298
00299
00300
00301 i__2 = i__ + i__ * a_dim1;
00302 z__[0].r = a[i__2].r, z__[0].i = a[i__2].i;
00303 i__2 = i__ + i__ * d_dim1;
00304 z__[1].r = d__[i__2].r, z__[1].i = d__[i__2].i;
00305 i__2 = j + j * b_dim1;
00306 z__1.r = -b[i__2].r, z__1.i = -b[i__2].i;
00307 z__[2].r = z__1.r, z__[2].i = z__1.i;
00308 i__2 = j + j * e_dim1;
00309 z__1.r = -e[i__2].r, z__1.i = -e[i__2].i;
00310 z__[3].r = z__1.r, z__[3].i = z__1.i;
00311
00312
00313
00314 i__2 = i__ + j * c_dim1;
00315 rhs[0].r = c__[i__2].r, rhs[0].i = c__[i__2].i;
00316 i__2 = i__ + j * f_dim1;
00317 rhs[1].r = f[i__2].r, rhs[1].i = f[i__2].i;
00318
00319
00320
00321 zgetc2_(&c__2, z__, &c__2, ipiv, jpiv, &ierr);
00322 if (ierr > 0) {
00323 *info = ierr;
00324 }
00325 if (*ijob == 0) {
00326 zgesc2_(&c__2, z__, &c__2, rhs, ipiv, jpiv, &scaloc);
00327 if (scaloc != 1.) {
00328 i__2 = *n;
00329 for (k = 1; k <= i__2; ++k) {
00330 z__1.r = scaloc, z__1.i = 0.;
00331 zscal_(m, &z__1, &c__[k * c_dim1 + 1], &c__1);
00332 z__1.r = scaloc, z__1.i = 0.;
00333 zscal_(m, &z__1, &f[k * f_dim1 + 1], &c__1);
00334
00335 }
00336 *scale *= scaloc;
00337 }
00338 } else {
00339 zlatdf_(ijob, &c__2, z__, &c__2, rhs, rdsum, rdscal, ipiv,
00340 jpiv);
00341 }
00342
00343
00344
00345 i__2 = i__ + j * c_dim1;
00346 c__[i__2].r = rhs[0].r, c__[i__2].i = rhs[0].i;
00347 i__2 = i__ + j * f_dim1;
00348 f[i__2].r = rhs[1].r, f[i__2].i = rhs[1].i;
00349
00350
00351
00352 if (i__ > 1) {
00353 z__1.r = -rhs[0].r, z__1.i = -rhs[0].i;
00354 alpha.r = z__1.r, alpha.i = z__1.i;
00355 i__2 = i__ - 1;
00356 zaxpy_(&i__2, &alpha, &a[i__ * a_dim1 + 1], &c__1, &c__[j
00357 * c_dim1 + 1], &c__1);
00358 i__2 = i__ - 1;
00359 zaxpy_(&i__2, &alpha, &d__[i__ * d_dim1 + 1], &c__1, &f[j
00360 * f_dim1 + 1], &c__1);
00361 }
00362 if (j < *n) {
00363 i__2 = *n - j;
00364 zaxpy_(&i__2, &rhs[1], &b[j + (j + 1) * b_dim1], ldb, &
00365 c__[i__ + (j + 1) * c_dim1], ldc);
00366 i__2 = *n - j;
00367 zaxpy_(&i__2, &rhs[1], &e[j + (j + 1) * e_dim1], lde, &f[
00368 i__ + (j + 1) * f_dim1], ldf);
00369 }
00370
00371
00372 }
00373
00374 }
00375 } else {
00376
00377
00378
00379
00380
00381
00382 *scale = 1.;
00383 scaloc = 1.;
00384 i__1 = *m;
00385 for (i__ = 1; i__ <= i__1; ++i__) {
00386 for (j = *n; j >= 1; --j) {
00387
00388
00389
00390 d_cnjg(&z__1, &a[i__ + i__ * a_dim1]);
00391 z__[0].r = z__1.r, z__[0].i = z__1.i;
00392 d_cnjg(&z__2, &b[j + j * b_dim1]);
00393 z__1.r = -z__2.r, z__1.i = -z__2.i;
00394 z__[1].r = z__1.r, z__[1].i = z__1.i;
00395 d_cnjg(&z__1, &d__[i__ + i__ * d_dim1]);
00396 z__[2].r = z__1.r, z__[2].i = z__1.i;
00397 d_cnjg(&z__2, &e[j + j * e_dim1]);
00398 z__1.r = -z__2.r, z__1.i = -z__2.i;
00399 z__[3].r = z__1.r, z__[3].i = z__1.i;
00400
00401
00402
00403
00404 i__2 = i__ + j * c_dim1;
00405 rhs[0].r = c__[i__2].r, rhs[0].i = c__[i__2].i;
00406 i__2 = i__ + j * f_dim1;
00407 rhs[1].r = f[i__2].r, rhs[1].i = f[i__2].i;
00408
00409
00410
00411 zgetc2_(&c__2, z__, &c__2, ipiv, jpiv, &ierr);
00412 if (ierr > 0) {
00413 *info = ierr;
00414 }
00415 zgesc2_(&c__2, z__, &c__2, rhs, ipiv, jpiv, &scaloc);
00416 if (scaloc != 1.) {
00417 i__2 = *n;
00418 for (k = 1; k <= i__2; ++k) {
00419 z__1.r = scaloc, z__1.i = 0.;
00420 zscal_(m, &z__1, &c__[k * c_dim1 + 1], &c__1);
00421 z__1.r = scaloc, z__1.i = 0.;
00422 zscal_(m, &z__1, &f[k * f_dim1 + 1], &c__1);
00423
00424 }
00425 *scale *= scaloc;
00426 }
00427
00428
00429
00430 i__2 = i__ + j * c_dim1;
00431 c__[i__2].r = rhs[0].r, c__[i__2].i = rhs[0].i;
00432 i__2 = i__ + j * f_dim1;
00433 f[i__2].r = rhs[1].r, f[i__2].i = rhs[1].i;
00434
00435
00436
00437 i__2 = j - 1;
00438 for (k = 1; k <= i__2; ++k) {
00439 i__3 = i__ + k * f_dim1;
00440 i__4 = i__ + k * f_dim1;
00441 d_cnjg(&z__4, &b[k + j * b_dim1]);
00442 z__3.r = rhs[0].r * z__4.r - rhs[0].i * z__4.i, z__3.i =
00443 rhs[0].r * z__4.i + rhs[0].i * z__4.r;
00444 z__2.r = f[i__4].r + z__3.r, z__2.i = f[i__4].i + z__3.i;
00445 d_cnjg(&z__6, &e[k + j * e_dim1]);
00446 z__5.r = rhs[1].r * z__6.r - rhs[1].i * z__6.i, z__5.i =
00447 rhs[1].r * z__6.i + rhs[1].i * z__6.r;
00448 z__1.r = z__2.r + z__5.r, z__1.i = z__2.i + z__5.i;
00449 f[i__3].r = z__1.r, f[i__3].i = z__1.i;
00450
00451 }
00452 i__2 = *m;
00453 for (k = i__ + 1; k <= i__2; ++k) {
00454 i__3 = k + j * c_dim1;
00455 i__4 = k + j * c_dim1;
00456 d_cnjg(&z__4, &a[i__ + k * a_dim1]);
00457 z__3.r = z__4.r * rhs[0].r - z__4.i * rhs[0].i, z__3.i =
00458 z__4.r * rhs[0].i + z__4.i * rhs[0].r;
00459 z__2.r = c__[i__4].r - z__3.r, z__2.i = c__[i__4].i -
00460 z__3.i;
00461 d_cnjg(&z__6, &d__[i__ + k * d_dim1]);
00462 z__5.r = z__6.r * rhs[1].r - z__6.i * rhs[1].i, z__5.i =
00463 z__6.r * rhs[1].i + z__6.i * rhs[1].r;
00464 z__1.r = z__2.r - z__5.r, z__1.i = z__2.i - z__5.i;
00465 c__[i__3].r = z__1.r, c__[i__3].i = z__1.i;
00466
00467 }
00468
00469
00470 }
00471
00472 }
00473 }
00474 return 0;
00475
00476
00477
00478 }