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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__0 = 0;
00021 static integer c__6 = 6;
00022 static doublereal c_b32 = 1.;
00023 static integer c__1 = 1;
00024 static doublereal c_b42 = 0.;
00025 static integer c__4 = 4;
00026
00027 int zchkhb_(integer *nsizes, integer *nn, integer *nwdths,
00028 integer *kk, integer *ntypes, logical *dotype, integer *iseed,
00029 doublereal *thresh, integer *nounit, doublecomplex *a, integer *lda,
00030 doublereal *sd, doublereal *se, doublecomplex *u, integer *ldu,
00031 doublecomplex *work, integer *lwork, doublereal *rwork, doublereal *
00032 result, integer *info)
00033 {
00034
00035
00036 static integer ktype[15] = { 1,2,4,4,4,4,4,5,5,5,5,5,8,8,8 };
00037 static integer kmagn[15] = { 1,1,1,1,1,2,3,1,1,1,2,3,1,2,3 };
00038 static integer kmode[15] = { 0,0,4,3,1,4,4,4,3,1,4,4,0,0,0 };
00039
00040
00041 static char fmt_9999[] = "(\002 ZCHKHB: \002,a,\002 returned INFO=\002,i"
00042 "6,\002.\002,/9x,\002N=\002,i6,\002, JTYPE=\002,i6,\002, ISEED="
00043 "(\002,3(i5,\002,\002),i5,\002)\002)";
00044 static char fmt_9998[] = "(/1x,a3,\002 -- Complex Hermitian Banded Tridi"
00045 "agonal Reduction Routines\002)";
00046 static char fmt_9997[] = "(\002 Matrix types (see DCHK23 for details):"
00047 " \002)";
00048 static char fmt_9996[] = "(/\002 Special Matrices:\002,/\002 1=Zero mat"
00049 "rix. \002,\002 5=Diagonal: clustered ent"
00050 "ries.\002,/\002 2=Identity matrix. \002,\002"
00051 " 6=Diagonal: large, evenly spaced.\002,/\002 3=Diagonal: evenl"
00052 "y spaced entries. \002,\002 7=Diagonal: small, evenly spaced."
00053 "\002,/\002 4=Diagonal: geometr. spaced entries.\002)";
00054 static char fmt_9995[] = "(\002 Dense \002,a,\002 Banded Matrices:\002,"
00055 "/\002 8=Evenly spaced eigenvals. \002,\002 12=Small,"
00056 " evenly spaced eigenvals.\002,/\002 9=Geometrically spaced eige"
00057 "nvals. \002,\002 13=Matrix with random O(1) entries.\002,"
00058 "/\002 10=Clustered eigenvalues. \002,\002 14=Matrix"
00059 " with large random entries.\002,/\002 11=Large, evenly spaced ei"
00060 "genvals. \002,\002 15=Matrix with small random entries.\002)";
00061 static char fmt_9994[] = "(/\002 Tests performed: (S is Tridiag, U "
00062 "is \002,a,\002,\002,/20x,a,\002 means \002,a,\002.\002,/\002 UPL"
00063 "O='U':\002,/\002 1= | A - U S U\002,a1,\002 | / ( |A| n ulp ) "
00064 " \002,\002 2= | I - U U\002,a1,\002 | / ( n ulp )\002,/\002 U"
00065 "PLO='L':\002,/\002 3= | A - U S U\002,a1,\002 | / ( |A| n ulp )"
00066 " \002,\002 4= | I - U U\002,a1,\002 | / ( n ulp )\002)";
00067 static char fmt_9993[] = "(\002 N=\002,i5,\002, K=\002,i4,\002, seed="
00068 "\002,4(i4,\002,\002),\002 type \002,i2,\002, test(\002,i2,\002)"
00069 "=\002,g10.3)";
00070
00071
00072 integer a_dim1, a_offset, u_dim1, u_offset, i__1, i__2, i__3, i__4, i__5,
00073 i__6, i__7;
00074 doublereal d__1;
00075 doublecomplex z__1;
00076
00077
00078 double sqrt(doublereal), z_abs(doublecomplex *);
00079 integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
00080 void d_cnjg(doublecomplex *, doublecomplex *);
00081
00082
00083 integer i__, j, k, n, jc, jr;
00084 doublereal ulp, cond;
00085 integer jcol, kmax, nmax;
00086 doublereal unfl, ovfl, temp1;
00087 logical badnn;
00088 integer imode, iinfo;
00089 extern int zhbt21_(char *, integer *, integer *, integer
00090 *, doublecomplex *, integer *, doublereal *, doublereal *,
00091 doublecomplex *, integer *, doublecomplex *, doublereal *,
00092 doublereal *);
00093 doublereal aninv, anorm;
00094 integer nmats, jsize, nerrs, itype, jtype, ntest;
00095 logical badnnb;
00096 extern doublereal dlamch_(char *);
00097 integer idumma[1];
00098 extern int xerbla_(char *, integer *);
00099 integer ioldsd[4];
00100 extern int dlasum_(char *, integer *, integer *, integer
00101 *);
00102 integer jwidth;
00103 extern int zhbtrd_(char *, char *, integer *, integer *,
00104 doublecomplex *, integer *, doublereal *, doublereal *,
00105 doublecomplex *, integer *, doublecomplex *, integer *), zlacpy_(char *, integer *, integer *, doublecomplex *,
00106 integer *, doublecomplex *, integer *), zlaset_(char *,
00107 integer *, integer *, doublecomplex *, doublecomplex *,
00108 doublecomplex *, integer *), zlatmr_(integer *, integer *,
00109 char *, integer *, char *, doublecomplex *, integer *,
00110 doublereal *, doublecomplex *, char *, char *, doublecomplex *,
00111 integer *, doublereal *, doublecomplex *, integer *, doublereal *,
00112 char *, integer *, integer *, integer *, doublereal *,
00113 doublereal *, char *, doublecomplex *, integer *, integer *,
00114 integer *);
00115 doublereal rtunfl, rtovfl, ulpinv;
00116 extern int zlatms_(integer *, integer *, char *, integer
00117 *, char *, doublereal *, integer *, doublereal *, doublereal *,
00118 integer *, integer *, char *, doublecomplex *, integer *,
00119 doublecomplex *, integer *);
00120 integer mtypes, ntestt;
00121
00122
00123 static cilist io___36 = { 0, 0, 0, fmt_9999, 0 };
00124 static cilist io___37 = { 0, 0, 0, fmt_9999, 0 };
00125 static cilist io___40 = { 0, 0, 0, fmt_9999, 0 };
00126 static cilist io___41 = { 0, 0, 0, fmt_9998, 0 };
00127 static cilist io___42 = { 0, 0, 0, fmt_9997, 0 };
00128 static cilist io___43 = { 0, 0, 0, fmt_9996, 0 };
00129 static cilist io___44 = { 0, 0, 0, fmt_9995, 0 };
00130 static cilist io___45 = { 0, 0, 0, fmt_9994, 0 };
00131 static cilist io___46 = { 0, 0, 0, fmt_9993, 0 };
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
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351 --nn;
00352 --kk;
00353 --dotype;
00354 --iseed;
00355 a_dim1 = *lda;
00356 a_offset = 1 + a_dim1;
00357 a -= a_offset;
00358 --sd;
00359 --se;
00360 u_dim1 = *ldu;
00361 u_offset = 1 + u_dim1;
00362 u -= u_offset;
00363 --work;
00364 --rwork;
00365 --result;
00366
00367
00368
00369
00370
00371
00372
00373 ntestt = 0;
00374 *info = 0;
00375
00376
00377
00378 badnn = FALSE_;
00379 nmax = 1;
00380 i__1 = *nsizes;
00381 for (j = 1; j <= i__1; ++j) {
00382
00383 i__2 = nmax, i__3 = nn[j];
00384 nmax = max(i__2,i__3);
00385 if (nn[j] < 0) {
00386 badnn = TRUE_;
00387 }
00388
00389 }
00390
00391 badnnb = FALSE_;
00392 kmax = 0;
00393 i__1 = *nsizes;
00394 for (j = 1; j <= i__1; ++j) {
00395
00396 i__2 = kmax, i__3 = kk[j];
00397 kmax = max(i__2,i__3);
00398 if (kk[j] < 0) {
00399 badnnb = TRUE_;
00400 }
00401
00402 }
00403
00404 i__1 = nmax - 1;
00405 kmax = min(i__1,kmax);
00406
00407
00408
00409 if (*nsizes < 0) {
00410 *info = -1;
00411 } else if (badnn) {
00412 *info = -2;
00413 } else if (*nwdths < 0) {
00414 *info = -3;
00415 } else if (badnnb) {
00416 *info = -4;
00417 } else if (*ntypes < 0) {
00418 *info = -5;
00419 } else if (*lda < kmax + 1) {
00420 *info = -11;
00421 } else if (*ldu < nmax) {
00422 *info = -15;
00423 } else if ((max(*lda,nmax) + 1) * nmax > *lwork) {
00424 *info = -17;
00425 }
00426
00427 if (*info != 0) {
00428 i__1 = -(*info);
00429 xerbla_("ZCHKHB", &i__1);
00430 return 0;
00431 }
00432
00433
00434
00435 if (*nsizes == 0 || *ntypes == 0 || *nwdths == 0) {
00436 return 0;
00437 }
00438
00439
00440
00441 unfl = dlamch_("Safe minimum");
00442 ovfl = 1. / unfl;
00443 ulp = dlamch_("Epsilon") * dlamch_("Base");
00444 ulpinv = 1. / ulp;
00445 rtunfl = sqrt(unfl);
00446 rtovfl = sqrt(ovfl);
00447
00448
00449
00450 nerrs = 0;
00451 nmats = 0;
00452
00453 i__1 = *nsizes;
00454 for (jsize = 1; jsize <= i__1; ++jsize) {
00455 n = nn[jsize];
00456 aninv = 1. / (doublereal) max(1,n);
00457
00458 i__2 = *nwdths;
00459 for (jwidth = 1; jwidth <= i__2; ++jwidth) {
00460 k = kk[jwidth];
00461 if (k > n) {
00462 goto L180;
00463 }
00464
00465
00466 i__5 = n - 1;
00467 i__3 = 0, i__4 = min(i__5,k);
00468 k = max(i__3,i__4);
00469
00470 if (*nsizes != 1) {
00471 mtypes = min(15,*ntypes);
00472 } else {
00473 mtypes = min(16,*ntypes);
00474 }
00475
00476 i__3 = mtypes;
00477 for (jtype = 1; jtype <= i__3; ++jtype) {
00478 if (! dotype[jtype]) {
00479 goto L170;
00480 }
00481 ++nmats;
00482 ntest = 0;
00483
00484 for (j = 1; j <= 4; ++j) {
00485 ioldsd[j - 1] = iseed[j];
00486
00487 }
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 if (mtypes > 15) {
00507 goto L100;
00508 }
00509
00510 itype = ktype[jtype - 1];
00511 imode = kmode[jtype - 1];
00512
00513
00514
00515 switch (kmagn[jtype - 1]) {
00516 case 1: goto L40;
00517 case 2: goto L50;
00518 case 3: goto L60;
00519 }
00520
00521 L40:
00522 anorm = 1.;
00523 goto L70;
00524
00525 L50:
00526 anorm = rtovfl * ulp * aninv;
00527 goto L70;
00528
00529 L60:
00530 anorm = rtunfl * n * ulpinv;
00531 goto L70;
00532
00533 L70:
00534
00535 zlaset_("Full", lda, &n, &c_b1, &c_b1, &a[a_offset], lda);
00536 iinfo = 0;
00537 if (jtype <= 15) {
00538 cond = ulpinv;
00539 } else {
00540 cond = ulpinv * aninv / 10.;
00541 }
00542
00543
00544
00545
00546
00547 if (itype == 1) {
00548 iinfo = 0;
00549
00550 } else if (itype == 2) {
00551
00552
00553
00554 i__4 = n;
00555 for (jcol = 1; jcol <= i__4; ++jcol) {
00556 i__5 = k + 1 + jcol * a_dim1;
00557 a[i__5].r = anorm, a[i__5].i = 0.;
00558
00559 }
00560
00561 } else if (itype == 4) {
00562
00563
00564
00565 zlatms_(&n, &n, "S", &iseed[1], "H", &rwork[1], &imode, &
00566 cond, &anorm, &c__0, &c__0, "Q", &a[k + 1 +
00567 a_dim1], lda, &work[1], &iinfo);
00568
00569 } else if (itype == 5) {
00570
00571
00572
00573 zlatms_(&n, &n, "S", &iseed[1], "H", &rwork[1], &imode, &
00574 cond, &anorm, &k, &k, "Q", &a[a_offset], lda, &
00575 work[1], &iinfo);
00576
00577 } else if (itype == 7) {
00578
00579
00580
00581 zlatmr_(&n, &n, "S", &iseed[1], "H", &work[1], &c__6, &
00582 c_b32, &c_b2, "T", "N", &work[n + 1], &c__1, &
00583 c_b32, &work[(n << 1) + 1], &c__1, &c_b32, "N",
00584 idumma, &c__0, &c__0, &c_b42, &anorm, "Q", &a[k +
00585 1 + a_dim1], lda, idumma, &iinfo);
00586
00587 } else if (itype == 8) {
00588
00589
00590
00591 zlatmr_(&n, &n, "S", &iseed[1], "H", &work[1], &c__6, &
00592 c_b32, &c_b2, "T", "N", &work[n + 1], &c__1, &
00593 c_b32, &work[(n << 1) + 1], &c__1, &c_b32, "N",
00594 idumma, &k, &k, &c_b42, &anorm, "Q", &a[a_offset],
00595 lda, idumma, &iinfo);
00596
00597 } else if (itype == 9) {
00598
00599
00600
00601 zlatms_(&n, &n, "S", &iseed[1], "P", &rwork[1], &imode, &
00602 cond, &anorm, &k, &k, "Q", &a[a_offset], lda, &
00603 work[n + 1], &iinfo);
00604
00605 } else if (itype == 10) {
00606
00607
00608
00609 if (n > 1) {
00610 k = max(1,k);
00611 }
00612 zlatms_(&n, &n, "S", &iseed[1], "P", &rwork[1], &imode, &
00613 cond, &anorm, &c__1, &c__1, "Q", &a[k + a_dim1],
00614 lda, &work[1], &iinfo);
00615 i__4 = n;
00616 for (i__ = 2; i__ <= i__4; ++i__) {
00617 i__5 = k + 1 + (i__ - 1) * a_dim1;
00618 i__6 = k + 1 + i__ * a_dim1;
00619 z__1.r = a[i__5].r * a[i__6].r - a[i__5].i * a[i__6]
00620 .i, z__1.i = a[i__5].r * a[i__6].i + a[i__5]
00621 .i * a[i__6].r;
00622 temp1 = z_abs(&a[k + i__ * a_dim1]) / sqrt(z_abs(&
00623 z__1));
00624 if (temp1 > .5) {
00625 i__5 = k + i__ * a_dim1;
00626 i__6 = k + 1 + (i__ - 1) * a_dim1;
00627 i__7 = k + 1 + i__ * a_dim1;
00628 z__1.r = a[i__6].r * a[i__7].r - a[i__6].i * a[
00629 i__7].i, z__1.i = a[i__6].r * a[i__7].i +
00630 a[i__6].i * a[i__7].r;
00631 d__1 = sqrt(z_abs(&z__1)) * .5;
00632 a[i__5].r = d__1, a[i__5].i = 0.;
00633 }
00634
00635 }
00636
00637 } else {
00638
00639 iinfo = 1;
00640 }
00641
00642 if (iinfo != 0) {
00643 io___36.ciunit = *nounit;
00644 s_wsfe(&io___36);
00645 do_fio(&c__1, "Generator", (ftnlen)9);
00646 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00647 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00648 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00649 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00650 ;
00651 e_wsfe();
00652 *info = abs(iinfo);
00653 return 0;
00654 }
00655
00656 L100:
00657
00658
00659
00660 i__4 = k + 1;
00661 zlacpy_(" ", &i__4, &n, &a[a_offset], lda, &work[1], lda);
00662
00663 ntest = 1;
00664 zhbtrd_("V", "U", &n, &k, &work[1], lda, &sd[1], &se[1], &u[
00665 u_offset], ldu, &work[*lda * n + 1], &iinfo);
00666
00667 if (iinfo != 0) {
00668 io___37.ciunit = *nounit;
00669 s_wsfe(&io___37);
00670 do_fio(&c__1, "ZHBTRD(U)", (ftnlen)9);
00671 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00672 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00673 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00674 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00675 ;
00676 e_wsfe();
00677 *info = abs(iinfo);
00678 if (iinfo < 0) {
00679 return 0;
00680 } else {
00681 result[1] = ulpinv;
00682 goto L150;
00683 }
00684 }
00685
00686
00687
00688 zhbt21_("Upper", &n, &k, &c__1, &a[a_offset], lda, &sd[1], &
00689 se[1], &u[u_offset], ldu, &work[1], &rwork[1], &
00690 result[1]);
00691
00692
00693
00694
00695 i__4 = n;
00696 for (jc = 1; jc <= i__4; ++jc) {
00697
00698 i__6 = k, i__7 = n - jc;
00699 i__5 = min(i__6,i__7);
00700 for (jr = 0; jr <= i__5; ++jr) {
00701 i__6 = jr + 1 + jc * a_dim1;
00702 d_cnjg(&z__1, &a[k + 1 - jr + (jc + jr) * a_dim1]);
00703 a[i__6].r = z__1.r, a[i__6].i = z__1.i;
00704
00705 }
00706
00707 }
00708 i__4 = n;
00709 for (jc = n + 1 - k; jc <= i__4; ++jc) {
00710
00711 i__5 = k, i__6 = n - jc;
00712 i__7 = k;
00713 for (jr = min(i__5,i__6) + 1; jr <= i__7; ++jr) {
00714 i__5 = jr + 1 + jc * a_dim1;
00715 a[i__5].r = 0., a[i__5].i = 0.;
00716
00717 }
00718
00719 }
00720
00721
00722
00723 i__4 = k + 1;
00724 zlacpy_(" ", &i__4, &n, &a[a_offset], lda, &work[1], lda);
00725
00726 ntest = 3;
00727 zhbtrd_("V", "L", &n, &k, &work[1], lda, &sd[1], &se[1], &u[
00728 u_offset], ldu, &work[*lda * n + 1], &iinfo);
00729
00730 if (iinfo != 0) {
00731 io___40.ciunit = *nounit;
00732 s_wsfe(&io___40);
00733 do_fio(&c__1, "ZHBTRD(L)", (ftnlen)9);
00734 do_fio(&c__1, (char *)&iinfo, (ftnlen)sizeof(integer));
00735 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00736 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer));
00737 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(integer))
00738 ;
00739 e_wsfe();
00740 *info = abs(iinfo);
00741 if (iinfo < 0) {
00742 return 0;
00743 } else {
00744 result[3] = ulpinv;
00745 goto L150;
00746 }
00747 }
00748 ntest = 4;
00749
00750
00751
00752 zhbt21_("Lower", &n, &k, &c__1, &a[a_offset], lda, &sd[1], &
00753 se[1], &u[u_offset], ldu, &work[1], &rwork[1], &
00754 result[3]);
00755
00756
00757
00758 L150:
00759 ntestt += ntest;
00760
00761
00762
00763 i__4 = ntest;
00764 for (jr = 1; jr <= i__4; ++jr) {
00765 if (result[jr] >= *thresh) {
00766
00767
00768
00769
00770 if (nerrs == 0) {
00771 io___41.ciunit = *nounit;
00772 s_wsfe(&io___41);
00773 do_fio(&c__1, "ZHB", (ftnlen)3);
00774 e_wsfe();
00775 io___42.ciunit = *nounit;
00776 s_wsfe(&io___42);
00777 e_wsfe();
00778 io___43.ciunit = *nounit;
00779 s_wsfe(&io___43);
00780 e_wsfe();
00781 io___44.ciunit = *nounit;
00782 s_wsfe(&io___44);
00783 do_fio(&c__1, "Hermitian", (ftnlen)9);
00784 e_wsfe();
00785 io___45.ciunit = *nounit;
00786 s_wsfe(&io___45);
00787 do_fio(&c__1, "unitary", (ftnlen)7);
00788 do_fio(&c__1, "*", (ftnlen)1);
00789 do_fio(&c__1, "conjugate transpose", (ftnlen)19);
00790 for (j = 1; j <= 4; ++j) {
00791 do_fio(&c__1, "*", (ftnlen)1);
00792 }
00793 e_wsfe();
00794 }
00795 ++nerrs;
00796 io___46.ciunit = *nounit;
00797 s_wsfe(&io___46);
00798 do_fio(&c__1, (char *)&n, (ftnlen)sizeof(integer));
00799 do_fio(&c__1, (char *)&k, (ftnlen)sizeof(integer));
00800 do_fio(&c__4, (char *)&ioldsd[0], (ftnlen)sizeof(
00801 integer));
00802 do_fio(&c__1, (char *)&jtype, (ftnlen)sizeof(integer))
00803 ;
00804 do_fio(&c__1, (char *)&jr, (ftnlen)sizeof(integer));
00805 do_fio(&c__1, (char *)&result[jr], (ftnlen)sizeof(
00806 doublereal));
00807 e_wsfe();
00808 }
00809
00810 }
00811
00812 L170:
00813 ;
00814 }
00815 L180:
00816 ;
00817 }
00818
00819 }
00820
00821
00822
00823 dlasum_("ZHB", nounit, &nerrs, &ntestt);
00824 return 0;
00825
00826
00827
00828
00829
00830
00831 }