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


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