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


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