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 doublecomplex c_b1 = {1.,0.};
00019 static integer c__1 = 1;
00020
00021 int zsytrs_(char *uplo, integer *n, integer *nrhs,
00022 doublecomplex *a, integer *lda, integer *ipiv, doublecomplex *b,
00023 integer *ldb, integer *info)
00024 {
00025
00026 integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00027 doublecomplex z__1, z__2, z__3;
00028
00029
00030 void z_div(doublecomplex *, doublecomplex *, doublecomplex *);
00031
00032
00033 integer j, k;
00034 doublecomplex ak, bk;
00035 integer kp;
00036 doublecomplex akm1, bkm1, akm1k;
00037 extern logical lsame_(char *, char *);
00038 doublecomplex denom;
00039 extern int zscal_(integer *, doublecomplex *,
00040 doublecomplex *, integer *), zgemv_(char *, integer *, integer *,
00041 doublecomplex *, doublecomplex *, integer *, doublecomplex *,
00042 integer *, doublecomplex *, doublecomplex *, integer *);
00043 logical upper;
00044 extern int zgeru_(integer *, integer *, doublecomplex *,
00045 doublecomplex *, integer *, doublecomplex *, integer *,
00046 doublecomplex *, integer *), zswap_(integer *, doublecomplex *,
00047 integer *, doublecomplex *, integer *), 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_("ZSYTRS", &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 zswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1], ldb);
00180 }
00181
00182
00183
00184
00185 i__1 = k - 1;
00186 z__1.r = -1., z__1.i = -0.;
00187 zgeru_(&i__1, nrhs, &z__1, &a[k * a_dim1 + 1], &c__1, &b[k +
00188 b_dim1], ldb, &b[b_dim1 + 1], ldb);
00189
00190
00191
00192 z_div(&z__1, &c_b1, &a[k + k * a_dim1]);
00193 zscal_(nrhs, &z__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 zswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1], ldb);
00204 }
00205
00206
00207
00208
00209 i__1 = k - 2;
00210 z__1.r = -1., z__1.i = -0.;
00211 zgeru_(&i__1, nrhs, &z__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 z__1.r = -1., z__1.i = -0.;
00215 zgeru_(&i__1, nrhs, &z__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 z_div(&z__1, &a[k - 1 + (k - 1) * a_dim1], &akm1k);
00223 akm1.r = z__1.r, akm1.i = z__1.i;
00224 z_div(&z__1, &a[k + k * a_dim1], &akm1k);
00225 ak.r = z__1.r, ak.i = z__1.i;
00226 z__2.r = akm1.r * ak.r - akm1.i * ak.i, z__2.i = akm1.r * ak.i +
00227 akm1.i * ak.r;
00228 z__1.r = z__2.r - 1., z__1.i = z__2.i - 0.;
00229 denom.r = z__1.r, denom.i = z__1.i;
00230 i__1 = *nrhs;
00231 for (j = 1; j <= i__1; ++j) {
00232 z_div(&z__1, &b[k - 1 + j * b_dim1], &akm1k);
00233 bkm1.r = z__1.r, bkm1.i = z__1.i;
00234 z_div(&z__1, &b[k + j * b_dim1], &akm1k);
00235 bk.r = z__1.r, bk.i = z__1.i;
00236 i__2 = k - 1 + j * b_dim1;
00237 z__3.r = ak.r * bkm1.r - ak.i * bkm1.i, z__3.i = ak.r *
00238 bkm1.i + ak.i * bkm1.r;
00239 z__2.r = z__3.r - bk.r, z__2.i = z__3.i - bk.i;
00240 z_div(&z__1, &z__2, &denom);
00241 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00242 i__2 = k + j * b_dim1;
00243 z__3.r = akm1.r * bk.r - akm1.i * bk.i, z__3.i = akm1.r *
00244 bk.i + akm1.i * bk.r;
00245 z__2.r = z__3.r - bkm1.r, z__2.i = z__3.i - bkm1.i;
00246 z_div(&z__1, &z__2, &denom);
00247 b[i__2].r = z__1.r, b[i__2].i = z__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 z__1.r = -1., z__1.i = -0.;
00279 zgemv_("Transpose", &i__1, nrhs, &z__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 zswap_(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 z__1.r = -1., z__1.i = -0.;
00299 zgemv_("Transpose", &i__1, nrhs, &z__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 z__1.r = -1., z__1.i = -0.;
00304 zgemv_("Transpose", &i__1, nrhs, &z__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 zswap_(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 zswap_(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 z__1.r = -1., z__1.i = -0.;
00355 zgeru_(&i__1, nrhs, &z__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 z_div(&z__1, &c_b1, &a[k + k * a_dim1]);
00362 zscal_(nrhs, &z__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 zswap_(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 z__1.r = -1., z__1.i = -0.;
00381 zgeru_(&i__1, nrhs, &z__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 z__1.r = -1., z__1.i = -0.;
00385 zgeru_(&i__1, nrhs, &z__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 z_div(&z__1, &a[k + k * a_dim1], &akm1k);
00395 akm1.r = z__1.r, akm1.i = z__1.i;
00396 z_div(&z__1, &a[k + 1 + (k + 1) * a_dim1], &akm1k);
00397 ak.r = z__1.r, ak.i = z__1.i;
00398 z__2.r = akm1.r * ak.r - akm1.i * ak.i, z__2.i = akm1.r * ak.i +
00399 akm1.i * ak.r;
00400 z__1.r = z__2.r - 1., z__1.i = z__2.i - 0.;
00401 denom.r = z__1.r, denom.i = z__1.i;
00402 i__1 = *nrhs;
00403 for (j = 1; j <= i__1; ++j) {
00404 z_div(&z__1, &b[k + j * b_dim1], &akm1k);
00405 bkm1.r = z__1.r, bkm1.i = z__1.i;
00406 z_div(&z__1, &b[k + 1 + j * b_dim1], &akm1k);
00407 bk.r = z__1.r, bk.i = z__1.i;
00408 i__2 = k + j * b_dim1;
00409 z__3.r = ak.r * bkm1.r - ak.i * bkm1.i, z__3.i = ak.r *
00410 bkm1.i + ak.i * bkm1.r;
00411 z__2.r = z__3.r - bk.r, z__2.i = z__3.i - bk.i;
00412 z_div(&z__1, &z__2, &denom);
00413 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00414 i__2 = k + 1 + j * b_dim1;
00415 z__3.r = akm1.r * bk.r - akm1.i * bk.i, z__3.i = akm1.r *
00416 bk.i + akm1.i * bk.r;
00417 z__2.r = z__3.r - bkm1.r, z__2.i = z__3.i - bkm1.i;
00418 z_div(&z__1, &z__2, &denom);
00419 b[i__2].r = z__1.r, b[i__2].i = z__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 z__1.r = -1., z__1.i = -0.;
00452 zgemv_("Transpose", &i__1, nrhs, &z__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 zswap_(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 z__1.r = -1., z__1.i = -0.;
00474 zgemv_("Transpose", &i__1, nrhs, &z__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 z__1.r = -1., z__1.i = -0.;
00479 zgemv_("Transpose", &i__1, nrhs, &z__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 zswap_(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 }