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 clavsy_(char *uplo, char *trans, char *diag, integer *n,
00022 integer *nrhs, complex *a, integer *lda, integer *ipiv, complex *b,
00023 integer *ldb, integer *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 integer j, k;
00031 complex t1, t2, d11, d12, d21, d22;
00032 integer kp;
00033 extern int cscal_(integer *, complex *, complex *,
00034 integer *);
00035 extern logical lsame_(char *, char *);
00036 extern int cgemv_(char *, integer *, integer *, complex *
00037 , complex *, integer *, complex *, integer *, complex *, complex *
00038 , integer *), cgeru_(integer *, integer *, complex *,
00039 complex *, integer *, complex *, integer *, complex *, integer *),
00040 cswap_(integer *, complex *, integer *, complex *, integer *),
00041 xerbla_(char *, integer *);
00042 logical nounit;
00043
00044
00045
00046
00047
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
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 a_dim1 = *lda;
00168 a_offset = 1 + a_dim1;
00169 a -= a_offset;
00170 --ipiv;
00171 b_dim1 = *ldb;
00172 b_offset = 1 + b_dim1;
00173 b -= b_offset;
00174
00175
00176 *info = 0;
00177 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00178 *info = -1;
00179 } else if (! lsame_(trans, "N") && ! lsame_(trans,
00180 "T")) {
00181 *info = -2;
00182 } else if (! lsame_(diag, "U") && ! lsame_(diag,
00183 "N")) {
00184 *info = -3;
00185 } else if (*n < 0) {
00186 *info = -4;
00187 } else if (*lda < max(1,*n)) {
00188 *info = -6;
00189 } else if (*ldb < max(1,*n)) {
00190 *info = -9;
00191 }
00192 if (*info != 0) {
00193 i__1 = -(*info);
00194 xerbla_("CLAVSY ", &i__1);
00195 return 0;
00196 }
00197
00198
00199
00200 if (*n == 0) {
00201 return 0;
00202 }
00203
00204 nounit = lsame_(diag, "N");
00205
00206
00207
00208
00209
00210 if (lsame_(trans, "N")) {
00211
00212
00213
00214
00215 if (lsame_(uplo, "U")) {
00216
00217
00218
00219 k = 1;
00220 L10:
00221 if (k > *n) {
00222 goto L30;
00223 }
00224 if (ipiv[k] > 0) {
00225
00226
00227
00228
00229
00230 if (nounit) {
00231 cscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00232 }
00233
00234
00235
00236 if (k > 1) {
00237
00238
00239
00240 i__1 = k - 1;
00241 cgeru_(&i__1, nrhs, &c_b1, &a[k * a_dim1 + 1], &c__1, &b[
00242 k + b_dim1], ldb, &b[b_dim1 + 1], ldb);
00243
00244
00245
00246 kp = ipiv[k];
00247 if (kp != k) {
00248 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00249 ldb);
00250 }
00251 }
00252 ++k;
00253 } else {
00254
00255
00256
00257
00258
00259 if (nounit) {
00260 i__1 = k + k * a_dim1;
00261 d11.r = a[i__1].r, d11.i = a[i__1].i;
00262 i__1 = k + 1 + (k + 1) * a_dim1;
00263 d22.r = a[i__1].r, d22.i = a[i__1].i;
00264 i__1 = k + (k + 1) * a_dim1;
00265 d12.r = a[i__1].r, d12.i = a[i__1].i;
00266 d21.r = d12.r, d21.i = d12.i;
00267 i__1 = *nrhs;
00268 for (j = 1; j <= i__1; ++j) {
00269 i__2 = k + j * b_dim1;
00270 t1.r = b[i__2].r, t1.i = b[i__2].i;
00271 i__2 = k + 1 + j * b_dim1;
00272 t2.r = b[i__2].r, t2.i = b[i__2].i;
00273 i__2 = k + j * b_dim1;
00274 q__2.r = d11.r * t1.r - d11.i * t1.i, q__2.i = d11.r *
00275 t1.i + d11.i * t1.r;
00276 q__3.r = d12.r * t2.r - d12.i * t2.i, q__3.i = d12.r *
00277 t2.i + d12.i * t2.r;
00278 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00279 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00280 i__2 = k + 1 + j * b_dim1;
00281 q__2.r = d21.r * t1.r - d21.i * t1.i, q__2.i = d21.r *
00282 t1.i + d21.i * t1.r;
00283 q__3.r = d22.r * t2.r - d22.i * t2.i, q__3.i = d22.r *
00284 t2.i + d22.i * t2.r;
00285 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00286 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00287
00288 }
00289 }
00290
00291
00292
00293 if (k > 1) {
00294
00295
00296
00297 i__1 = k - 1;
00298 cgeru_(&i__1, nrhs, &c_b1, &a[k * a_dim1 + 1], &c__1, &b[
00299 k + b_dim1], ldb, &b[b_dim1 + 1], ldb);
00300 i__1 = k - 1;
00301 cgeru_(&i__1, nrhs, &c_b1, &a[(k + 1) * a_dim1 + 1], &
00302 c__1, &b[k + 1 + b_dim1], ldb, &b[b_dim1 + 1],
00303 ldb);
00304
00305
00306
00307 kp = (i__1 = ipiv[k], abs(i__1));
00308 if (kp != k) {
00309 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00310 ldb);
00311 }
00312 }
00313 k += 2;
00314 }
00315 goto L10;
00316 L30:
00317
00318
00319
00320
00321 ;
00322 } else {
00323
00324
00325
00326 k = *n;
00327 L40:
00328 if (k < 1) {
00329 goto L60;
00330 }
00331
00332
00333
00334
00335 if (ipiv[k] > 0) {
00336
00337
00338
00339
00340
00341 if (nounit) {
00342 cscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00343 }
00344
00345
00346
00347 if (k != *n) {
00348 kp = ipiv[k];
00349
00350
00351
00352 i__1 = *n - k;
00353 cgeru_(&i__1, nrhs, &c_b1, &a[k + 1 + k * a_dim1], &c__1,
00354 &b[k + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00355
00356
00357
00358
00359 if (kp != k) {
00360 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00361 ldb);
00362 }
00363 }
00364 --k;
00365
00366 } else {
00367
00368
00369
00370
00371
00372 if (nounit) {
00373 i__1 = k - 1 + (k - 1) * a_dim1;
00374 d11.r = a[i__1].r, d11.i = a[i__1].i;
00375 i__1 = k + k * a_dim1;
00376 d22.r = a[i__1].r, d22.i = a[i__1].i;
00377 i__1 = k + (k - 1) * a_dim1;
00378 d21.r = a[i__1].r, d21.i = a[i__1].i;
00379 d12.r = d21.r, d12.i = d21.i;
00380 i__1 = *nrhs;
00381 for (j = 1; j <= i__1; ++j) {
00382 i__2 = k - 1 + j * b_dim1;
00383 t1.r = b[i__2].r, t1.i = b[i__2].i;
00384 i__2 = k + j * b_dim1;
00385 t2.r = b[i__2].r, t2.i = b[i__2].i;
00386 i__2 = k - 1 + j * b_dim1;
00387 q__2.r = d11.r * t1.r - d11.i * t1.i, q__2.i = d11.r *
00388 t1.i + d11.i * t1.r;
00389 q__3.r = d12.r * t2.r - d12.i * t2.i, q__3.i = d12.r *
00390 t2.i + d12.i * t2.r;
00391 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00392 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00393 i__2 = k + j * b_dim1;
00394 q__2.r = d21.r * t1.r - d21.i * t1.i, q__2.i = d21.r *
00395 t1.i + d21.i * t1.r;
00396 q__3.r = d22.r * t2.r - d22.i * t2.i, q__3.i = d22.r *
00397 t2.i + d22.i * t2.r;
00398 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00399 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00400
00401 }
00402 }
00403
00404
00405
00406 if (k != *n) {
00407
00408
00409
00410 i__1 = *n - k;
00411 cgeru_(&i__1, nrhs, &c_b1, &a[k + 1 + k * a_dim1], &c__1,
00412 &b[k + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00413 i__1 = *n - k;
00414 cgeru_(&i__1, nrhs, &c_b1, &a[k + 1 + (k - 1) * a_dim1], &
00415 c__1, &b[k - 1 + b_dim1], ldb, &b[k + 1 + b_dim1],
00416 ldb);
00417
00418
00419
00420
00421 kp = (i__1 = ipiv[k], abs(i__1));
00422 if (kp != k) {
00423 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00424 ldb);
00425 }
00426 }
00427 k += -2;
00428 }
00429 goto L40;
00430 L60:
00431 ;
00432 }
00433
00434
00435
00436
00437
00438 } else if (lsame_(trans, "T")) {
00439
00440
00441
00442
00443
00444 if (lsame_(uplo, "U")) {
00445
00446
00447
00448 k = *n;
00449 L70:
00450 if (k < 1) {
00451 goto L90;
00452 }
00453
00454
00455
00456 if (ipiv[k] > 0) {
00457 if (k > 1) {
00458
00459
00460
00461 kp = ipiv[k];
00462 if (kp != k) {
00463 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00464 ldb);
00465 }
00466
00467
00468
00469 i__1 = k - 1;
00470 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[b_offset], ldb,
00471 &a[k * a_dim1 + 1], &c__1, &c_b1, &b[k + b_dim1],
00472 ldb);
00473 }
00474 if (nounit) {
00475 cscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00476 }
00477 --k;
00478
00479
00480
00481 } else {
00482 if (k > 2) {
00483
00484
00485
00486 kp = (i__1 = ipiv[k], abs(i__1));
00487 if (kp != k - 1) {
00488 cswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1],
00489 ldb);
00490 }
00491
00492
00493
00494 i__1 = k - 2;
00495 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[b_offset], ldb,
00496 &a[k * a_dim1 + 1], &c__1, &c_b1, &b[k + b_dim1],
00497 ldb);
00498 i__1 = k - 2;
00499 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[b_offset], ldb,
00500 &a[(k - 1) * a_dim1 + 1], &c__1, &c_b1, &b[k - 1
00501 + b_dim1], ldb);
00502 }
00503
00504
00505
00506 if (nounit) {
00507 i__1 = k - 1 + (k - 1) * a_dim1;
00508 d11.r = a[i__1].r, d11.i = a[i__1].i;
00509 i__1 = k + k * a_dim1;
00510 d22.r = a[i__1].r, d22.i = a[i__1].i;
00511 i__1 = k - 1 + k * a_dim1;
00512 d12.r = a[i__1].r, d12.i = a[i__1].i;
00513 d21.r = d12.r, d21.i = d12.i;
00514 i__1 = *nrhs;
00515 for (j = 1; j <= i__1; ++j) {
00516 i__2 = k - 1 + j * b_dim1;
00517 t1.r = b[i__2].r, t1.i = b[i__2].i;
00518 i__2 = k + j * b_dim1;
00519 t2.r = b[i__2].r, t2.i = b[i__2].i;
00520 i__2 = k - 1 + j * b_dim1;
00521 q__2.r = d11.r * t1.r - d11.i * t1.i, q__2.i = d11.r *
00522 t1.i + d11.i * t1.r;
00523 q__3.r = d12.r * t2.r - d12.i * t2.i, q__3.i = d12.r *
00524 t2.i + d12.i * t2.r;
00525 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00526 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00527 i__2 = k + j * b_dim1;
00528 q__2.r = d21.r * t1.r - d21.i * t1.i, q__2.i = d21.r *
00529 t1.i + d21.i * t1.r;
00530 q__3.r = d22.r * t2.r - d22.i * t2.i, q__3.i = d22.r *
00531 t2.i + d22.i * t2.r;
00532 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00533 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00534
00535 }
00536 }
00537 k += -2;
00538 }
00539 goto L70;
00540 L90:
00541
00542
00543
00544
00545
00546 ;
00547 } else {
00548
00549
00550
00551 k = 1;
00552 L100:
00553 if (k > *n) {
00554 goto L120;
00555 }
00556
00557
00558
00559 if (ipiv[k] > 0) {
00560 if (k < *n) {
00561
00562
00563
00564 kp = ipiv[k];
00565 if (kp != k) {
00566 cswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00567 ldb);
00568 }
00569
00570
00571
00572 i__1 = *n - k;
00573 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[k + 1 + b_dim1]
00574 , ldb, &a[k + 1 + k * a_dim1], &c__1, &c_b1, &b[k
00575 + b_dim1], ldb);
00576 }
00577 if (nounit) {
00578 cscal_(nrhs, &a[k + k * a_dim1], &b[k + b_dim1], ldb);
00579 }
00580 ++k;
00581
00582
00583
00584 } else {
00585 if (k < *n - 1) {
00586
00587
00588
00589 kp = (i__1 = ipiv[k], abs(i__1));
00590 if (kp != k + 1) {
00591 cswap_(nrhs, &b[k + 1 + b_dim1], ldb, &b[kp + b_dim1],
00592 ldb);
00593 }
00594
00595
00596
00597 i__1 = *n - k - 1;
00598 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[k + 2 + b_dim1]
00599 , ldb, &a[k + 2 + (k + 1) * a_dim1], &c__1, &c_b1,
00600 &b[k + 1 + b_dim1], ldb);
00601 i__1 = *n - k - 1;
00602 cgemv_("Transpose", &i__1, nrhs, &c_b1, &b[k + 2 + b_dim1]
00603 , ldb, &a[k + 2 + k * a_dim1], &c__1, &c_b1, &b[k
00604 + b_dim1], ldb);
00605 }
00606
00607
00608
00609 if (nounit) {
00610 i__1 = k + k * a_dim1;
00611 d11.r = a[i__1].r, d11.i = a[i__1].i;
00612 i__1 = k + 1 + (k + 1) * a_dim1;
00613 d22.r = a[i__1].r, d22.i = a[i__1].i;
00614 i__1 = k + 1 + k * a_dim1;
00615 d21.r = a[i__1].r, d21.i = a[i__1].i;
00616 d12.r = d21.r, d12.i = d21.i;
00617 i__1 = *nrhs;
00618 for (j = 1; j <= i__1; ++j) {
00619 i__2 = k + j * b_dim1;
00620 t1.r = b[i__2].r, t1.i = b[i__2].i;
00621 i__2 = k + 1 + j * b_dim1;
00622 t2.r = b[i__2].r, t2.i = b[i__2].i;
00623 i__2 = k + j * b_dim1;
00624 q__2.r = d11.r * t1.r - d11.i * t1.i, q__2.i = d11.r *
00625 t1.i + d11.i * t1.r;
00626 q__3.r = d12.r * t2.r - d12.i * t2.i, q__3.i = d12.r *
00627 t2.i + d12.i * t2.r;
00628 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00629 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00630 i__2 = k + 1 + j * b_dim1;
00631 q__2.r = d21.r * t1.r - d21.i * t1.i, q__2.i = d21.r *
00632 t1.i + d21.i * t1.r;
00633 q__3.r = d22.r * t2.r - d22.i * t2.i, q__3.i = d22.r *
00634 t2.i + d22.i * t2.r;
00635 q__1.r = q__2.r + q__3.r, q__1.i = q__2.i + q__3.i;
00636 b[i__2].r = q__1.r, b[i__2].i = q__1.i;
00637
00638 }
00639 }
00640 k += 2;
00641 }
00642 goto L100;
00643 L120:
00644 ;
00645 }
00646 }
00647 return 0;
00648
00649
00650
00651 }