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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:49