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