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