dget52.c
Go to the documentation of this file.
00001 /* dget52.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 integer c__1 = 1;
00019 static doublereal c_b12 = 0.;
00020 static doublereal c_b15 = 1.;
00021 
00022 /* Subroutine */ int dget52_(logical *left, integer *n, doublereal *a, 
00023         integer *lda, doublereal *b, integer *ldb, doublereal *e, integer *
00024         lde, doublereal *alphar, doublereal *alphai, doublereal *beta, 
00025         doublereal *work, doublereal *result)
00026 {
00027     /* System generated locals */
00028     integer a_dim1, a_offset, b_dim1, b_offset, e_dim1, e_offset, i__1, i__2;
00029     doublereal d__1, d__2, d__3, d__4;
00030 
00031     /* Local variables */
00032     integer j;
00033     doublereal ulp;
00034     integer jvec;
00035     doublereal temp1, acoef, scale, abmax, salfi, sbeta;
00036     extern /* Subroutine */ int dgemv_(char *, integer *, integer *, 
00037             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00038             doublereal *, doublereal *, integer *);
00039     doublereal salfr, anorm, bnorm, enorm;
00040     char trans[1];
00041     doublereal bcoefi;
00042     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00043             integer *, doublereal *, integer *, doublereal *);
00044     doublereal bcoefr, alfmax, safmin;
00045     char normab[1];
00046     doublereal safmax, betmax, enrmer;
00047     logical ilcplx;
00048     doublereal errnrm;
00049 
00050 
00051 /*  -- LAPACK test routine (version 3.1) -- */
00052 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00053 /*     November 2006 */
00054 
00055 /*     .. Scalar Arguments .. */
00056 /*     .. */
00057 /*     .. Array Arguments .. */
00058 /*     .. */
00059 
00060 /*  Purpose */
00061 /*  ======= */
00062 
00063 /*  DGET52  does an eigenvector check for the generalized eigenvalue */
00064 /*  problem. */
00065 
00066 /*  The basic test for right eigenvectors is: */
00067 
00068 /*                            | b(j) A E(j) -  a(j) B E(j) | */
00069 /*          RESULT(1) = max   ------------------------------- */
00070 /*                       j    n ulp max( |b(j) A|, |a(j) B| ) */
00071 
00072 /*  using the 1-norm.  Here, a(j)/b(j) = w is the j-th generalized */
00073 /*  eigenvalue of A - w B, or, equivalently, b(j)/a(j) = m is the j-th */
00074 /*  generalized eigenvalue of m A - B. */
00075 
00076 /*  For real eigenvalues, the test is straightforward.  For complex */
00077 /*  eigenvalues, E(j) and a(j) are complex, represented by */
00078 /*  Er(j) + i*Ei(j) and ar(j) + i*ai(j), resp., so the test for that */
00079 /*  eigenvector becomes */
00080 
00081 /*                  max( |Wr|, |Wi| ) */
00082 /*      -------------------------------------------- */
00083 /*      n ulp max( |b(j) A|, (|ar(j)|+|ai(j)|) |B| ) */
00084 
00085 /*  where */
00086 
00087 /*      Wr = b(j) A Er(j) - ar(j) B Er(j) + ai(j) B Ei(j) */
00088 
00089 /*      Wi = b(j) A Ei(j) - ai(j) B Er(j) - ar(j) B Ei(j) */
00090 
00091 /*                          T   T  _ */
00092 /*  For left eigenvectors, A , B , a, and b  are used. */
00093 
00094 /*  DGET52 also tests the normalization of E.  Each eigenvector is */
00095 /*  supposed to be normalized so that the maximum "absolute value" */
00096 /*  of its elements is 1, where in this case, "absolute value" */
00097 /*  of a complex value x is  |Re(x)| + |Im(x)| ; let us call this */
00098 /*  maximum "absolute value" norm of a vector v  M(v). */
00099 /*  if a(j)=b(j)=0, then the eigenvector is set to be the jth coordinate */
00100 /*  vector.  The normalization test is: */
00101 
00102 /*          RESULT(2) =      max       | M(v(j)) - 1 | / ( n ulp ) */
00103 /*                     eigenvectors v(j) */
00104 
00105 /*  Arguments */
00106 /*  ========= */
00107 
00108 /*  LEFT    (input) LOGICAL */
00109 /*          =.TRUE.:  The eigenvectors in the columns of E are assumed */
00110 /*                    to be *left* eigenvectors. */
00111 /*          =.FALSE.: The eigenvectors in the columns of E are assumed */
00112 /*                    to be *right* eigenvectors. */
00113 
00114 /*  N       (input) INTEGER */
00115 /*          The size of the matrices.  If it is zero, DGET52 does */
00116 /*          nothing.  It must be at least zero. */
00117 
00118 /*  A       (input) DOUBLE PRECISION array, dimension (LDA, N) */
00119 /*          The matrix A. */
00120 
00121 /*  LDA     (input) INTEGER */
00122 /*          The leading dimension of A.  It must be at least 1 */
00123 /*          and at least N. */
00124 
00125 /*  B       (input) DOUBLE PRECISION array, dimension (LDB, N) */
00126 /*          The matrix B. */
00127 
00128 /*  LDB     (input) INTEGER */
00129 /*          The leading dimension of B.  It must be at least 1 */
00130 /*          and at least N. */
00131 
00132 /*  E       (input) DOUBLE PRECISION array, dimension (LDE, N) */
00133 /*          The matrix of eigenvectors.  It must be O( 1 ).  Complex */
00134 /*          eigenvalues and eigenvectors always come in pairs, the */
00135 /*          eigenvalue and its conjugate being stored in adjacent */
00136 /*          elements of ALPHAR, ALPHAI, and BETA.  Thus, if a(j)/b(j) */
00137 /*          and a(j+1)/b(j+1) are a complex conjugate pair of */
00138 /*          generalized eigenvalues, then E(,j) contains the real part */
00139 /*          of the eigenvector and E(,j+1) contains the imaginary part. */
00140 /*          Note that whether E(,j) is a real eigenvector or part of a */
00141 /*          complex one is specified by whether ALPHAI(j) is zero or not. */
00142 
00143 /*  LDE     (input) INTEGER */
00144 /*          The leading dimension of E.  It must be at least 1 and at */
00145 /*          least N. */
00146 
00147 /*  ALPHAR  (input) DOUBLE PRECISION array, dimension (N) */
00148 /*          The real parts of the values a(j) as described above, which, */
00149 /*          along with b(j), define the generalized eigenvalues. */
00150 /*          Complex eigenvalues always come in complex conjugate pairs */
00151 /*          a(j)/b(j) and a(j+1)/b(j+1), which are stored in adjacent */
00152 /*          elements in ALPHAR, ALPHAI, and BETA.  Thus, if the j-th */
00153 /*          and (j+1)-st eigenvalues form a pair, ALPHAR(j+1)/BETA(j+1) */
00154 /*          is assumed to be equal to ALPHAR(j)/BETA(j). */
00155 
00156 /*  ALPHAI  (input) DOUBLE PRECISION array, dimension (N) */
00157 /*          The imaginary parts of the values a(j) as described above, */
00158 /*          which, along with b(j), define the generalized eigenvalues. */
00159 /*          If ALPHAI(j)=0, then the eigenvalue is real, otherwise it */
00160 /*          is part of a complex conjugate pair.  Complex eigenvalues */
00161 /*          always come in complex conjugate pairs a(j)/b(j) and */
00162 /*          a(j+1)/b(j+1), which are stored in adjacent elements in */
00163 /*          ALPHAR, ALPHAI, and BETA.  Thus, if the j-th and (j+1)-st */
00164 /*          eigenvalues form a pair, ALPHAI(j+1)/BETA(j+1) is assumed to */
00165 /*          be equal to  -ALPHAI(j)/BETA(j).  Also, nonzero values in */
00166 /*          ALPHAI are assumed to always come in adjacent pairs. */
00167 
00168 /*  BETA    (input) DOUBLE PRECISION array, dimension (N) */
00169 /*          The values b(j) as described above, which, along with a(j), */
00170 /*          define the generalized eigenvalues. */
00171 
00172 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (N**2+N) */
00173 
00174 /*  RESULT  (output) DOUBLE PRECISION array, dimension (2) */
00175 /*          The values computed by the test described above.  If A E or */
00176 /*          B E is likely to overflow, then RESULT(1:2) is set to */
00177 /*          10 / ulp. */
00178 
00179 /*  ===================================================================== */
00180 
00181 /*     .. Parameters .. */
00182 /*     .. */
00183 /*     .. Local Scalars .. */
00184 /*     .. */
00185 /*     .. External Functions .. */
00186 /*     .. */
00187 /*     .. External Subroutines .. */
00188 /*     .. */
00189 /*     .. Intrinsic Functions .. */
00190 /*     .. */
00191 /*     .. Executable Statements .. */
00192 
00193     /* Parameter adjustments */
00194     a_dim1 = *lda;
00195     a_offset = 1 + a_dim1;
00196     a -= a_offset;
00197     b_dim1 = *ldb;
00198     b_offset = 1 + b_dim1;
00199     b -= b_offset;
00200     e_dim1 = *lde;
00201     e_offset = 1 + e_dim1;
00202     e -= e_offset;
00203     --alphar;
00204     --alphai;
00205     --beta;
00206     --work;
00207     --result;
00208 
00209     /* Function Body */
00210     result[1] = 0.;
00211     result[2] = 0.;
00212     if (*n <= 0) {
00213         return 0;
00214     }
00215 
00216     safmin = dlamch_("Safe minimum");
00217     safmax = 1. / safmin;
00218     ulp = dlamch_("Epsilon") * dlamch_("Base");
00219 
00220     if (*left) {
00221         *(unsigned char *)trans = 'T';
00222         *(unsigned char *)normab = 'I';
00223     } else {
00224         *(unsigned char *)trans = 'N';
00225         *(unsigned char *)normab = 'O';
00226     }
00227 
00228 /*     Norm of A, B, and E: */
00229 
00230 /* Computing MAX */
00231     d__1 = dlange_(normab, n, n, &a[a_offset], lda, &work[1]);
00232     anorm = max(d__1,safmin);
00233 /* Computing MAX */
00234     d__1 = dlange_(normab, n, n, &b[b_offset], ldb, &work[1]);
00235     bnorm = max(d__1,safmin);
00236 /* Computing MAX */
00237     d__1 = dlange_("O", n, n, &e[e_offset], lde, &work[1]);
00238     enorm = max(d__1,ulp);
00239     alfmax = safmax / max(1.,bnorm);
00240     betmax = safmax / max(1.,anorm);
00241 
00242 /*     Compute error matrix. */
00243 /*     Column i = ( b(i) A - a(i) B ) E(i) / max( |a(i) B| |b(i) A| ) */
00244 
00245     ilcplx = FALSE_;
00246     i__1 = *n;
00247     for (jvec = 1; jvec <= i__1; ++jvec) {
00248         if (ilcplx) {
00249 
00250 /*           2nd Eigenvalue/-vector of pair -- do nothing */
00251 
00252             ilcplx = FALSE_;
00253         } else {
00254             salfr = alphar[jvec];
00255             salfi = alphai[jvec];
00256             sbeta = beta[jvec];
00257             if (salfi == 0.) {
00258 
00259 /*              Real eigenvalue and -vector */
00260 
00261 /* Computing MAX */
00262                 d__1 = abs(salfr), d__2 = abs(sbeta);
00263                 abmax = max(d__1,d__2);
00264                 if (abs(salfr) > alfmax || abs(sbeta) > betmax || abmax < 1.) 
00265                         {
00266                     scale = 1. / max(abmax,safmin);
00267                     salfr = scale * salfr;
00268                     sbeta = scale * sbeta;
00269                 }
00270 /* Computing MAX */
00271                 d__1 = abs(salfr) * bnorm, d__2 = abs(sbeta) * anorm, d__1 = 
00272                         max(d__1,d__2);
00273                 scale = 1. / max(d__1,safmin);
00274                 acoef = scale * sbeta;
00275                 bcoefr = scale * salfr;
00276                 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[jvec * 
00277                         e_dim1 + 1], &c__1, &c_b12, &work[*n * (jvec - 1) + 1]
00278 , &c__1);
00279                 d__1 = -bcoefr;
00280                 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec * 
00281                         e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) + 1]
00282 , &c__1);
00283             } else {
00284 
00285 /*              Complex conjugate pair */
00286 
00287                 ilcplx = TRUE_;
00288                 if (jvec == *n) {
00289                     result[1] = 10. / ulp;
00290                     return 0;
00291                 }
00292 /* Computing MAX */
00293                 d__1 = abs(salfr) + abs(salfi), d__2 = abs(sbeta);
00294                 abmax = max(d__1,d__2);
00295                 if (abs(salfr) + abs(salfi) > alfmax || abs(sbeta) > betmax ||
00296                          abmax < 1.) {
00297                     scale = 1. / max(abmax,safmin);
00298                     salfr = scale * salfr;
00299                     salfi = scale * salfi;
00300                     sbeta = scale * sbeta;
00301                 }
00302 /* Computing MAX */
00303                 d__1 = (abs(salfr) + abs(salfi)) * bnorm, d__2 = abs(sbeta) * 
00304                         anorm, d__1 = max(d__1,d__2);
00305                 scale = 1. / max(d__1,safmin);
00306                 acoef = scale * sbeta;
00307                 bcoefr = scale * salfr;
00308                 bcoefi = scale * salfi;
00309                 if (*left) {
00310                     bcoefi = -bcoefi;
00311                 }
00312 
00313                 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[jvec * 
00314                         e_dim1 + 1], &c__1, &c_b12, &work[*n * (jvec - 1) + 1]
00315 , &c__1);
00316                 d__1 = -bcoefr;
00317                 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec * 
00318                         e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) + 1]
00319 , &c__1);
00320                 dgemv_(trans, n, n, &bcoefi, &b[b_offset], lda, &e[(jvec + 1) 
00321                         * e_dim1 + 1], &c__1, &c_b15, &work[*n * (jvec - 1) + 
00322                         1], &c__1);
00323 
00324                 dgemv_(trans, n, n, &acoef, &a[a_offset], lda, &e[(jvec + 1) *
00325                          e_dim1 + 1], &c__1, &c_b12, &work[*n * jvec + 1], &
00326                         c__1);
00327                 d__1 = -bcoefi;
00328                 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[jvec * 
00329                         e_dim1 + 1], &c__1, &c_b15, &work[*n * jvec + 1], &
00330                         c__1);
00331                 d__1 = -bcoefr;
00332                 dgemv_(trans, n, n, &d__1, &b[b_offset], lda, &e[(jvec + 1) * 
00333                         e_dim1 + 1], &c__1, &c_b15, &work[*n * jvec + 1], &
00334                         c__1);
00335             }
00336         }
00337 /* L10: */
00338     }
00339 
00340 /* Computing 2nd power */
00341     i__1 = *n;
00342     errnrm = dlange_("One", n, n, &work[1], n, &work[i__1 * i__1 + 1]) / enorm;
00343 
00344 /*     Compute RESULT(1) */
00345 
00346     result[1] = errnrm / ulp;
00347 
00348 /*     Normalization of E: */
00349 
00350     enrmer = 0.;
00351     ilcplx = FALSE_;
00352     i__1 = *n;
00353     for (jvec = 1; jvec <= i__1; ++jvec) {
00354         if (ilcplx) {
00355             ilcplx = FALSE_;
00356         } else {
00357             temp1 = 0.;
00358             if (alphai[jvec] == 0.) {
00359                 i__2 = *n;
00360                 for (j = 1; j <= i__2; ++j) {
00361 /* Computing MAX */
00362                     d__2 = temp1, d__3 = (d__1 = e[j + jvec * e_dim1], abs(
00363                             d__1));
00364                     temp1 = max(d__2,d__3);
00365 /* L20: */
00366                 }
00367 /* Computing MAX */
00368                 d__1 = enrmer, d__2 = temp1 - 1.;
00369                 enrmer = max(d__1,d__2);
00370             } else {
00371                 ilcplx = TRUE_;
00372                 i__2 = *n;
00373                 for (j = 1; j <= i__2; ++j) {
00374 /* Computing MAX */
00375                     d__3 = temp1, d__4 = (d__1 = e[j + jvec * e_dim1], abs(
00376                             d__1)) + (d__2 = e[j + (jvec + 1) * e_dim1], abs(
00377                             d__2));
00378                     temp1 = max(d__3,d__4);
00379 /* L30: */
00380                 }
00381 /* Computing MAX */
00382                 d__1 = enrmer, d__2 = temp1 - 1.;
00383                 enrmer = max(d__1,d__2);
00384             }
00385         }
00386 /* L40: */
00387     }
00388 
00389 /*     Compute RESULT(2) : the normalization error in E. */
00390 
00391     result[2] = enrmer / ((doublereal) (*n) * ulp);
00392 
00393     return 0;
00394 
00395 /*     End of DGET52 */
00396 
00397 } /* dget52_ */


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