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