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 doublereal c_b15 = 1.;
00019 static integer c__1 = 1;
00020
00021 int dlavsp_(char *uplo, char *trans, char *diag, integer *n,
00022 integer *nrhs, doublereal *a, integer *ipiv, doublereal *b, integer *
00023 ldb, integer *info)
00024 {
00025
00026 integer b_dim1, b_offset, i__1;
00027
00028
00029 integer j, k;
00030 doublereal t1, t2, d11, d12, d21, d22;
00031 integer kc, kp;
00032 extern int dger_(integer *, integer *, doublereal *,
00033 doublereal *, integer *, doublereal *, integer *, doublereal *,
00034 integer *), dscal_(integer *, doublereal *, doublereal *, integer
00035 *);
00036 extern logical lsame_(char *, char *);
00037 extern int dgemv_(char *, integer *, integer *,
00038 doublereal *, doublereal *, integer *, doublereal *, integer *,
00039 doublereal *, doublereal *, integer *), dswap_(integer *,
00040 doublereal *, integer *, doublereal *, integer *), xerbla_(char *,
00041 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 --a;
00133 --ipiv;
00134 b_dim1 = *ldb;
00135 b_offset = 1 + b_dim1;
00136 b -= b_offset;
00137
00138
00139 *info = 0;
00140 if (! lsame_(uplo, "U") && ! lsame_(uplo, "L")) {
00141 *info = -1;
00142 } else if (! lsame_(trans, "N") && ! lsame_(trans,
00143 "T") && ! lsame_(trans, "C")) {
00144 *info = -2;
00145 } else if (! lsame_(diag, "U") && ! lsame_(diag,
00146 "N")) {
00147 *info = -3;
00148 } else if (*n < 0) {
00149 *info = -4;
00150 } else if (*ldb < max(1,*n)) {
00151 *info = -8;
00152 }
00153 if (*info != 0) {
00154 i__1 = -(*info);
00155 xerbla_("DLAVSP ", &i__1);
00156 return 0;
00157 }
00158
00159
00160
00161 if (*n == 0) {
00162 return 0;
00163 }
00164
00165 nounit = lsame_(diag, "N");
00166
00167
00168
00169
00170
00171 if (lsame_(trans, "N")) {
00172
00173
00174
00175
00176 if (lsame_(uplo, "U")) {
00177
00178
00179
00180 k = 1;
00181 kc = 1;
00182 L10:
00183 if (k > *n) {
00184 goto L30;
00185 }
00186
00187
00188
00189 if (ipiv[k] > 0) {
00190
00191
00192
00193 if (nounit) {
00194 dscal_(nrhs, &a[kc + k - 1], &b[k + b_dim1], ldb);
00195 }
00196
00197
00198
00199 if (k > 1) {
00200
00201
00202
00203 i__1 = k - 1;
00204 dger_(&i__1, nrhs, &c_b15, &a[kc], &c__1, &b[k + b_dim1],
00205 ldb, &b[b_dim1 + 1], ldb);
00206
00207
00208
00209 kp = ipiv[k];
00210 if (kp != k) {
00211 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00212 ldb);
00213 }
00214 }
00215 kc += k;
00216 ++k;
00217 } else {
00218
00219
00220
00221 kcnext = kc + k;
00222
00223
00224
00225 if (nounit) {
00226 d11 = a[kcnext - 1];
00227 d22 = a[kcnext + k];
00228 d12 = a[kcnext + k - 1];
00229 d21 = d12;
00230 i__1 = *nrhs;
00231 for (j = 1; j <= i__1; ++j) {
00232 t1 = b[k + j * b_dim1];
00233 t2 = b[k + 1 + j * b_dim1];
00234 b[k + j * b_dim1] = d11 * t1 + d12 * t2;
00235 b[k + 1 + j * b_dim1] = d21 * t1 + d22 * t2;
00236
00237 }
00238 }
00239
00240
00241
00242 if (k > 1) {
00243
00244
00245
00246 i__1 = k - 1;
00247 dger_(&i__1, nrhs, &c_b15, &a[kc], &c__1, &b[k + b_dim1],
00248 ldb, &b[b_dim1 + 1], ldb);
00249 i__1 = k - 1;
00250 dger_(&i__1, nrhs, &c_b15, &a[kcnext], &c__1, &b[k + 1 +
00251 b_dim1], ldb, &b[b_dim1 + 1], ldb);
00252
00253
00254
00255 kp = (i__1 = ipiv[k], abs(i__1));
00256 if (kp != k) {
00257 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00258 ldb);
00259 }
00260 }
00261 kc = kcnext + k + 1;
00262 k += 2;
00263 }
00264 goto L10;
00265 L30:
00266
00267
00268
00269
00270 ;
00271 } else {
00272
00273
00274
00275 k = *n;
00276 kc = *n * (*n + 1) / 2 + 1;
00277 L40:
00278 if (k < 1) {
00279 goto L60;
00280 }
00281 kc -= *n - k + 1;
00282
00283
00284
00285
00286 if (ipiv[k] > 0) {
00287
00288
00289
00290
00291
00292 if (nounit) {
00293 dscal_(nrhs, &a[kc], &b[k + b_dim1], ldb);
00294 }
00295
00296
00297
00298 if (k != *n) {
00299 kp = ipiv[k];
00300
00301
00302
00303 i__1 = *n - k;
00304 dger_(&i__1, nrhs, &c_b15, &a[kc + 1], &c__1, &b[k +
00305 b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00306
00307
00308
00309
00310 if (kp != k) {
00311 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00312 ldb);
00313 }
00314 }
00315 --k;
00316
00317 } else {
00318
00319
00320
00321 kcnext = kc - (*n - k + 2);
00322
00323
00324
00325 if (nounit) {
00326 d11 = a[kcnext];
00327 d22 = a[kc];
00328 d21 = a[kcnext + 1];
00329 d12 = d21;
00330 i__1 = *nrhs;
00331 for (j = 1; j <= i__1; ++j) {
00332 t1 = b[k - 1 + j * b_dim1];
00333 t2 = b[k + j * b_dim1];
00334 b[k - 1 + j * b_dim1] = d11 * t1 + d12 * t2;
00335 b[k + j * b_dim1] = d21 * t1 + d22 * t2;
00336
00337 }
00338 }
00339
00340
00341
00342 if (k != *n) {
00343
00344
00345
00346 i__1 = *n - k;
00347 dger_(&i__1, nrhs, &c_b15, &a[kc + 1], &c__1, &b[k +
00348 b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00349 i__1 = *n - k;
00350 dger_(&i__1, nrhs, &c_b15, &a[kcnext + 2], &c__1, &b[k -
00351 1 + b_dim1], ldb, &b[k + 1 + b_dim1], ldb);
00352
00353
00354
00355
00356 kp = (i__1 = ipiv[k], abs(i__1));
00357 if (kp != k) {
00358 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00359 ldb);
00360 }
00361 }
00362 kc = kcnext;
00363 k += -2;
00364 }
00365 goto L40;
00366 L60:
00367 ;
00368 }
00369
00370
00371
00372
00373
00374 } else {
00375
00376
00377
00378
00379
00380 if (lsame_(uplo, "U")) {
00381
00382
00383
00384 k = *n;
00385 kc = *n * (*n + 1) / 2 + 1;
00386 L70:
00387 if (k < 1) {
00388 goto L90;
00389 }
00390 kc -= k;
00391
00392
00393
00394 if (ipiv[k] > 0) {
00395 if (k > 1) {
00396
00397
00398
00399 kp = ipiv[k];
00400 if (kp != k) {
00401 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00402 ldb);
00403 }
00404
00405
00406
00407 i__1 = k - 1;
00408 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset],
00409 ldb, &a[kc], &c__1, &c_b15, &b[k + b_dim1], ldb);
00410 }
00411 if (nounit) {
00412 dscal_(nrhs, &a[kc + k - 1], &b[k + b_dim1], ldb);
00413 }
00414 --k;
00415
00416
00417
00418 } else {
00419 kcnext = kc - (k - 1);
00420 if (k > 2) {
00421
00422
00423
00424 kp = (i__1 = ipiv[k], abs(i__1));
00425 if (kp != k - 1) {
00426 dswap_(nrhs, &b[k - 1 + b_dim1], ldb, &b[kp + b_dim1],
00427 ldb);
00428 }
00429
00430
00431
00432 i__1 = k - 2;
00433 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset],
00434 ldb, &a[kc], &c__1, &c_b15, &b[k + b_dim1], ldb);
00435 i__1 = k - 2;
00436 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[b_offset],
00437 ldb, &a[kcnext], &c__1, &c_b15, &b[k - 1 + b_dim1]
00438 , ldb);
00439 }
00440
00441
00442
00443 if (nounit) {
00444 d11 = a[kc - 1];
00445 d22 = a[kc + k - 1];
00446 d12 = a[kc + k - 2];
00447 d21 = d12;
00448 i__1 = *nrhs;
00449 for (j = 1; j <= i__1; ++j) {
00450 t1 = b[k - 1 + j * b_dim1];
00451 t2 = b[k + j * b_dim1];
00452 b[k - 1 + j * b_dim1] = d11 * t1 + d12 * t2;
00453 b[k + j * b_dim1] = d21 * t1 + d22 * t2;
00454
00455 }
00456 }
00457 kc = kcnext;
00458 k += -2;
00459 }
00460 goto L70;
00461 L90:
00462
00463
00464
00465
00466
00467 ;
00468 } else {
00469
00470
00471
00472 k = 1;
00473 kc = 1;
00474 L100:
00475 if (k > *n) {
00476 goto L120;
00477 }
00478
00479
00480
00481 if (ipiv[k] > 0) {
00482 if (k < *n) {
00483
00484
00485
00486 kp = ipiv[k];
00487 if (kp != k) {
00488 dswap_(nrhs, &b[k + b_dim1], ldb, &b[kp + b_dim1],
00489 ldb);
00490 }
00491
00492
00493
00494 i__1 = *n - k;
00495 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 1 +
00496 b_dim1], ldb, &a[kc + 1], &c__1, &c_b15, &b[k +
00497 b_dim1], ldb);
00498 }
00499 if (nounit) {
00500 dscal_(nrhs, &a[kc], &b[k + b_dim1], ldb);
00501 }
00502 kc = kc + *n - k + 1;
00503 ++k;
00504
00505
00506
00507 } else {
00508 kcnext = kc + *n - k + 1;
00509 if (k < *n - 1) {
00510
00511
00512
00513 kp = (i__1 = ipiv[k], abs(i__1));
00514 if (kp != k + 1) {
00515 dswap_(nrhs, &b[k + 1 + b_dim1], ldb, &b[kp + b_dim1],
00516 ldb);
00517 }
00518
00519
00520
00521 i__1 = *n - k - 1;
00522 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 2 +
00523 b_dim1], ldb, &a[kcnext + 1], &c__1, &c_b15, &b[k
00524 + 1 + b_dim1], ldb);
00525 i__1 = *n - k - 1;
00526 dgemv_("Transpose", &i__1, nrhs, &c_b15, &b[k + 2 +
00527 b_dim1], ldb, &a[kc + 2], &c__1, &c_b15, &b[k +
00528 b_dim1], ldb);
00529 }
00530
00531
00532
00533 if (nounit) {
00534 d11 = a[kc];
00535 d22 = a[kcnext];
00536 d21 = a[kc + 1];
00537 d12 = d21;
00538 i__1 = *nrhs;
00539 for (j = 1; j <= i__1; ++j) {
00540 t1 = b[k + j * b_dim1];
00541 t2 = b[k + 1 + j * b_dim1];
00542 b[k + j * b_dim1] = d11 * t1 + d12 * t2;
00543 b[k + 1 + j * b_dim1] = d21 * t1 + d22 * t2;
00544
00545 }
00546 }
00547 kc = kcnext + (*n - k);
00548 k += 2;
00549 }
00550 goto L100;
00551 L120:
00552 ;
00553 }
00554
00555 }
00556 return 0;
00557
00558
00559
00560 }