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 complex c_b1 = {1.f,0.f};
00019 static integer c__1 = 1;
00020
00021 int csytrs_(char *uplo, integer *n, integer *nrhs, complex *
00022 a, integer *lda, integer *ipiv, complex *b, integer *ldb, integer *
00023 info)
00024 {
00025
00026 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00027 complex q__1, q__2, q__3;
00028
00029
00030 void c_div(complex *, complex *, complex *);
00031
00032
00033 integer j, k;
00034 complex ak, bk;
00035 integer kp;
00036 complex akm1, bkm1, akm1k;
00037 extern int cscal_(integer *, complex *, complex *,
00038 integer *);
00039 extern logical lsame_(char *, char *);
00040 complex denom;
00041 extern int cgemv_(char *, integer *, integer *, complex *
00042 , complex *, integer *, complex *, integer *, complex *, complex *
00043 , integer *), cgeru_(integer *, integer *, complex *,
00044 complex *, integer *, complex *, integer *, complex *, integer *),
00045 cswap_(integer *, complex *, integer *, complex *, integer *);
00046 logical upper;
00047 extern int xerbla_(char *, integer *);
00048
00049
00050
00051
00052
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 a_dim1 = *lda;
00120 a_offset = 1 + a_dim1;
00121 a -= a_offset;
00122 --ipiv;
00123 b_dim1 = *ldb;
00124 b_offset = 1 + b_dim1;
00125 b -= b_offset;
00126
00127
00128 *info = 0;
00129 upper = lsame_(uplo, "U");
00130 if (! upper && ! lsame_(uplo, "L")) {
00131 *info = -1;
00132 } else if (*n < 0) {
00133 *info = -2;
00134 } else if (*nrhs < 0) {
00135 *info = -3;
00136 } else if (*lda < max(1,*n)) {
00137 *info = -5;
00138 } else if (*ldb < max(1,*n)) {
00139 *info = -8;
00140 }
00141 if (*info != 0) {
00142 i__1 = -(*info);
00143 xerbla_("CSYTRS", &i__1);
00144 return 0;
00145 }
00146
00147
00148
00149 if (*n == 0 || *nrhs == 0) {
00150 return 0;
00151 }
00152
00153 if (upper) {
00154
00155
00156
00157
00158
00159
00160
00161
00162 k = *n;
00163 L10:
00164
00165
00166
00167 if (k < 1) {
00168 goto L30;
00169 }
00170
00171 if (ipiv[k] > 0) {
00172
00173
00174
00175
00176
00177 kp = ipiv[k];
00178 if (kp != k) {
00179 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00180 }
00181
00182
00183
00184
00185 i__1 = k - 1;
00186 q__1.r = -1.f, q__1.i = -0.f;
00187 cgeru_(&i__1, nrhs, &q__1, &a[k * a_dim1 + 1], &c__1, &b[k +
00188 b_dim1], ldb, &b[b_dim1 + 1], ldb);
00189
00190
00191
00192 c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
00193 cscal_(nrhs, &q__1, &b[k + b_dim1], ldb);
00194 --k;
00195 } else {
00196
00197
00198
00199
00200
00201 kp = -ipiv[k];
00202 if (kp != k - 1) {
00203 cswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1], ldb);
00204 }
00205
00206
00207
00208
00209 i__1 = k - 2;
00210 q__1.r = -1.f, q__1.i = -0.f;
00211 cgeru_(&i__1, nrhs, &q__1, &a[k * a_dim1 + 1], &c__1, &b[k +
00212 b_dim1], ldb, &b[b_dim1 + 1], ldb);
00213 i__1 = k - 2;
00214 q__1.r = -1.f, q__1.i = -0.f;
00215 cgeru_(&i__1, nrhs, &q__1, &a[(k - 1) * a_dim1 + 1], &c__1, &b[k
00216 - 1 + b_dim1], ldb, &b[b_dim1 + 1], ldb);
00217
00218
00219
00220 i__1 = k - 1 + k * a_dim1;
00221 akm1k.r = a[i__1].r, akm1k.i = a[i__1].i;
00222 c_div(&q__1, &a[k - 1 + (k - 1) * a_dim1], &akm1k);
00223 akm1.r = q__1.r, akm1.i = q__1.i;
00224 c_div(&q__1, &a[k + k * a_dim1], &akm1k);
00225 ak.r = q__1.r, ak.i = q__1.i;
00226 q__2.r = akm1.r * ak.r - akm1.i * ak.i, q__2.i = akm1.r * ak.i +
00227 akm1.i * ak.r;
00228 q__1.r = q__2.r - 1.f, q__1.i = q__2.i - 0.f;
00229 denom.r = q__1.r, denom.i = q__1.i;
00230 i__1 = *nrhs;
00231 for (j = 1; j <= i__1; ++j) {
00232 c_div(&q__1, &b[k - 1 + j * b_dim1], &akm1k);
00233 bkm1.r = q__1.r, bkm1.i = q__1.i;
00234 c_div(&q__1, &b[k + j * b_dim1], &akm1k);
00235 bk.r = q__1.r, bk.i = q__1.i;
00236 i__2 = k - 1 + j * b_dim1;
00237 q__3.r = ak.r * bkm1.r - ak.i * bkm1.i, q__3.i = ak.r *
00238 bkm1.i + ak.i * bkm1.r;
00239 q__2.r = q__3.r - bk.r, q__2.i = q__3.i - bk.i;
00240 c_div(&q__1, &q__2, &denom);
00241 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00242 i__2 = k + j * b_dim1;
00243 q__3.r = akm1.r * bk.r - akm1.i * bk.i, q__3.i = akm1.r *
00244 bk.i + akm1.i * bk.r;
00245 q__2.r = q__3.r - bkm1.r, q__2.i = q__3.i - bkm1.i;
00246 c_div(&q__1, &q__2, &denom);
00247 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00248
00249 }
00250 k += -2;
00251 }
00252
00253 goto L10;
00254 L30:
00255
00256
00257
00258
00259
00260
00261 k = 1;
00262 L40:
00263
00264
00265
00266 if (k > *n) {
00267 goto L50;
00268 }
00269
00270 if (ipiv[k] > 0) {
00271
00272
00273
00274
00275
00276
00277 i__1 = k - 1;
00278 q__1.r = -1.f, q__1.i = -0.f;
00279 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[b_offset], ldb, &a[k *
00280 a_dim1 + 1], &c__1, &c_b1, &b[k + b_dim1], ldb)
00281 ;
00282
00283
00284
00285 kp = ipiv[k];
00286 if (kp != k) {
00287 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00288 }
00289 ++k;
00290 } else {
00291
00292
00293
00294
00295
00296
00297 i__1 = k - 1;
00298 q__1.r = -1.f, q__1.i = -0.f;
00299 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[b_offset], ldb, &a[k *
00300 a_dim1 + 1], &c__1, &c_b1, &b[k + b_dim1], ldb)
00301 ;
00302 i__1 = k - 1;
00303 q__1.r = -1.f, q__1.i = -0.f;
00304 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[b_offset], ldb, &a[(k
00305 + 1) * a_dim1 + 1], &c__1, &c_b1, &b[k + 1 + b_dim1], ldb);
00306
00307
00308
00309 kp = -ipiv[k];
00310 if (kp != k) {
00311 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00312 }
00313 k += 2;
00314 }
00315
00316 goto L40;
00317 L50:
00318
00319 ;
00320 } else {
00321
00322
00323
00324
00325
00326
00327
00328
00329 k = 1;
00330 L60:
00331
00332
00333
00334 if (k > *n) {
00335 goto L80;
00336 }
00337
00338 if (ipiv[k] > 0) {
00339
00340
00341
00342
00343
00344 kp = ipiv[k];
00345 if (kp != k) {
00346 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00347 }
00348
00349
00350
00351
00352 if (k < *n) {
00353 i__1 = *n - k;
00354 q__1.r = -1.f, q__1.i = -0.f;
00355 cgeru_(&i__1, nrhs, &q__1, &a[k + 1 + k * a_dim1], &c__1, &b[
00356 k + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00357 }
00358
00359
00360
00361 c_div(&q__1, &c_b1, &a[k + k * a_dim1]);
00362 cscal_(nrhs, &q__1, &b[k + b_dim1], ldb);
00363 ++k;
00364 } else {
00365
00366
00367
00368
00369
00370 kp = -ipiv[k];
00371 if (kp != k + 1) {
00372 cswap_(nrhs, &b[k + 1 + b_dim1], ldb, &b[kp + b_dim1], ldb);
00373 }
00374
00375
00376
00377
00378 if (k < *n - 1) {
00379 i__1 = *n - k - 1;
00380 q__1.r = -1.f, q__1.i = -0.f;
00381 cgeru_(&i__1, nrhs, &q__1, &a[k + 2 + k * a_dim1], &c__1, &b[
00382 k + b_dim1], ldb, &b[k + 2 + b_dim1], ldb);
00383 i__1 = *n - k - 1;
00384 q__1.r = -1.f, q__1.i = -0.f;
00385 cgeru_(&i__1, nrhs, &q__1, &a[k + 2 + (k + 1) * a_dim1], &
00386 c__1, &b[k + 1 + b_dim1], ldb, &b[k + 2 + b_dim1],
00387 ldb);
00388 }
00389
00390
00391
00392 i__1 = k + 1 + k * a_dim1;
00393 akm1k.r = a[i__1].r, akm1k.i = a[i__1].i;
00394 c_div(&q__1, &a[k + k * a_dim1], &akm1k);
00395 akm1.r = q__1.r, akm1.i = q__1.i;
00396 c_div(&q__1, &a[k + 1 + (k + 1) * a_dim1], &akm1k);
00397 ak.r = q__1.r, ak.i = q__1.i;
00398 q__2.r = akm1.r * ak.r - akm1.i * ak.i, q__2.i = akm1.r * ak.i +
00399 akm1.i * ak.r;
00400 q__1.r = q__2.r - 1.f, q__1.i = q__2.i - 0.f;
00401 denom.r = q__1.r, denom.i = q__1.i;
00402 i__1 = *nrhs;
00403 for (j = 1; j <= i__1; ++j) {
00404 c_div(&q__1, &b[k + j * b_dim1], &akm1k);
00405 bkm1.r = q__1.r, bkm1.i = q__1.i;
00406 c_div(&q__1, &b[k + 1 + j * b_dim1], &akm1k);
00407 bk.r = q__1.r, bk.i = q__1.i;
00408 i__2 = k + j * b_dim1;
00409 q__3.r = ak.r * bkm1.r - ak.i * bkm1.i, q__3.i = ak.r *
00410 bkm1.i + ak.i * bkm1.r;
00411 q__2.r = q__3.r - bk.r, q__2.i = q__3.i - bk.i;
00412 c_div(&q__1, &q__2, &denom);
00413 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00414 i__2 = k + 1 + j * b_dim1;
00415 q__3.r = akm1.r * bk.r - akm1.i * bk.i, q__3.i = akm1.r *
00416 bk.i + akm1.i * bk.r;
00417 q__2.r = q__3.r - bkm1.r, q__2.i = q__3.i - bkm1.i;
00418 c_div(&q__1, &q__2, &denom);
00419 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00420
00421 }
00422 k += 2;
00423 }
00424
00425 goto L60;
00426 L80:
00427
00428
00429
00430
00431
00432
00433 k = *n;
00434 L90:
00435
00436
00437
00438 if (k < 1) {
00439 goto L100;
00440 }
00441
00442 if (ipiv[k] > 0) {
00443
00444
00445
00446
00447
00448
00449 if (k < *n) {
00450 i__1 = *n - k;
00451 q__1.r = -1.f, q__1.i = -0.f;
00452 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[k + 1 + b_dim1],
00453 ldb, &a[k + 1 + k * a_dim1], &c__1, &c_b1, &b[k +
00454 b_dim1], ldb);
00455 }
00456
00457
00458
00459 kp = ipiv[k];
00460 if (kp != k) {
00461 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00462 }
00463 --k;
00464 } else {
00465
00466
00467
00468
00469
00470
00471 if (k < *n) {
00472 i__1 = *n - k;
00473 q__1.r = -1.f, q__1.i = -0.f;
00474 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[k + 1 + b_dim1],
00475 ldb, &a[k + 1 + k * a_dim1], &c__1, &c_b1, &b[k +
00476 b_dim1], ldb);
00477 i__1 = *n - k;
00478 q__1.r = -1.f, q__1.i = -0.f;
00479 cgemv_("Transpose", &i__1, nrhs, &q__1, &b[k + 1 + b_dim1],
00480 ldb, &a[k + 1 + (k - 1) * a_dim1], &c__1, &c_b1, &b[k
00481 - 1 + b_dim1], ldb);
00482 }
00483
00484
00485
00486 kp = -ipiv[k];
00487 if (kp != k) {
00488 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00489 }
00490 k += -2;
00491 }
00492
00493 goto L90;
00494 L100:
00495 ;
00496 }
00497
00498 return 0;
00499
00500
00501
00502 }