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


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