cget22.c
Go to the documentation of this file.
00001 /* cget22.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 cget22_(char *transa, char *transe, char *transw, 
00022         integer *n, complex *a, integer *lda, complex *e, integer *lde, 
00023         complex *w, complex *work, real *rwork, real *result)
00024 {
00025     /* System generated locals */
00026     integer a_dim1, a_offset, e_dim1, e_offset, i__1, i__2, i__3, i__4;
00027     real r__1, r__2, r__3, r__4;
00028     complex q__1, q__2;
00029 
00030     /* Builtin functions */
00031     double r_imag(complex *);
00032     void r_cnjg(complex *, complex *);
00033 
00034     /* Local variables */
00035     integer j;
00036     real ulp;
00037     integer joff, jcol, jvec;
00038     real unfl;
00039     integer jrow;
00040     real temp1;
00041     extern /* Subroutine */ int cgemm_(char *, char *, integer *, integer *, 
00042             integer *, complex *, complex *, integer *, complex *, integer *, 
00043             complex *, complex *, integer *);
00044     extern logical lsame_(char *, char *);
00045     char norma[1];
00046     real anorm;
00047     char norme[1];
00048     real enorm;
00049     complex wtemp;
00050     extern doublereal clange_(char *, integer *, integer *, complex *, 
00051             integer *, real *), slamch_(char *);
00052     extern /* Subroutine */ int claset_(char *, integer *, integer *, complex 
00053             *, complex *, complex *, integer *);
00054     real enrmin, enrmax;
00055     integer itrnse;
00056     real errnrm;
00057     integer itrnsw;
00058 
00059 
00060 /*  -- LAPACK test routine (version 3.1) -- */
00061 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00062 /*     November 2006 */
00063 
00064 /*     .. Scalar Arguments .. */
00065 /*     .. */
00066 /*     .. Array Arguments .. */
00067 /*     .. */
00068 
00069 /*  Purpose */
00070 /*  ======= */
00071 
00072 /*  CGET22 does an eigenvector check. */
00073 
00074 /*  The basic test is: */
00075 
00076 /*     RESULT(1) = | A E  -  E W | / ( |A| |E| ulp ) */
00077 
00078 /*  using the 1-norm.  It also tests the normalization of E: */
00079 
00080 /*     RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp ) */
00081 /*                  j */
00082 
00083 /*  where E(j) is the j-th eigenvector, and m-norm is the max-norm of a */
00084 /*  vector.  The max-norm of a complex n-vector x in this case is the */
00085 /*  maximum of |re(x(i)| + |im(x(i)| over i = 1, ..., n. */
00086 
00087 /*  Arguments */
00088 /*  ========== */
00089 
00090 /*  TRANSA  (input) CHARACTER*1 */
00091 /*          Specifies whether or not A is transposed. */
00092 /*          = 'N':  No transpose */
00093 /*          = 'T':  Transpose */
00094 /*          = 'C':  Conjugate transpose */
00095 
00096 /*  TRANSE  (input) CHARACTER*1 */
00097 /*          Specifies whether or not E is transposed. */
00098 /*          = 'N':  No transpose, eigenvectors are in columns of E */
00099 /*          = 'T':  Transpose, eigenvectors are in rows of E */
00100 /*          = 'C':  Conjugate transpose, eigenvectors are in rows of E */
00101 
00102 /*  TRANSW  (input) CHARACTER*1 */
00103 /*          Specifies whether or not W is transposed. */
00104 /*          = 'N':  No transpose */
00105 /*          = 'T':  Transpose, same as TRANSW = 'N' */
00106 /*          = 'C':  Conjugate transpose, use -WI(j) instead of WI(j) */
00107 
00108 /*  N       (input) INTEGER */
00109 /*          The order of the matrix A.  N >= 0. */
00110 
00111 /*  A       (input) COMPLEX array, dimension (LDA,N) */
00112 /*          The matrix whose eigenvectors are in E. */
00113 
00114 /*  LDA     (input) INTEGER */
00115 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00116 
00117 /*  E       (input) COMPLEX array, dimension (LDE,N) */
00118 /*          The matrix of eigenvectors. If TRANSE = 'N', the eigenvectors */
00119 /*          are stored in the columns of E, if TRANSE = 'T' or 'C', the */
00120 /*          eigenvectors are stored in the rows of E. */
00121 
00122 /*  LDE     (input) INTEGER */
00123 /*          The leading dimension of the array E.  LDE >= max(1,N). */
00124 
00125 /*  W       (input) COMPLEX array, dimension (N) */
00126 /*          The eigenvalues of A. */
00127 
00128 /*  WORK    (workspace) COMPLEX array, dimension (N*N) */
00129 
00130 /*  RWORK   (workspace) REAL array, dimension (N) */
00131 
00132 /*  RESULT  (output) REAL array, dimension (2) */
00133 /*          RESULT(1) = | A E  -  E W | / ( |A| |E| ulp ) */
00134 /*          RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp ) */
00135 /*                       j */
00136 /*  ===================================================================== */
00137 
00138 /*     .. Parameters .. */
00139 /*     .. */
00140 /*     .. Local Scalars .. */
00141 /*     .. */
00142 /*     .. External Functions .. */
00143 /*     .. */
00144 /*     .. External Subroutines .. */
00145 /*     .. */
00146 /*     .. Intrinsic Functions .. */
00147 /*     .. */
00148 /*     .. Executable Statements .. */
00149 
00150 /*     Initialize RESULT (in case N=0) */
00151 
00152     /* Parameter adjustments */
00153     a_dim1 = *lda;
00154     a_offset = 1 + a_dim1;
00155     a -= a_offset;
00156     e_dim1 = *lde;
00157     e_offset = 1 + e_dim1;
00158     e -= e_offset;
00159     --w;
00160     --work;
00161     --rwork;
00162     --result;
00163 
00164     /* Function Body */
00165     result[1] = 0.f;
00166     result[2] = 0.f;
00167     if (*n <= 0) {
00168         return 0;
00169     }
00170 
00171     unfl = slamch_("Safe minimum");
00172     ulp = slamch_("Precision");
00173 
00174     itrnse = 0;
00175     itrnsw = 0;
00176     *(unsigned char *)norma = 'O';
00177     *(unsigned char *)norme = 'O';
00178 
00179     if (lsame_(transa, "T") || lsame_(transa, "C")) {
00180         *(unsigned char *)norma = 'I';
00181     }
00182 
00183     if (lsame_(transe, "T")) {
00184         itrnse = 1;
00185         *(unsigned char *)norme = 'I';
00186     } else if (lsame_(transe, "C")) {
00187         itrnse = 2;
00188         *(unsigned char *)norme = 'I';
00189     }
00190 
00191     if (lsame_(transw, "C")) {
00192         itrnsw = 1;
00193     }
00194 
00195 /*     Normalization of E: */
00196 
00197     enrmin = 1.f / ulp;
00198     enrmax = 0.f;
00199     if (itrnse == 0) {
00200         i__1 = *n;
00201         for (jvec = 1; jvec <= i__1; ++jvec) {
00202             temp1 = 0.f;
00203             i__2 = *n;
00204             for (j = 1; j <= i__2; ++j) {
00205 /* Computing MAX */
00206                 i__3 = j + jvec * e_dim1;
00207                 r__3 = temp1, r__4 = (r__1 = e[i__3].r, dabs(r__1)) + (r__2 = 
00208                         r_imag(&e[j + jvec * e_dim1]), dabs(r__2));
00209                 temp1 = dmax(r__3,r__4);
00210 /* L10: */
00211             }
00212             enrmin = dmin(enrmin,temp1);
00213             enrmax = dmax(enrmax,temp1);
00214 /* L20: */
00215         }
00216     } else {
00217         i__1 = *n;
00218         for (jvec = 1; jvec <= i__1; ++jvec) {
00219             rwork[jvec] = 0.f;
00220 /* L30: */
00221         }
00222 
00223         i__1 = *n;
00224         for (j = 1; j <= i__1; ++j) {
00225             i__2 = *n;
00226             for (jvec = 1; jvec <= i__2; ++jvec) {
00227 /* Computing MAX */
00228                 i__3 = jvec + j * e_dim1;
00229                 r__3 = rwork[jvec], r__4 = (r__1 = e[i__3].r, dabs(r__1)) + (
00230                         r__2 = r_imag(&e[jvec + j * e_dim1]), dabs(r__2));
00231                 rwork[jvec] = dmax(r__3,r__4);
00232 /* L40: */
00233             }
00234 /* L50: */
00235         }
00236 
00237         i__1 = *n;
00238         for (jvec = 1; jvec <= i__1; ++jvec) {
00239 /* Computing MIN */
00240             r__1 = enrmin, r__2 = rwork[jvec];
00241             enrmin = dmin(r__1,r__2);
00242 /* Computing MAX */
00243             r__1 = enrmax, r__2 = rwork[jvec];
00244             enrmax = dmax(r__1,r__2);
00245 /* L60: */
00246         }
00247     }
00248 
00249 /*     Norm of A: */
00250 
00251 /* Computing MAX */
00252     r__1 = clange_(norma, n, n, &a[a_offset], lda, &rwork[1]);
00253     anorm = dmax(r__1,unfl);
00254 
00255 /*     Norm of E: */
00256 
00257 /* Computing MAX */
00258     r__1 = clange_(norme, n, n, &e[e_offset], lde, &rwork[1]);
00259     enorm = dmax(r__1,ulp);
00260 
00261 /*     Norm of error: */
00262 
00263 /*     Error =  AE - EW */
00264 
00265     claset_("Full", n, n, &c_b1, &c_b1, &work[1], n);
00266 
00267     joff = 0;
00268     i__1 = *n;
00269     for (jcol = 1; jcol <= i__1; ++jcol) {
00270         if (itrnsw == 0) {
00271             i__2 = jcol;
00272             wtemp.r = w[i__2].r, wtemp.i = w[i__2].i;
00273         } else {
00274             r_cnjg(&q__1, &w[jcol]);
00275             wtemp.r = q__1.r, wtemp.i = q__1.i;
00276         }
00277 
00278         if (itrnse == 0) {
00279             i__2 = *n;
00280             for (jrow = 1; jrow <= i__2; ++jrow) {
00281                 i__3 = joff + jrow;
00282                 i__4 = jrow + jcol * e_dim1;
00283                 q__1.r = e[i__4].r * wtemp.r - e[i__4].i * wtemp.i, q__1.i = 
00284                         e[i__4].r * wtemp.i + e[i__4].i * wtemp.r;
00285                 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00286 /* L70: */
00287             }
00288         } else if (itrnse == 1) {
00289             i__2 = *n;
00290             for (jrow = 1; jrow <= i__2; ++jrow) {
00291                 i__3 = joff + jrow;
00292                 i__4 = jcol + jrow * e_dim1;
00293                 q__1.r = e[i__4].r * wtemp.r - e[i__4].i * wtemp.i, q__1.i = 
00294                         e[i__4].r * wtemp.i + e[i__4].i * wtemp.r;
00295                 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00296 /* L80: */
00297             }
00298         } else {
00299             i__2 = *n;
00300             for (jrow = 1; jrow <= i__2; ++jrow) {
00301                 i__3 = joff + jrow;
00302                 r_cnjg(&q__2, &e[jcol + jrow * e_dim1]);
00303                 q__1.r = q__2.r * wtemp.r - q__2.i * wtemp.i, q__1.i = q__2.r 
00304                         * wtemp.i + q__2.i * wtemp.r;
00305                 work[i__3].r = q__1.r, work[i__3].i = q__1.i;
00306 /* L90: */
00307             }
00308         }
00309         joff += *n;
00310 /* L100: */
00311     }
00312 
00313     q__1.r = -1.f, q__1.i = -0.f;
00314     cgemm_(transa, transe, n, n, n, &c_b2, &a[a_offset], lda, &e[e_offset], 
00315             lde, &q__1, &work[1], n);
00316 
00317     errnrm = clange_("One", n, n, &work[1], n, &rwork[1]) / enorm;
00318 
00319 /*     Compute RESULT(1) (avoiding under/overflow) */
00320 
00321     if (anorm > errnrm) {
00322         result[1] = errnrm / anorm / ulp;
00323     } else {
00324         if (anorm < 1.f) {
00325             result[1] = dmin(errnrm,anorm) / anorm / ulp;
00326         } else {
00327 /* Computing MIN */
00328             r__1 = errnrm / anorm;
00329             result[1] = dmin(r__1,1.f) / ulp;
00330         }
00331     }
00332 
00333 /*     Compute RESULT(2) : the normalization error in E. */
00334 
00335 /* Computing MAX */
00336     r__3 = (r__1 = enrmax - 1.f, dabs(r__1)), r__4 = (r__2 = enrmin - 1.f, 
00337             dabs(r__2));
00338     result[2] = dmax(r__3,r__4) / ((real) (*n) * ulp);
00339 
00340     return 0;
00341 
00342 /*     End of CGET22 */
00343 
00344 } /* cget22_ */


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