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 complex c_b2 = {0.f,0.f};
00020 static integer c__2 = 2;
00021 static integer c__1 = 1;
00022
00023 int clarhs_(char *path, char *xtype, char *uplo, char *trans,
00024 integer *m, integer *n, integer *kl, integer *ku, integer *nrhs,
00025 complex *a, integer *lda, complex *x, integer *ldx, complex *b,
00026 integer *ldb, integer *iseed, integer *info)
00027 {
00028
00029 integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00030
00031
00032 int s_copy(char *, char *, ftnlen, ftnlen);
00033
00034
00035 integer j;
00036 char c1[1], c2[2];
00037 integer mb, nx;
00038 logical gen, tri, qrs, sym, band;
00039 char diag[1];
00040 logical tran;
00041 extern int cgemm_(char *, char *, integer *, integer *,
00042 integer *, complex *, complex *, integer *, complex *, integer *,
00043 complex *, complex *, integer *), chemm_(char *,
00044 char *, integer *, integer *, complex *, complex *, integer *,
00045 complex *, integer *, complex *, complex *, integer *), cgbmv_(char *, integer *, integer *, integer *, integer *
00046 , complex *, complex *, integer *, complex *, integer *, complex *
00047 , complex *, integer *), chbmv_(char *, integer *,
00048 integer *, complex *, complex *, integer *, complex *, integer *,
00049 complex *, complex *, integer *);
00050 extern logical lsame_(char *, char *);
00051 extern int csbmv_(char *, integer *, integer *, complex *
00052 , complex *, integer *, complex *, integer *, complex *, complex *
00053 , integer *), ctbmv_(char *, char *, char *, integer *,
00054 integer *, complex *, integer *, complex *, integer *), chpmv_(char *, integer *, complex *, complex *,
00055 complex *, integer *, complex *, complex *, integer *),
00056 ctrmm_(char *, char *, char *, char *, integer *, integer *,
00057 complex *, complex *, integer *, complex *, integer *), cspmv_(char *, integer *, complex *,
00058 complex *, complex *, integer *, complex *, complex *, integer *), csymm_(char *, char *, integer *, integer *, complex *,
00059 complex *, integer *, complex *, integer *, complex *, complex *,
00060 integer *), ctpmv_(char *, char *, char *,
00061 integer *, complex *, complex *, integer *), clacpy_(char *, integer *, integer *, complex *, integer
00062 *, complex *, integer *), xerbla_(char *, integer *);
00063 extern logical lsamen_(integer *, char *, char *);
00064 extern int clarnv_(integer *, integer *, integer *,
00065 complex *);
00066 logical notran;
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 a_dim1 = *lda;
00213 a_offset = 1 + a_dim1;
00214 a -= a_offset;
00215 x_dim1 = *ldx;
00216 x_offset = 1 + x_dim1;
00217 x -= x_offset;
00218 b_dim1 = *ldb;
00219 b_offset = 1 + b_dim1;
00220 b -= b_offset;
00221 --iseed;
00222
00223
00224 *info = 0;
00225 *(unsigned char *)c1 = *(unsigned char *)path;
00226 s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);
00227 tran = lsame_(trans, "T") || lsame_(trans, "C");
00228 notran = ! tran;
00229 gen = lsame_(path + 1, "G");
00230 qrs = lsame_(path + 1, "Q") || lsame_(path + 2,
00231 "Q");
00232 sym = lsame_(path + 1, "P") || lsame_(path + 1,
00233 "S") || lsame_(path + 1, "H");
00234 tri = lsame_(path + 1, "T");
00235 band = lsame_(path + 2, "B");
00236 if (! lsame_(c1, "Complex precision")) {
00237 *info = -1;
00238 } else if (! (lsame_(xtype, "N") || lsame_(xtype,
00239 "C"))) {
00240 *info = -2;
00241 } else if ((sym || tri) && ! (lsame_(uplo, "U") ||
00242 lsame_(uplo, "L"))) {
00243 *info = -3;
00244 } else if ((gen || qrs) && ! (tran || lsame_(trans, "N"))) {
00245 *info = -4;
00246 } else if (*m < 0) {
00247 *info = -5;
00248 } else if (*n < 0) {
00249 *info = -6;
00250 } else if (band && *kl < 0) {
00251 *info = -7;
00252 } else if (band && *ku < 0) {
00253 *info = -8;
00254 } else if (*nrhs < 0) {
00255 *info = -9;
00256 } else if (! band && *lda < max(1,*m) || band && (sym || tri) && *lda < *
00257 kl + 1 || band && gen && *lda < *kl + *ku + 1) {
00258 *info = -11;
00259 } else if (notran && *ldx < max(1,*n) || tran && *ldx < max(1,*m)) {
00260 *info = -13;
00261 } else if (notran && *ldb < max(1,*m) || tran && *ldb < max(1,*n)) {
00262 *info = -15;
00263 }
00264 if (*info != 0) {
00265 i__1 = -(*info);
00266 xerbla_("CLARHS", &i__1);
00267 return 0;
00268 }
00269
00270
00271
00272 if (tran) {
00273 nx = *m;
00274 mb = *n;
00275 } else {
00276 nx = *n;
00277 mb = *m;
00278 }
00279 if (! lsame_(xtype, "C")) {
00280 i__1 = *nrhs;
00281 for (j = 1; j <= i__1; ++j) {
00282 clarnv_(&c__2, &iseed[1], n, &x[j * x_dim1 + 1]);
00283
00284 }
00285 }
00286
00287
00288
00289
00290 if (lsamen_(&c__2, c2, "GE") || lsamen_(&c__2, c2,
00291 "QR") || lsamen_(&c__2, c2, "LQ") || lsamen_(&c__2, c2, "QL") ||
00292 lsamen_(&c__2, c2, "RQ")) {
00293
00294
00295
00296 cgemm_(trans, "N", &mb, nrhs, &nx, &c_b1, &a[a_offset], lda, &x[
00297 x_offset], ldx, &c_b2, &b[b_offset], ldb);
00298
00299 } else if (lsamen_(&c__2, c2, "PO") || lsamen_(&
00300 c__2, c2, "HE")) {
00301
00302
00303
00304 chemm_("Left", uplo, n, nrhs, &c_b1, &a[a_offset], lda, &x[x_offset],
00305 ldx, &c_b2, &b[b_offset], ldb);
00306
00307 } else if (lsamen_(&c__2, c2, "SY")) {
00308
00309
00310
00311 csymm_("Left", uplo, n, nrhs, &c_b1, &a[a_offset], lda, &x[x_offset],
00312 ldx, &c_b2, &b[b_offset], ldb);
00313
00314 } else if (lsamen_(&c__2, c2, "GB")) {
00315
00316
00317
00318 i__1 = *nrhs;
00319 for (j = 1; j <= i__1; ++j) {
00320 cgbmv_(trans, m, n, kl, ku, &c_b1, &a[a_offset], lda, &x[j *
00321 x_dim1 + 1], &c__1, &c_b2, &b[j * b_dim1 + 1], &c__1);
00322
00323 }
00324
00325 } else if (lsamen_(&c__2, c2, "PB") || lsamen_(&
00326 c__2, c2, "HB")) {
00327
00328
00329
00330 i__1 = *nrhs;
00331 for (j = 1; j <= i__1; ++j) {
00332 chbmv_(uplo, n, kl, &c_b1, &a[a_offset], lda, &x[j * x_dim1 + 1],
00333 &c__1, &c_b2, &b[j * b_dim1 + 1], &c__1);
00334
00335 }
00336
00337 } else if (lsamen_(&c__2, c2, "SB")) {
00338
00339
00340
00341 i__1 = *nrhs;
00342 for (j = 1; j <= i__1; ++j) {
00343 csbmv_(uplo, n, kl, &c_b1, &a[a_offset], lda, &x[j * x_dim1 + 1],
00344 &c__1, &c_b2, &b[j * b_dim1 + 1], &c__1);
00345
00346 }
00347
00348 } else if (lsamen_(&c__2, c2, "PP") || lsamen_(&
00349 c__2, c2, "HP")) {
00350
00351
00352
00353 i__1 = *nrhs;
00354 for (j = 1; j <= i__1; ++j) {
00355 chpmv_(uplo, n, &c_b1, &a[a_offset], &x[j * x_dim1 + 1], &c__1, &
00356 c_b2, &b[j * b_dim1 + 1], &c__1);
00357
00358 }
00359
00360 } else if (lsamen_(&c__2, c2, "SP")) {
00361
00362
00363
00364 i__1 = *nrhs;
00365 for (j = 1; j <= i__1; ++j) {
00366 cspmv_(uplo, n, &c_b1, &a[a_offset], &x[j * x_dim1 + 1], &c__1, &
00367 c_b2, &b[j * b_dim1 + 1], &c__1);
00368
00369 }
00370
00371 } else if (lsamen_(&c__2, c2, "TR")) {
00372
00373
00374
00375
00376
00377 clacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00378 if (*ku == 2) {
00379 *(unsigned char *)diag = 'U';
00380 } else {
00381 *(unsigned char *)diag = 'N';
00382 }
00383 ctrmm_("Left", uplo, trans, diag, n, nrhs, &c_b1, &a[a_offset], lda, &
00384 b[b_offset], ldb);
00385
00386 } else if (lsamen_(&c__2, c2, "TP")) {
00387
00388
00389
00390 clacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00391 if (*ku == 2) {
00392 *(unsigned char *)diag = 'U';
00393 } else {
00394 *(unsigned char *)diag = 'N';
00395 }
00396 i__1 = *nrhs;
00397 for (j = 1; j <= i__1; ++j) {
00398 ctpmv_(uplo, trans, diag, n, &a[a_offset], &b[j * b_dim1 + 1], &
00399 c__1);
00400
00401 }
00402
00403 } else if (lsamen_(&c__2, c2, "TB")) {
00404
00405
00406
00407 clacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00408 if (*ku == 2) {
00409 *(unsigned char *)diag = 'U';
00410 } else {
00411 *(unsigned char *)diag = 'N';
00412 }
00413 i__1 = *nrhs;
00414 for (j = 1; j <= i__1; ++j) {
00415 ctbmv_(uplo, trans, diag, n, kl, &a[a_offset], lda, &b[j * b_dim1
00416 + 1], &c__1);
00417
00418 }
00419
00420 } else {
00421
00422
00423
00424 *info = -1;
00425 i__1 = -(*info);
00426 xerbla_("CLARHS", &i__1);
00427 }
00428
00429 return 0;
00430
00431
00432
00433 }