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