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


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