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 real c_b23 = -1.f;
00019 static real c_b27 = 1.f;
00020
00021 int stfsm_(char *transr, char *side, char *uplo, char *trans,
00022 char *diag, integer *m, integer *n, real *alpha, real *a, real *b,
00023 integer *ldb)
00024 {
00025
00026 integer b_dim1, b_offset, i__1, i__2;
00027
00028
00029 integer i__, j, k, m1, m2, n1, n2, info;
00030 logical normaltransr, lside;
00031 extern logical lsame_(char *, char *);
00032 extern int sgemm_(char *, char *, integer *, integer *,
00033 integer *, real *, real *, integer *, real *, integer *, real *,
00034 real *, integer *);
00035 logical lower;
00036 extern int strsm_(char *, char *, char *, char *,
00037 integer *, integer *, real *, real *, integer *, real *, integer *
00038 ), xerbla_(char *, integer *);
00039 logical misodd, nisodd, notrans;
00040
00041
00042
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
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 b_dim1 = *ldb - 1 - 0 + 1;
00269 b_offset = 0 + b_dim1 * 0;
00270 b -= b_offset;
00271
00272
00273 info = 0;
00274 normaltransr = lsame_(transr, "N");
00275 lside = lsame_(side, "L");
00276 lower = lsame_(uplo, "L");
00277 notrans = lsame_(trans, "N");
00278 if (! normaltransr && ! lsame_(transr, "T")) {
00279 info = -1;
00280 } else if (! lside && ! lsame_(side, "R")) {
00281 info = -2;
00282 } else if (! lower && ! lsame_(uplo, "U")) {
00283 info = -3;
00284 } else if (! notrans && ! lsame_(trans, "T")) {
00285 info = -4;
00286 } else if (! lsame_(diag, "N") && ! lsame_(diag,
00287 "U")) {
00288 info = -5;
00289 } else if (*m < 0) {
00290 info = -6;
00291 } else if (*n < 0) {
00292 info = -7;
00293 } else if (*ldb < max(1,*m)) {
00294 info = -11;
00295 }
00296 if (info != 0) {
00297 i__1 = -info;
00298 xerbla_("STFSM ", &i__1);
00299 return 0;
00300 }
00301
00302
00303
00304 if (*m == 0 || *n == 0) {
00305 return 0;
00306 }
00307
00308
00309
00310 if (*alpha == 0.f) {
00311 i__1 = *n - 1;
00312 for (j = 0; j <= i__1; ++j) {
00313 i__2 = *m - 1;
00314 for (i__ = 0; i__ <= i__2; ++i__) {
00315 b[i__ + j * b_dim1] = 0.f;
00316
00317 }
00318
00319 }
00320 return 0;
00321 }
00322
00323 if (lside) {
00324
00325
00326
00327
00328
00329
00330
00331 if (*m % 2 == 0) {
00332 misodd = FALSE_;
00333 k = *m / 2;
00334 } else {
00335 misodd = TRUE_;
00336 if (lower) {
00337 m2 = *m / 2;
00338 m1 = *m - m2;
00339 } else {
00340 m1 = *m / 2;
00341 m2 = *m - m1;
00342 }
00343 }
00344
00345 if (misodd) {
00346
00347
00348
00349 if (normaltransr) {
00350
00351
00352
00353 if (lower) {
00354
00355
00356
00357 if (notrans) {
00358
00359
00360
00361
00362 if (*m == 1) {
00363 strsm_("L", "L", "N", diag, &m1, n, alpha, a, m, &
00364 b[b_offset], ldb);
00365 } else {
00366 strsm_("L", "L", "N", diag, &m1, n, alpha, a, m, &
00367 b[b_offset], ldb);
00368 sgemm_("N", "N", &m2, n, &m1, &c_b23, &a[m1], m, &
00369 b[b_offset], ldb, alpha, &b[m1], ldb);
00370 strsm_("L", "U", "T", diag, &m2, n, &c_b27, &a[*m]
00371 , m, &b[m1], ldb);
00372 }
00373
00374 } else {
00375
00376
00377
00378
00379 if (*m == 1) {
00380 strsm_("L", "L", "T", diag, &m1, n, alpha, a, m, &
00381 b[b_offset], ldb);
00382 } else {
00383 strsm_("L", "U", "N", diag, &m2, n, alpha, &a[*m],
00384 m, &b[m1], ldb);
00385 sgemm_("T", "N", &m1, n, &m2, &c_b23, &a[m1], m, &
00386 b[m1], ldb, alpha, &b[b_offset], ldb);
00387 strsm_("L", "L", "T", diag, &m1, n, &c_b27, a, m,
00388 &b[b_offset], ldb);
00389 }
00390
00391 }
00392
00393 } else {
00394
00395
00396
00397 if (! notrans) {
00398
00399
00400
00401
00402 strsm_("L", "L", "N", diag, &m1, n, alpha, &a[m2], m,
00403 &b[b_offset], ldb);
00404 sgemm_("T", "N", &m2, n, &m1, &c_b23, a, m, &b[
00405 b_offset], ldb, alpha, &b[m1], ldb);
00406 strsm_("L", "U", "T", diag, &m2, n, &c_b27, &a[m1], m,
00407 &b[m1], ldb);
00408
00409 } else {
00410
00411
00412
00413
00414 strsm_("L", "U", "N", diag, &m2, n, alpha, &a[m1], m,
00415 &b[m1], ldb);
00416 sgemm_("N", "N", &m1, n, &m2, &c_b23, a, m, &b[m1],
00417 ldb, alpha, &b[b_offset], ldb);
00418 strsm_("L", "L", "T", diag, &m1, n, &c_b27, &a[m2], m,
00419 &b[b_offset], ldb);
00420
00421 }
00422
00423 }
00424
00425 } else {
00426
00427
00428
00429 if (lower) {
00430
00431
00432
00433 if (notrans) {
00434
00435
00436
00437
00438 if (*m == 1) {
00439 strsm_("L", "U", "T", diag, &m1, n, alpha, a, &m1,
00440 &b[b_offset], ldb);
00441 } else {
00442 strsm_("L", "U", "T", diag, &m1, n, alpha, a, &m1,
00443 &b[b_offset], ldb);
00444 sgemm_("T", "N", &m2, n, &m1, &c_b23, &a[m1 * m1],
00445 &m1, &b[b_offset], ldb, alpha, &b[m1],
00446 ldb);
00447 strsm_("L", "L", "N", diag, &m2, n, &c_b27, &a[1],
00448 &m1, &b[m1], ldb);
00449 }
00450
00451 } else {
00452
00453
00454
00455
00456 if (*m == 1) {
00457 strsm_("L", "U", "N", diag, &m1, n, alpha, a, &m1,
00458 &b[b_offset], ldb);
00459 } else {
00460 strsm_("L", "L", "T", diag, &m2, n, alpha, &a[1],
00461 &m1, &b[m1], ldb);
00462 sgemm_("N", "N", &m1, n, &m2, &c_b23, &a[m1 * m1],
00463 &m1, &b[m1], ldb, alpha, &b[b_offset],
00464 ldb);
00465 strsm_("L", "U", "N", diag, &m1, n, &c_b27, a, &
00466 m1, &b[b_offset], ldb);
00467 }
00468
00469 }
00470
00471 } else {
00472
00473
00474
00475 if (! notrans) {
00476
00477
00478
00479
00480 strsm_("L", "U", "T", diag, &m1, n, alpha, &a[m2 * m2]
00481 , &m2, &b[b_offset], ldb);
00482 sgemm_("N", "N", &m2, n, &m1, &c_b23, a, &m2, &b[
00483 b_offset], ldb, alpha, &b[m1], ldb);
00484 strsm_("L", "L", "N", diag, &m2, n, &c_b27, &a[m1 *
00485 m2], &m2, &b[m1], ldb);
00486
00487 } else {
00488
00489
00490
00491
00492 strsm_("L", "L", "T", diag, &m2, n, alpha, &a[m1 * m2]
00493 , &m2, &b[m1], ldb);
00494 sgemm_("T", "N", &m1, n, &m2, &c_b23, a, &m2, &b[m1],
00495 ldb, alpha, &b[b_offset], ldb);
00496 strsm_("L", "U", "N", diag, &m1, n, &c_b27, &a[m2 *
00497 m2], &m2, &b[b_offset], ldb);
00498
00499 }
00500
00501 }
00502
00503 }
00504
00505 } else {
00506
00507
00508
00509 if (normaltransr) {
00510
00511
00512
00513 if (lower) {
00514
00515
00516
00517 if (notrans) {
00518
00519
00520
00521
00522 i__1 = *m + 1;
00523 strsm_("L", "L", "N", diag, &k, n, alpha, &a[1], &
00524 i__1, &b[b_offset], ldb);
00525 i__1 = *m + 1;
00526 sgemm_("N", "N", &k, n, &k, &c_b23, &a[k + 1], &i__1,
00527 &b[b_offset], ldb, alpha, &b[k], ldb);
00528 i__1 = *m + 1;
00529 strsm_("L", "U", "T", diag, &k, n, &c_b27, a, &i__1, &
00530 b[k], ldb);
00531
00532 } else {
00533
00534
00535
00536
00537 i__1 = *m + 1;
00538 strsm_("L", "U", "N", diag, &k, n, alpha, a, &i__1, &
00539 b[k], ldb);
00540 i__1 = *m + 1;
00541 sgemm_("T", "N", &k, n, &k, &c_b23, &a[k + 1], &i__1,
00542 &b[k], ldb, alpha, &b[b_offset], ldb);
00543 i__1 = *m + 1;
00544 strsm_("L", "L", "T", diag, &k, n, &c_b27, &a[1], &
00545 i__1, &b[b_offset], ldb);
00546
00547 }
00548
00549 } else {
00550
00551
00552
00553 if (! notrans) {
00554
00555
00556
00557
00558 i__1 = *m + 1;
00559 strsm_("L", "L", "N", diag, &k, n, alpha, &a[k + 1], &
00560 i__1, &b[b_offset], ldb);
00561 i__1 = *m + 1;
00562 sgemm_("T", "N", &k, n, &k, &c_b23, a, &i__1, &b[
00563 b_offset], ldb, alpha, &b[k], ldb);
00564 i__1 = *m + 1;
00565 strsm_("L", "U", "T", diag, &k, n, &c_b27, &a[k], &
00566 i__1, &b[k], ldb);
00567
00568 } else {
00569
00570
00571
00572 i__1 = *m + 1;
00573 strsm_("L", "U", "N", diag, &k, n, alpha, &a[k], &
00574 i__1, &b[k], ldb);
00575 i__1 = *m + 1;
00576 sgemm_("N", "N", &k, n, &k, &c_b23, a, &i__1, &b[k],
00577 ldb, alpha, &b[b_offset], ldb);
00578 i__1 = *m + 1;
00579 strsm_("L", "L", "T", diag, &k, n, &c_b27, &a[k + 1],
00580 &i__1, &b[b_offset], ldb);
00581
00582 }
00583
00584 }
00585
00586 } else {
00587
00588
00589
00590 if (lower) {
00591
00592
00593
00594 if (notrans) {
00595
00596
00597
00598
00599 strsm_("L", "U", "T", diag, &k, n, alpha, &a[k], &k, &
00600 b[b_offset], ldb);
00601 sgemm_("T", "N", &k, n, &k, &c_b23, &a[k * (k + 1)], &
00602 k, &b[b_offset], ldb, alpha, &b[k], ldb);
00603 strsm_("L", "L", "N", diag, &k, n, &c_b27, a, &k, &b[
00604 k], ldb);
00605
00606 } else {
00607
00608
00609
00610
00611 strsm_("L", "L", "T", diag, &k, n, alpha, a, &k, &b[k]
00612 , ldb);
00613 sgemm_("N", "N", &k, n, &k, &c_b23, &a[k * (k + 1)], &
00614 k, &b[k], ldb, alpha, &b[b_offset], ldb);
00615 strsm_("L", "U", "N", diag, &k, n, &c_b27, &a[k], &k,
00616 &b[b_offset], ldb);
00617
00618 }
00619
00620 } else {
00621
00622
00623
00624 if (! notrans) {
00625
00626
00627
00628
00629 strsm_("L", "U", "T", diag, &k, n, alpha, &a[k * (k +
00630 1)], &k, &b[b_offset], ldb);
00631 sgemm_("N", "N", &k, n, &k, &c_b23, a, &k, &b[
00632 b_offset], ldb, alpha, &b[k], ldb);
00633 strsm_("L", "L", "N", diag, &k, n, &c_b27, &a[k * k],
00634 &k, &b[k], ldb);
00635
00636 } else {
00637
00638
00639
00640
00641 strsm_("L", "L", "T", diag, &k, n, alpha, &a[k * k], &
00642 k, &b[k], ldb);
00643 sgemm_("T", "N", &k, n, &k, &c_b23, a, &k, &b[k], ldb,
00644 alpha, &b[b_offset], ldb);
00645 strsm_("L", "U", "N", diag, &k, n, &c_b27, &a[k * (k
00646 + 1)], &k, &b[b_offset], ldb);
00647
00648 }
00649
00650 }
00651
00652 }
00653
00654 }
00655
00656 } else {
00657
00658
00659
00660
00661
00662
00663
00664 if (*n % 2 == 0) {
00665 nisodd = FALSE_;
00666 k = *n / 2;
00667 } else {
00668 nisodd = TRUE_;
00669 if (lower) {
00670 n2 = *n / 2;
00671 n1 = *n - n2;
00672 } else {
00673 n1 = *n / 2;
00674 n2 = *n - n1;
00675 }
00676 }
00677
00678 if (nisodd) {
00679
00680
00681
00682 if (normaltransr) {
00683
00684
00685
00686 if (lower) {
00687
00688
00689
00690 if (notrans) {
00691
00692
00693
00694
00695 strsm_("R", "U", "T", diag, m, &n2, alpha, &a[*n], n,
00696 &b[n1 * b_dim1], ldb);
00697 sgemm_("N", "N", m, &n1, &n2, &c_b23, &b[n1 * b_dim1],
00698 ldb, &a[n1], n, alpha, b, ldb);
00699 strsm_("R", "L", "N", diag, m, &n1, &c_b27, a, n, b,
00700 ldb);
00701
00702 } else {
00703
00704
00705
00706
00707 strsm_("R", "L", "T", diag, m, &n1, alpha, a, n, b,
00708 ldb);
00709 sgemm_("N", "T", m, &n2, &n1, &c_b23, b, ldb, &a[n1],
00710 n, alpha, &b[n1 * b_dim1], ldb);
00711 strsm_("R", "U", "N", diag, m, &n2, &c_b27, &a[*n], n,
00712 &b[n1 * b_dim1], ldb);
00713
00714 }
00715
00716 } else {
00717
00718
00719
00720 if (notrans) {
00721
00722
00723
00724
00725 strsm_("R", "L", "T", diag, m, &n1, alpha, &a[n2], n,
00726 b, ldb);
00727 sgemm_("N", "N", m, &n2, &n1, &c_b23, b, ldb, a, n,
00728 alpha, &b[n1 * b_dim1], ldb);
00729 strsm_("R", "U", "N", diag, m, &n2, &c_b27, &a[n1], n,
00730 &b[n1 * b_dim1], ldb);
00731
00732 } else {
00733
00734
00735
00736
00737 strsm_("R", "U", "T", diag, m, &n2, alpha, &a[n1], n,
00738 &b[n1 * b_dim1], ldb);
00739 sgemm_("N", "T", m, &n1, &n2, &c_b23, &b[n1 * b_dim1],
00740 ldb, a, n, alpha, b, ldb);
00741 strsm_("R", "L", "N", diag, m, &n1, &c_b27, &a[n2], n,
00742 b, ldb);
00743
00744 }
00745
00746 }
00747
00748 } else {
00749
00750
00751
00752 if (lower) {
00753
00754
00755
00756 if (notrans) {
00757
00758
00759
00760
00761 strsm_("R", "L", "N", diag, m, &n2, alpha, &a[1], &n1,
00762 &b[n1 * b_dim1], ldb);
00763 sgemm_("N", "T", m, &n1, &n2, &c_b23, &b[n1 * b_dim1],
00764 ldb, &a[n1 * n1], &n1, alpha, b, ldb);
00765 strsm_("R", "U", "T", diag, m, &n1, &c_b27, a, &n1, b,
00766 ldb);
00767
00768 } else {
00769
00770
00771
00772
00773 strsm_("R", "U", "N", diag, m, &n1, alpha, a, &n1, b,
00774 ldb);
00775 sgemm_("N", "N", m, &n2, &n1, &c_b23, b, ldb, &a[n1 *
00776 n1], &n1, alpha, &b[n1 * b_dim1], ldb);
00777 strsm_("R", "L", "T", diag, m, &n2, &c_b27, &a[1], &
00778 n1, &b[n1 * b_dim1], ldb);
00779
00780 }
00781
00782 } else {
00783
00784
00785
00786 if (notrans) {
00787
00788
00789
00790
00791 strsm_("R", "U", "N", diag, m, &n1, alpha, &a[n2 * n2]
00792 , &n2, b, ldb);
00793 sgemm_("N", "T", m, &n2, &n1, &c_b23, b, ldb, a, &n2,
00794 alpha, &b[n1 * b_dim1], ldb);
00795 strsm_("R", "L", "T", diag, m, &n2, &c_b27, &a[n1 *
00796 n2], &n2, &b[n1 * b_dim1], ldb);
00797
00798 } else {
00799
00800
00801
00802
00803 strsm_("R", "L", "N", diag, m, &n2, alpha, &a[n1 * n2]
00804 , &n2, &b[n1 * b_dim1], ldb);
00805 sgemm_("N", "N", m, &n1, &n2, &c_b23, &b[n1 * b_dim1],
00806 ldb, a, &n2, alpha, b, ldb);
00807 strsm_("R", "U", "T", diag, m, &n1, &c_b27, &a[n2 *
00808 n2], &n2, b, ldb);
00809
00810 }
00811
00812 }
00813
00814 }
00815
00816 } else {
00817
00818
00819
00820 if (normaltransr) {
00821
00822
00823
00824 if (lower) {
00825
00826
00827
00828 if (notrans) {
00829
00830
00831
00832
00833 i__1 = *n + 1;
00834 strsm_("R", "U", "T", diag, m, &k, alpha, a, &i__1, &
00835 b[k * b_dim1], ldb);
00836 i__1 = *n + 1;
00837 sgemm_("N", "N", m, &k, &k, &c_b23, &b[k * b_dim1],
00838 ldb, &a[k + 1], &i__1, alpha, b, ldb);
00839 i__1 = *n + 1;
00840 strsm_("R", "L", "N", diag, m, &k, &c_b27, &a[1], &
00841 i__1, b, ldb);
00842
00843 } else {
00844
00845
00846
00847
00848 i__1 = *n + 1;
00849 strsm_("R", "L", "T", diag, m, &k, alpha, &a[1], &
00850 i__1, b, ldb);
00851 i__1 = *n + 1;
00852 sgemm_("N", "T", m, &k, &k, &c_b23, b, ldb, &a[k + 1],
00853 &i__1, alpha, &b[k * b_dim1], ldb);
00854 i__1 = *n + 1;
00855 strsm_("R", "U", "N", diag, m, &k, &c_b27, a, &i__1, &
00856 b[k * b_dim1], ldb);
00857
00858 }
00859
00860 } else {
00861
00862
00863
00864 if (notrans) {
00865
00866
00867
00868
00869 i__1 = *n + 1;
00870 strsm_("R", "L", "T", diag, m, &k, alpha, &a[k + 1], &
00871 i__1, b, ldb);
00872 i__1 = *n + 1;
00873 sgemm_("N", "N", m, &k, &k, &c_b23, b, ldb, a, &i__1,
00874 alpha, &b[k * b_dim1], ldb);
00875 i__1 = *n + 1;
00876 strsm_("R", "U", "N", diag, m, &k, &c_b27, &a[k], &
00877 i__1, &b[k * b_dim1], ldb);
00878
00879 } else {
00880
00881
00882
00883
00884 i__1 = *n + 1;
00885 strsm_("R", "U", "T", diag, m, &k, alpha, &a[k], &
00886 i__1, &b[k * b_dim1], ldb);
00887 i__1 = *n + 1;
00888 sgemm_("N", "T", m, &k, &k, &c_b23, &b[k * b_dim1],
00889 ldb, a, &i__1, alpha, b, ldb);
00890 i__1 = *n + 1;
00891 strsm_("R", "L", "N", diag, m, &k, &c_b27, &a[k + 1],
00892 &i__1, b, ldb);
00893
00894 }
00895
00896 }
00897
00898 } else {
00899
00900
00901
00902 if (lower) {
00903
00904
00905
00906 if (notrans) {
00907
00908
00909
00910
00911 strsm_("R", "L", "N", diag, m, &k, alpha, a, &k, &b[k
00912 * b_dim1], ldb);
00913 sgemm_("N", "T", m, &k, &k, &c_b23, &b[k * b_dim1],
00914 ldb, &a[(k + 1) * k], &k, alpha, b, ldb);
00915 strsm_("R", "U", "T", diag, m, &k, &c_b27, &a[k], &k,
00916 b, ldb);
00917
00918 } else {
00919
00920
00921
00922
00923 strsm_("R", "U", "N", diag, m, &k, alpha, &a[k], &k,
00924 b, ldb);
00925 sgemm_("N", "N", m, &k, &k, &c_b23, b, ldb, &a[(k + 1)
00926 * k], &k, alpha, &b[k * b_dim1], ldb);
00927 strsm_("R", "L", "T", diag, m, &k, &c_b27, a, &k, &b[
00928 k * b_dim1], ldb);
00929
00930 }
00931
00932 } else {
00933
00934
00935
00936 if (notrans) {
00937
00938
00939
00940
00941 strsm_("R", "U", "N", diag, m, &k, alpha, &a[(k + 1) *
00942 k], &k, b, ldb);
00943 sgemm_("N", "T", m, &k, &k, &c_b23, b, ldb, a, &k,
00944 alpha, &b[k * b_dim1], ldb);
00945 strsm_("R", "L", "T", diag, m, &k, &c_b27, &a[k * k],
00946 &k, &b[k * b_dim1], ldb);
00947
00948 } else {
00949
00950
00951
00952
00953 strsm_("R", "L", "N", diag, m, &k, alpha, &a[k * k], &
00954 k, &b[k * b_dim1], ldb);
00955 sgemm_("N", "N", m, &k, &k, &c_b23, &b[k * b_dim1],
00956 ldb, a, &k, alpha, b, ldb);
00957 strsm_("R", "U", "T", diag, m, &k, &c_b27, &a[(k + 1)
00958 * k], &k, b, ldb);
00959
00960 }
00961
00962 }
00963
00964 }
00965
00966 }
00967 }
00968
00969 return 0;
00970
00971
00972
00973 }