00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015
00016
00017
00018 struct {
00019 integer infot, nunit;
00020 logical ok, lerr;
00021 } infoc_;
00022
00023 #define infoc_1 infoc_
00024
00025 struct {
00026 char srnamt[32];
00027 } srnamc_;
00028
00029 #define srnamc_1 srnamc_
00030
00031
00032
00033 static integer c__1 = 1;
00034 static integer c__2 = 2;
00035 static integer c__0 = 0;
00036 static integer c_n1 = -1;
00037 static complex c_b50 = {0.f,0.f};
00038
00039 int cdrvhe_(logical *dotype, integer *nn, integer *nval,
00040 integer *nrhs, real *thresh, logical *tsterr, integer *nmax, complex *
00041 a, complex *afac, complex *ainv, complex *b, complex *x, complex *
00042 xact, complex *work, real *rwork, integer *iwork, integer *nout)
00043 {
00044
00045
00046 static integer iseedy[4] = { 1988,1989,1990,1991 };
00047 static char uplos[1*2] = "U" "L";
00048 static char facts[1*2] = "F" "N";
00049
00050
00051 static char fmt_9999[] = "(1x,a,\002, UPLO='\002,a1,\002', N =\002,i5"
00052 ",\002, type \002,i2,\002, test \002,i2,\002, ratio =\002,g12.5)";
00053 static char fmt_9998[] = "(1x,a,\002, FACT='\002,a1,\002', UPLO='\002,"
00054 "a1,\002', N =\002,i5,\002, type \002,i2,\002, test \002,i2,\002,"
00055 " ratio =\002,g12.5)";
00056
00057
00058 address a__1[2];
00059 integer i__1, i__2, i__3, i__4, i__5, i__6[2];
00060 char ch__1[2];
00061
00062
00063 int s_copy(char *, char *, ftnlen, ftnlen);
00064 integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00065 int s_cat(char *, char **, integer *, integer *, ftnlen);
00066
00067
00068 integer i__, j, k, n, i1, i2, k1, nb, in, kl, ku, nt, lda;
00069 char fact[1];
00070 integer ioff, mode, imat, info;
00071 char path[3], dist[1], uplo[1], type__[1];
00072 integer nrun;
00073 extern int chet01_(char *, integer *, complex *, integer
00074 *, complex *, integer *, integer *, complex *, integer *, real *,
00075 real *);
00076 integer ifact;
00077 extern int cget04_(integer *, integer *, complex *,
00078 integer *, complex *, integer *, real *, real *);
00079 integer nfail, iseed[4], nbmin;
00080 real rcond;
00081 extern int cpot02_(char *, integer *, integer *, complex
00082 *, integer *, complex *, integer *, complex *, integer *, real *,
00083 real *);
00084 integer nimat;
00085 extern doublereal sget06_(real *, real *);
00086 extern int chesv_(char *, integer *, integer *, complex *
00087 , integer *, integer *, complex *, integer *, complex *, integer *
00088 , integer *), cpot05_(char *, integer *, integer *,
00089 complex *, integer *, complex *, integer *, complex *, integer *,
00090 complex *, integer *, real *, real *, real *);
00091 real anorm;
00092 integer iuplo, izero, nerrs, lwork;
00093 logical zerot;
00094 char xtype[1];
00095 extern int clatb4_(char *, integer *, integer *, integer
00096 *, char *, integer *, integer *, real *, integer *, real *, char *
00097 ), aladhd_(integer *, char *);
00098 extern doublereal clanhe_(char *, char *, integer *, complex *, integer *,
00099 real *);
00100 extern int alaerh_(char *, char *, integer *, integer *,
00101 char *, integer *, integer *, integer *, integer *, integer *,
00102 integer *, integer *, integer *, integer *), claipd_(integer *, complex *, integer *, integer *);
00103 real rcondc;
00104 extern int chetrf_(char *, integer *, complex *, integer
00105 *, integer *, complex *, integer *, integer *), clacpy_(
00106 char *, integer *, integer *, complex *, integer *, complex *,
00107 integer *), chetri_(char *, integer *, complex *, integer
00108 *, integer *, complex *, integer *), clarhs_(char *, char
00109 *, char *, char *, integer *, integer *, integer *, integer *,
00110 integer *, complex *, integer *, complex *, integer *, complex *,
00111 integer *, integer *, integer *),
00112 claset_(char *, integer *, integer *, complex *, complex *,
00113 complex *, integer *), alasvm_(char *, integer *, integer
00114 *, integer *, integer *);
00115 real cndnum;
00116 extern int clatms_(integer *, integer *, char *, integer
00117 *, char *, real *, integer *, real *, real *, integer *, integer *
00118 , char *, complex *, integer *, complex *, integer *);
00119 real ainvnm;
00120 extern int xlaenv_(integer *, integer *), chesvx_(char *,
00121 char *, integer *, integer *, complex *, integer *, complex *,
00122 integer *, integer *, complex *, integer *, complex *, integer *,
00123 real *, real *, real *, complex *, integer *, real *, integer *), cerrvx_(char *, integer *);
00124 real result[6];
00125
00126
00127 static cilist io___42 = { 0, 0, 0, fmt_9999, 0 };
00128 static cilist io___45 = { 0, 0, 0, fmt_9998, 0 };
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 --iwork;
00219 --rwork;
00220 --work;
00221 --xact;
00222 --x;
00223 --b;
00224 --ainv;
00225 --afac;
00226 --a;
00227 --nval;
00228 --dotype;
00229
00230
00231
00232
00233
00234
00235
00236 *(unsigned char *)path = 'C';
00237 s_copy(path + 1, "HE", (ftnlen)2, (ftnlen)2);
00238 nrun = 0;
00239 nfail = 0;
00240 nerrs = 0;
00241 for (i__ = 1; i__ <= 4; ++i__) {
00242 iseed[i__ - 1] = iseedy[i__ - 1];
00243
00244 }
00245
00246 i__1 = *nmax << 1, i__2 = *nmax * *nrhs;
00247 lwork = max(i__1,i__2);
00248
00249
00250
00251 if (*tsterr) {
00252 cerrvx_(path, nout);
00253 }
00254 infoc_1.infot = 0;
00255
00256
00257
00258 nb = 1;
00259 nbmin = 2;
00260 xlaenv_(&c__1, &nb);
00261 xlaenv_(&c__2, &nbmin);
00262
00263
00264
00265 i__1 = *nn;
00266 for (in = 1; in <= i__1; ++in) {
00267 n = nval[in];
00268 lda = max(n,1);
00269 *(unsigned char *)xtype = 'N';
00270 nimat = 10;
00271 if (n <= 0) {
00272 nimat = 1;
00273 }
00274
00275 i__2 = nimat;
00276 for (imat = 1; imat <= i__2; ++imat) {
00277
00278
00279
00280 if (! dotype[imat]) {
00281 goto L170;
00282 }
00283
00284
00285
00286 zerot = imat >= 3 && imat <= 6;
00287 if (zerot && n < imat - 2) {
00288 goto L170;
00289 }
00290
00291
00292
00293 for (iuplo = 1; iuplo <= 2; ++iuplo) {
00294 *(unsigned char *)uplo = *(unsigned char *)&uplos[iuplo - 1];
00295
00296
00297
00298
00299 clatb4_(path, &imat, &n, &n, type__, &kl, &ku, &anorm, &mode,
00300 &cndnum, dist);
00301
00302 s_copy(srnamc_1.srnamt, "CLATMS", (ftnlen)32, (ftnlen)6);
00303 clatms_(&n, &n, dist, iseed, type__, &rwork[1], &mode, &
00304 cndnum, &anorm, &kl, &ku, uplo, &a[1], &lda, &work[1],
00305 &info);
00306
00307
00308
00309 if (info != 0) {
00310 alaerh_(path, "CLATMS", &info, &c__0, uplo, &n, &n, &c_n1,
00311 &c_n1, &c_n1, &imat, &nfail, &nerrs, nout);
00312 goto L160;
00313 }
00314
00315
00316
00317
00318 if (zerot) {
00319 if (imat == 3) {
00320 izero = 1;
00321 } else if (imat == 4) {
00322 izero = n;
00323 } else {
00324 izero = n / 2 + 1;
00325 }
00326
00327 if (imat < 6) {
00328
00329
00330
00331 if (iuplo == 1) {
00332 ioff = (izero - 1) * lda;
00333 i__3 = izero - 1;
00334 for (i__ = 1; i__ <= i__3; ++i__) {
00335 i__4 = ioff + i__;
00336 a[i__4].r = 0.f, a[i__4].i = 0.f;
00337
00338 }
00339 ioff += izero;
00340 i__3 = n;
00341 for (i__ = izero; i__ <= i__3; ++i__) {
00342 i__4 = ioff;
00343 a[i__4].r = 0.f, a[i__4].i = 0.f;
00344 ioff += lda;
00345
00346 }
00347 } else {
00348 ioff = izero;
00349 i__3 = izero - 1;
00350 for (i__ = 1; i__ <= i__3; ++i__) {
00351 i__4 = ioff;
00352 a[i__4].r = 0.f, a[i__4].i = 0.f;
00353 ioff += lda;
00354
00355 }
00356 ioff -= izero;
00357 i__3 = n;
00358 for (i__ = izero; i__ <= i__3; ++i__) {
00359 i__4 = ioff + i__;
00360 a[i__4].r = 0.f, a[i__4].i = 0.f;
00361
00362 }
00363 }
00364 } else {
00365 ioff = 0;
00366 if (iuplo == 1) {
00367
00368
00369
00370 i__3 = n;
00371 for (j = 1; j <= i__3; ++j) {
00372 i2 = min(j,izero);
00373 i__4 = i2;
00374 for (i__ = 1; i__ <= i__4; ++i__) {
00375 i__5 = ioff + i__;
00376 a[i__5].r = 0.f, a[i__5].i = 0.f;
00377
00378 }
00379 ioff += lda;
00380
00381 }
00382 } else {
00383
00384
00385
00386 i__3 = n;
00387 for (j = 1; j <= i__3; ++j) {
00388 i1 = max(j,izero);
00389 i__4 = n;
00390 for (i__ = i1; i__ <= i__4; ++i__) {
00391 i__5 = ioff + i__;
00392 a[i__5].r = 0.f, a[i__5].i = 0.f;
00393
00394 }
00395 ioff += lda;
00396
00397 }
00398 }
00399 }
00400 } else {
00401 izero = 0;
00402 }
00403
00404
00405
00406 i__3 = lda + 1;
00407 claipd_(&n, &a[1], &i__3, &c__0);
00408
00409 for (ifact = 1; ifact <= 2; ++ifact) {
00410
00411
00412
00413 *(unsigned char *)fact = *(unsigned char *)&facts[ifact -
00414 1];
00415
00416
00417
00418
00419 if (zerot) {
00420 if (ifact == 1) {
00421 goto L150;
00422 }
00423 rcondc = 0.f;
00424
00425 } else if (ifact == 1) {
00426
00427
00428
00429 anorm = clanhe_("1", uplo, &n, &a[1], &lda, &rwork[1]);
00430
00431
00432
00433 clacpy_(uplo, &n, &n, &a[1], &lda, &afac[1], &lda);
00434 chetrf_(uplo, &n, &afac[1], &lda, &iwork[1], &work[1],
00435 &lwork, &info);
00436
00437
00438
00439 clacpy_(uplo, &n, &n, &afac[1], &lda, &ainv[1], &lda);
00440 chetri_(uplo, &n, &ainv[1], &lda, &iwork[1], &work[1],
00441 &info);
00442 ainvnm = clanhe_("1", uplo, &n, &ainv[1], &lda, &
00443 rwork[1]);
00444
00445
00446
00447 if (anorm <= 0.f || ainvnm <= 0.f) {
00448 rcondc = 1.f;
00449 } else {
00450 rcondc = 1.f / anorm / ainvnm;
00451 }
00452 }
00453
00454
00455
00456 s_copy(srnamc_1.srnamt, "CLARHS", (ftnlen)32, (ftnlen)6);
00457 clarhs_(path, xtype, uplo, " ", &n, &n, &kl, &ku, nrhs, &
00458 a[1], &lda, &xact[1], &lda, &b[1], &lda, iseed, &
00459 info);
00460 *(unsigned char *)xtype = 'C';
00461
00462
00463
00464 if (ifact == 2) {
00465 clacpy_(uplo, &n, &n, &a[1], &lda, &afac[1], &lda);
00466 clacpy_("Full", &n, nrhs, &b[1], &lda, &x[1], &lda);
00467
00468
00469
00470 s_copy(srnamc_1.srnamt, "CHESV ", (ftnlen)32, (ftnlen)
00471 6);
00472 chesv_(uplo, &n, nrhs, &afac[1], &lda, &iwork[1], &x[
00473 1], &lda, &work[1], &lwork, &info);
00474
00475
00476
00477
00478 k = izero;
00479 if (k > 0) {
00480 L100:
00481 if (iwork[k] < 0) {
00482 if (iwork[k] != -k) {
00483 k = -iwork[k];
00484 goto L100;
00485 }
00486 } else if (iwork[k] != k) {
00487 k = iwork[k];
00488 goto L100;
00489 }
00490 }
00491
00492
00493
00494 if (info != k) {
00495 alaerh_(path, "CHESV ", &info, &k, uplo, &n, &n, &
00496 c_n1, &c_n1, nrhs, &imat, &nfail, &nerrs,
00497 nout);
00498 goto L120;
00499 } else if (info != 0) {
00500 goto L120;
00501 }
00502
00503
00504
00505
00506 chet01_(uplo, &n, &a[1], &lda, &afac[1], &lda, &iwork[
00507 1], &ainv[1], &lda, &rwork[1], result);
00508
00509
00510
00511 clacpy_("Full", &n, nrhs, &b[1], &lda, &work[1], &lda);
00512 cpot02_(uplo, &n, nrhs, &a[1], &lda, &x[1], &lda, &
00513 work[1], &lda, &rwork[1], &result[1]);
00514
00515
00516
00517 cget04_(&n, nrhs, &x[1], &lda, &xact[1], &lda, &
00518 rcondc, &result[2]);
00519 nt = 3;
00520
00521
00522
00523
00524 i__3 = nt;
00525 for (k = 1; k <= i__3; ++k) {
00526 if (result[k - 1] >= *thresh) {
00527 if (nfail == 0 && nerrs == 0) {
00528 aladhd_(nout, path);
00529 }
00530 io___42.ciunit = *nout;
00531 s_wsfe(&io___42);
00532 do_fio(&c__1, "CHESV ", (ftnlen)6);
00533 do_fio(&c__1, uplo, (ftnlen)1);
00534 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(
00535 integer));
00536 do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(
00537 integer));
00538 do_fio(&c__1, (char *)&k, (ftnlen)sizeof(
00539 integer));
00540 do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00541 sizeof(real));
00542 e_wsfe();
00543 ++nfail;
00544 }
00545
00546 }
00547 nrun += nt;
00548 L120:
00549 ;
00550 }
00551
00552
00553
00554 if (ifact == 2) {
00555 claset_(uplo, &n, &n, &c_b50, &c_b50, &afac[1], &lda);
00556 }
00557 claset_("Full", &n, nrhs, &c_b50, &c_b50, &x[1], &lda);
00558
00559
00560
00561
00562 s_copy(srnamc_1.srnamt, "CHESVX", (ftnlen)32, (ftnlen)6);
00563 chesvx_(fact, uplo, &n, nrhs, &a[1], &lda, &afac[1], &lda,
00564 &iwork[1], &b[1], &lda, &x[1], &lda, &rcond, &
00565 rwork[1], &rwork[*nrhs + 1], &work[1], &lwork, &
00566 rwork[(*nrhs << 1) + 1], &info);
00567
00568
00569
00570
00571 k = izero;
00572 if (k > 0) {
00573 L130:
00574 if (iwork[k] < 0) {
00575 if (iwork[k] != -k) {
00576 k = -iwork[k];
00577 goto L130;
00578 }
00579 } else if (iwork[k] != k) {
00580 k = iwork[k];
00581 goto L130;
00582 }
00583 }
00584
00585
00586
00587 if (info != k) {
00588
00589 i__6[0] = 1, a__1[0] = fact;
00590 i__6[1] = 1, a__1[1] = uplo;
00591 s_cat(ch__1, a__1, i__6, &c__2, (ftnlen)2);
00592 alaerh_(path, "CHESVX", &info, &k, ch__1, &n, &n, &
00593 c_n1, &c_n1, nrhs, &imat, &nfail, &nerrs,
00594 nout);
00595 goto L150;
00596 }
00597
00598 if (info == 0) {
00599 if (ifact >= 2) {
00600
00601
00602
00603
00604 chet01_(uplo, &n, &a[1], &lda, &afac[1], &lda, &
00605 iwork[1], &ainv[1], &lda, &rwork[(*nrhs <<
00606 1) + 1], result);
00607 k1 = 1;
00608 } else {
00609 k1 = 2;
00610 }
00611
00612
00613
00614 clacpy_("Full", &n, nrhs, &b[1], &lda, &work[1], &lda);
00615 cpot02_(uplo, &n, nrhs, &a[1], &lda, &x[1], &lda, &
00616 work[1], &lda, &rwork[(*nrhs << 1) + 1], &
00617 result[1]);
00618
00619
00620
00621 cget04_(&n, nrhs, &x[1], &lda, &xact[1], &lda, &
00622 rcondc, &result[2]);
00623
00624
00625
00626 cpot05_(uplo, &n, nrhs, &a[1], &lda, &b[1], &lda, &x[
00627 1], &lda, &xact[1], &lda, &rwork[1], &rwork[*
00628 nrhs + 1], &result[3]);
00629 } else {
00630 k1 = 6;
00631 }
00632
00633
00634
00635
00636 result[5] = sget06_(&rcond, &rcondc);
00637
00638
00639
00640
00641 for (k = k1; k <= 6; ++k) {
00642 if (result[k - 1] >= *thresh) {
00643 if (nfail == 0 && nerrs == 0) {
00644 aladhd_(nout, path);
00645 }
00646 io___45.ciunit = *nout;
00647 s_wsfe(&io___45);
00648 do_fio(&c__1, "CHESVX", (ftnlen)6);
00649 do_fio(&c__1, fact, (ftnlen)1);
00650 do_fio(&c__1, uplo, (ftnlen)1);
00651 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer))
00652 ;
00653 do_fio(&c__1, (char *)&imat, (ftnlen)sizeof(
00654 integer));
00655 do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer))
00656 ;
00657 do_fio(&c__1, (char *)&result[k - 1], (ftnlen)
00658 sizeof(real));
00659 e_wsfe();
00660 ++nfail;
00661 }
00662
00663 }
00664 nrun = nrun + 7 - k1;
00665
00666 L150:
00667 ;
00668 }
00669
00670 L160:
00671 ;
00672 }
00673 L170:
00674 ;
00675 }
00676
00677 }
00678
00679
00680
00681 alasvm_(path, nout, &nfail, &nrun, &nerrs);
00682
00683 return 0;
00684
00685
00686
00687 }