sstt21.c
Go to the documentation of this file.
00001 /* sstt21.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static real c_b5 = 0.f;
00019 static integer c__1 = 1;
00020 static real c_b19 = 1.f;
00021 
00022 /* Subroutine */ int sstt21_(integer *n, integer *kband, real *ad, real *ae, 
00023         real *sd, real *se, real *u, integer *ldu, real *work, real *result)
00024 {
00025     /* System generated locals */
00026     integer u_dim1, u_offset, i__1;
00027     real r__1, r__2, r__3;
00028 
00029     /* Local variables */
00030     integer j;
00031     real ulp, unfl;
00032     extern /* Subroutine */ int ssyr_(char *, integer *, real *, real *, 
00033             integer *, real *, integer *);
00034     real temp1, temp2;
00035     extern /* Subroutine */ int ssyr2_(char *, integer *, real *, real *, 
00036             integer *, real *, integer *, real *, integer *), sgemm_(
00037             char *, char *, integer *, integer *, integer *, real *, real *, 
00038             integer *, real *, integer *, real *, real *, integer *);
00039     real anorm, wnorm;
00040     extern doublereal slamch_(char *), slange_(char *, integer *, 
00041             integer *, real *, integer *, real *);
00042     extern /* Subroutine */ int slaset_(char *, integer *, integer *, real *, 
00043             real *, real *, integer *);
00044     extern doublereal slansy_(char *, char *, integer *, real *, integer *, 
00045             real *);
00046 
00047 
00048 /*  -- LAPACK test routine (version 3.1) -- */
00049 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00050 /*     November 2006 */
00051 
00052 /*     .. Scalar Arguments .. */
00053 /*     .. */
00054 /*     .. Array Arguments .. */
00055 /*     .. */
00056 
00057 /*  Purpose */
00058 /*  ======= */
00059 
00060 /*  SSTT21 checks a decomposition of the form */
00061 
00062 /*     A = U S U' */
00063 
00064 /*  where ' means transpose, A is symmetric tridiagonal, U is orthogonal, */
00065 /*  and S is diagonal (if KBAND=0) or symmetric tridiagonal (if KBAND=1). */
00066 /*  Two tests are performed: */
00067 
00068 /*     RESULT(1) = | A - U S U' | / ( |A| n ulp ) */
00069 
00070 /*     RESULT(2) = | I - UU' | / ( n ulp ) */
00071 
00072 /*  Arguments */
00073 /*  ========= */
00074 
00075 /*  N       (input) INTEGER */
00076 /*          The size of the matrix.  If it is zero, SSTT21 does nothing. */
00077 /*          It must be at least zero. */
00078 
00079 /*  KBAND   (input) INTEGER */
00080 /*          The bandwidth of the matrix S.  It may only be zero or one. */
00081 /*          If zero, then S is diagonal, and SE is not referenced.  If */
00082 /*          one, then S is symmetric tri-diagonal. */
00083 
00084 /*  AD      (input) REAL array, dimension (N) */
00085 /*          The diagonal of the original (unfactored) matrix A.  A is */
00086 /*          assumed to be symmetric tridiagonal. */
00087 
00088 /*  AE      (input) REAL array, dimension (N-1) */
00089 /*          The off-diagonal of the original (unfactored) matrix A.  A */
00090 /*          is assumed to be symmetric tridiagonal.  AE(1) is the (1,2) */
00091 /*          and (2,1) element, AE(2) is the (2,3) and (3,2) element, etc. */
00092 
00093 /*  SD      (input) REAL array, dimension (N) */
00094 /*          The diagonal of the (symmetric tri-) diagonal matrix S. */
00095 
00096 /*  SE      (input) REAL array, dimension (N-1) */
00097 /*          The off-diagonal of the (symmetric tri-) diagonal matrix S. */
00098 /*          Not referenced if KBSND=0.  If KBAND=1, then AE(1) is the */
00099 /*          (1,2) and (2,1) element, SE(2) is the (2,3) and (3,2) */
00100 /*          element, etc. */
00101 
00102 /*  U       (input) REAL array, dimension (LDU, N) */
00103 /*          The orthogonal matrix in the decomposition. */
00104 
00105 /*  LDU     (input) INTEGER */
00106 /*          The leading dimension of U.  LDU must be at least N. */
00107 
00108 /*  WORK    (workspace) REAL array, dimension (N*(N+1)) */
00109 
00110 /*  RESULT  (output) REAL array, dimension (2) */
00111 /*          The values computed by the two tests described above.  The */
00112 /*          values are currently limited to 1/ulp, to avoid overflow. */
00113 /*          RESULT(1) is always modified. */
00114 
00115 /*  ===================================================================== */
00116 
00117 /*     .. Parameters .. */
00118 /*     .. */
00119 /*     .. Local Scalars .. */
00120 /*     .. */
00121 /*     .. External Functions .. */
00122 /*     .. */
00123 /*     .. External Subroutines .. */
00124 /*     .. */
00125 /*     .. Intrinsic Functions .. */
00126 /*     .. */
00127 /*     .. Executable Statements .. */
00128 
00129 /*     1)      Constants */
00130 
00131     /* Parameter adjustments */
00132     --ad;
00133     --ae;
00134     --sd;
00135     --se;
00136     u_dim1 = *ldu;
00137     u_offset = 1 + u_dim1;
00138     u -= u_offset;
00139     --work;
00140     --result;
00141 
00142     /* Function Body */
00143     result[1] = 0.f;
00144     result[2] = 0.f;
00145     if (*n <= 0) {
00146         return 0;
00147     }
00148 
00149     unfl = slamch_("Safe minimum");
00150     ulp = slamch_("Precision");
00151 
00152 /*     Do Test 1 */
00153 
00154 /*     Copy A & Compute its 1-Norm: */
00155 
00156     slaset_("Full", n, n, &c_b5, &c_b5, &work[1], n);
00157 
00158     anorm = 0.f;
00159     temp1 = 0.f;
00160 
00161     i__1 = *n - 1;
00162     for (j = 1; j <= i__1; ++j) {
00163         work[(*n + 1) * (j - 1) + 1] = ad[j];
00164         work[(*n + 1) * (j - 1) + 2] = ae[j];
00165         temp2 = (r__1 = ae[j], dabs(r__1));
00166 /* Computing MAX */
00167         r__2 = anorm, r__3 = (r__1 = ad[j], dabs(r__1)) + temp1 + temp2;
00168         anorm = dmax(r__2,r__3);
00169         temp1 = temp2;
00170 /* L10: */
00171     }
00172 
00173 /* Computing 2nd power */
00174     i__1 = *n;
00175     work[i__1 * i__1] = ad[*n];
00176 /* Computing MAX */
00177     r__2 = anorm, r__3 = (r__1 = ad[*n], dabs(r__1)) + temp1, r__2 = max(r__2,
00178             r__3);
00179     anorm = dmax(r__2,unfl);
00180 
00181 /*     Norm of A - USU' */
00182 
00183     i__1 = *n;
00184     for (j = 1; j <= i__1; ++j) {
00185         r__1 = -sd[j];
00186         ssyr_("L", n, &r__1, &u[j * u_dim1 + 1], &c__1, &work[1], n);
00187 /* L20: */
00188     }
00189 
00190     if (*n > 1 && *kband == 1) {
00191         i__1 = *n - 1;
00192         for (j = 1; j <= i__1; ++j) {
00193             r__1 = -se[j];
00194             ssyr2_("L", n, &r__1, &u[j * u_dim1 + 1], &c__1, &u[(j + 1) * 
00195                     u_dim1 + 1], &c__1, &work[1], n);
00196 /* L30: */
00197         }
00198     }
00199 
00200 /* Computing 2nd power */
00201     i__1 = *n;
00202     wnorm = slansy_("1", "L", n, &work[1], n, &work[i__1 * i__1 + 1]);
00203 
00204     if (anorm > wnorm) {
00205         result[1] = wnorm / anorm / (*n * ulp);
00206     } else {
00207         if (anorm < 1.f) {
00208 /* Computing MIN */
00209             r__1 = wnorm, r__2 = *n * anorm;
00210             result[1] = dmin(r__1,r__2) / anorm / (*n * ulp);
00211         } else {
00212 /* Computing MIN */
00213             r__1 = wnorm / anorm, r__2 = (real) (*n);
00214             result[1] = dmin(r__1,r__2) / (*n * ulp);
00215         }
00216     }
00217 
00218 /*     Do Test 2 */
00219 
00220 /*     Compute  UU' - I */
00221 
00222     sgemm_("N", "C", n, n, n, &c_b19, &u[u_offset], ldu, &u[u_offset], ldu, &
00223             c_b5, &work[1], n);
00224 
00225     i__1 = *n;
00226     for (j = 1; j <= i__1; ++j) {
00227         work[(*n + 1) * (j - 1) + 1] += -1.f;
00228 /* L40: */
00229     }
00230 
00231 /* Computing MIN */
00232 /* Computing 2nd power */
00233     i__1 = *n;
00234     r__1 = (real) (*n), r__2 = slange_("1", n, n, &work[1], n, &work[i__1 * 
00235             i__1 + 1]);
00236     result[2] = dmin(r__1,r__2) / (*n * ulp);
00237 
00238     return 0;
00239 
00240 /*     End of SSTT21 */
00241 
00242 } /* sstt21_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:14