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