dggev.c
Go to the documentation of this file.
00001 /* dggev.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 integer c__0 = 0;
00020 static integer c_n1 = -1;
00021 static doublereal c_b36 = 0.;
00022 static doublereal c_b37 = 1.;
00023 
00024 /* Subroutine */ int dggev_(char *jobvl, char *jobvr, integer *n, doublereal *
00025         a, integer *lda, doublereal *b, integer *ldb, doublereal *alphar, 
00026         doublereal *alphai, doublereal *beta, doublereal *vl, integer *ldvl, 
00027         doublereal *vr, integer *ldvr, doublereal *work, integer *lwork, 
00028         integer *info)
00029 {
00030     /* System generated locals */
00031     integer a_dim1, a_offset, b_dim1, b_offset, vl_dim1, vl_offset, vr_dim1, 
00032             vr_offset, i__1, i__2;
00033     doublereal d__1, d__2, d__3, d__4;
00034 
00035     /* Builtin functions */
00036     double sqrt(doublereal);
00037 
00038     /* Local variables */
00039     integer jc, in, jr, ihi, ilo;
00040     doublereal eps;
00041     logical ilv;
00042     doublereal anrm, bnrm;
00043     integer ierr, itau;
00044     doublereal temp;
00045     logical ilvl, ilvr;
00046     integer iwrk;
00047     extern logical lsame_(char *, char *);
00048     integer ileft, icols, irows;
00049     extern /* Subroutine */ int dlabad_(doublereal *, doublereal *), dggbak_(
00050             char *, char *, integer *, integer *, integer *, doublereal *, 
00051             doublereal *, integer *, doublereal *, integer *, integer *), dggbal_(char *, integer *, doublereal *, integer 
00052             *, doublereal *, integer *, integer *, integer *, doublereal *, 
00053             doublereal *, doublereal *, integer *);
00054     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00055             integer *, doublereal *, integer *, doublereal *);
00056     extern /* Subroutine */ int dgghrd_(char *, char *, integer *, integer *, 
00057             integer *, doublereal *, integer *, doublereal *, integer *, 
00058             doublereal *, integer *, doublereal *, integer *, integer *), dlascl_(char *, integer *, integer *, doublereal 
00059             *, doublereal *, integer *, integer *, doublereal *, integer *, 
00060             integer *);
00061     logical ilascl, ilbscl;
00062     extern /* Subroutine */ int dgeqrf_(integer *, integer *, doublereal *, 
00063             integer *, doublereal *, doublereal *, integer *, integer *), 
00064             dlacpy_(char *, integer *, integer *, doublereal *, integer *, 
00065             doublereal *, integer *), dlaset_(char *, integer *, 
00066             integer *, doublereal *, doublereal *, doublereal *, integer *), dtgevc_(char *, char *, logical *, integer *, doublereal 
00067             *, integer *, doublereal *, integer *, doublereal *, integer *, 
00068             doublereal *, integer *, integer *, integer *, doublereal *, 
00069             integer *);
00070     logical ldumma[1];
00071     char chtemp[1];
00072     doublereal bignum;
00073     extern /* Subroutine */ int dhgeqz_(char *, char *, char *, integer *, 
00074             integer *, integer *, doublereal *, integer *, doublereal *, 
00075             integer *, doublereal *, doublereal *, doublereal *, doublereal *, 
00076              integer *, doublereal *, integer *, doublereal *, integer *, 
00077             integer *), xerbla_(char *, integer *);
00078     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00079             integer *, integer *);
00080     integer ijobvl, iright, ijobvr;
00081     extern /* Subroutine */ int dorgqr_(integer *, integer *, integer *, 
00082             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00083             integer *);
00084     doublereal anrmto, bnrmto;
00085     extern /* Subroutine */ int dormqr_(char *, char *, integer *, integer *, 
00086             integer *, doublereal *, integer *, doublereal *, doublereal *, 
00087             integer *, doublereal *, integer *, integer *);
00088     integer minwrk, maxwrk;
00089     doublereal smlnum;
00090     logical lquery;
00091 
00092 
00093 /*  -- LAPACK driver routine (version 3.2) -- */
00094 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00095 /*     November 2006 */
00096 
00097 /*     .. Scalar Arguments .. */
00098 /*     .. */
00099 /*     .. Array Arguments .. */
00100 /*     .. */
00101 
00102 /*  Purpose */
00103 /*  ======= */
00104 
00105 /*  DGGEV computes for a pair of N-by-N real nonsymmetric matrices (A,B) */
00106 /*  the generalized eigenvalues, and optionally, the left and/or right */
00107 /*  generalized eigenvectors. */
00108 
00109 /*  A generalized eigenvalue for a pair of matrices (A,B) is a scalar */
00110 /*  lambda or a ratio alpha/beta = lambda, such that A - lambda*B is */
00111 /*  singular. It is usually represented as the pair (alpha,beta), as */
00112 /*  there is a reasonable interpretation for beta=0, and even for both */
00113 /*  being zero. */
00114 
00115 /*  The right eigenvector v(j) corresponding to the eigenvalue lambda(j) */
00116 /*  of (A,B) satisfies */
00117 
00118 /*                   A * v(j) = lambda(j) * B * v(j). */
00119 
00120 /*  The left eigenvector u(j) corresponding to the eigenvalue lambda(j) */
00121 /*  of (A,B) satisfies */
00122 
00123 /*                   u(j)**H * A  = lambda(j) * u(j)**H * B . */
00124 
00125 /*  where u(j)**H is the conjugate-transpose of u(j). */
00126 
00127 
00128 /*  Arguments */
00129 /*  ========= */
00130 
00131 /*  JOBVL   (input) CHARACTER*1 */
00132 /*          = 'N':  do not compute the left generalized eigenvectors; */
00133 /*          = 'V':  compute the left generalized eigenvectors. */
00134 
00135 /*  JOBVR   (input) CHARACTER*1 */
00136 /*          = 'N':  do not compute the right generalized eigenvectors; */
00137 /*          = 'V':  compute the right generalized eigenvectors. */
00138 
00139 /*  N       (input) INTEGER */
00140 /*          The order of the matrices A, B, VL, and VR.  N >= 0. */
00141 
00142 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N) */
00143 /*          On entry, the matrix A in the pair (A,B). */
00144 /*          On exit, A has been overwritten. */
00145 
00146 /*  LDA     (input) INTEGER */
00147 /*          The leading dimension of A.  LDA >= max(1,N). */
00148 
00149 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB, N) */
00150 /*          On entry, the matrix B in the pair (A,B). */
00151 /*          On exit, B has been overwritten. */
00152 
00153 /*  LDB     (input) INTEGER */
00154 /*          The leading dimension of B.  LDB >= max(1,N). */
00155 
00156 /*  ALPHAR  (output) DOUBLE PRECISION array, dimension (N) */
00157 /*  ALPHAI  (output) DOUBLE PRECISION array, dimension (N) */
00158 /*  BETA    (output) DOUBLE PRECISION array, dimension (N) */
00159 /*          On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will */
00160 /*          be the generalized eigenvalues.  If ALPHAI(j) is zero, then */
00161 /*          the j-th eigenvalue is real; if positive, then the j-th and */
00162 /*          (j+1)-st eigenvalues are a complex conjugate pair, with */
00163 /*          ALPHAI(j+1) negative. */
00164 
00165 /*          Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j) */
00166 /*          may easily over- or underflow, and BETA(j) may even be zero. */
00167 /*          Thus, the user should avoid naively computing the ratio */
00168 /*          alpha/beta.  However, ALPHAR and ALPHAI will be always less */
00169 /*          than and usually comparable with norm(A) in magnitude, and */
00170 /*          BETA always less than and usually comparable with norm(B). */
00171 
00172 /*  VL      (output) DOUBLE PRECISION array, dimension (LDVL,N) */
00173 /*          If JOBVL = 'V', the left eigenvectors u(j) are stored one */
00174 /*          after another in the columns of VL, in the same order as */
00175 /*          their eigenvalues. If the j-th eigenvalue is real, then */
00176 /*          u(j) = VL(:,j), the j-th column of VL. If the j-th and */
00177 /*          (j+1)-th eigenvalues form a complex conjugate pair, then */
00178 /*          u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1). */
00179 /*          Each eigenvector is scaled so the largest component has */
00180 /*          abs(real part)+abs(imag. part)=1. */
00181 /*          Not referenced if JOBVL = 'N'. */
00182 
00183 /*  LDVL    (input) INTEGER */
00184 /*          The leading dimension of the matrix VL. LDVL >= 1, and */
00185 /*          if JOBVL = 'V', LDVL >= N. */
00186 
00187 /*  VR      (output) DOUBLE PRECISION array, dimension (LDVR,N) */
00188 /*          If JOBVR = 'V', the right eigenvectors v(j) are stored one */
00189 /*          after another in the columns of VR, in the same order as */
00190 /*          their eigenvalues. If the j-th eigenvalue is real, then */
00191 /*          v(j) = VR(:,j), the j-th column of VR. If the j-th and */
00192 /*          (j+1)-th eigenvalues form a complex conjugate pair, then */
00193 /*          v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1). */
00194 /*          Each eigenvector is scaled so the largest component has */
00195 /*          abs(real part)+abs(imag. part)=1. */
00196 /*          Not referenced if JOBVR = 'N'. */
00197 
00198 /*  LDVR    (input) INTEGER */
00199 /*          The leading dimension of the matrix VR. LDVR >= 1, and */
00200 /*          if JOBVR = 'V', LDVR >= N. */
00201 
00202 /*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
00203 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00204 
00205 /*  LWORK   (input) INTEGER */
00206 /*          The dimension of the array WORK.  LWORK >= max(1,8*N). */
00207 /*          For good performance, LWORK must generally be larger. */
00208 
00209 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00210 /*          only calculates the optimal size of the WORK array, returns */
00211 /*          this value as the first entry of the WORK array, and no error */
00212 /*          message related to LWORK is issued by XERBLA. */
00213 
00214 /*  INFO    (output) INTEGER */
00215 /*          = 0:  successful exit */
00216 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00217 /*          = 1,...,N: */
00218 /*                The QZ iteration failed.  No eigenvectors have been */
00219 /*                calculated, but ALPHAR(j), ALPHAI(j), and BETA(j) */
00220 /*                should be correct for j=INFO+1,...,N. */
00221 /*          > N:  =N+1: other than QZ iteration failed in DHGEQZ. */
00222 /*                =N+2: error return from DTGEVC. */
00223 
00224 /*  ===================================================================== */
00225 
00226 /*     .. Parameters .. */
00227 /*     .. */
00228 /*     .. Local Scalars .. */
00229 /*     .. */
00230 /*     .. Local Arrays .. */
00231 /*     .. */
00232 /*     .. External Subroutines .. */
00233 /*     .. */
00234 /*     .. External Functions .. */
00235 /*     .. */
00236 /*     .. Intrinsic Functions .. */
00237 /*     .. */
00238 /*     .. Executable Statements .. */
00239 
00240 /*     Decode the input arguments */
00241 
00242     /* Parameter adjustments */
00243     a_dim1 = *lda;
00244     a_offset = 1 + a_dim1;
00245     a -= a_offset;
00246     b_dim1 = *ldb;
00247     b_offset = 1 + b_dim1;
00248     b -= b_offset;
00249     --alphar;
00250     --alphai;
00251     --beta;
00252     vl_dim1 = *ldvl;
00253     vl_offset = 1 + vl_dim1;
00254     vl -= vl_offset;
00255     vr_dim1 = *ldvr;
00256     vr_offset = 1 + vr_dim1;
00257     vr -= vr_offset;
00258     --work;
00259 
00260     /* Function Body */
00261     if (lsame_(jobvl, "N")) {
00262         ijobvl = 1;
00263         ilvl = FALSE_;
00264     } else if (lsame_(jobvl, "V")) {
00265         ijobvl = 2;
00266         ilvl = TRUE_;
00267     } else {
00268         ijobvl = -1;
00269         ilvl = FALSE_;
00270     }
00271 
00272     if (lsame_(jobvr, "N")) {
00273         ijobvr = 1;
00274         ilvr = FALSE_;
00275     } else if (lsame_(jobvr, "V")) {
00276         ijobvr = 2;
00277         ilvr = TRUE_;
00278     } else {
00279         ijobvr = -1;
00280         ilvr = FALSE_;
00281     }
00282     ilv = ilvl || ilvr;
00283 
00284 /*     Test the input arguments */
00285 
00286     *info = 0;
00287     lquery = *lwork == -1;
00288     if (ijobvl <= 0) {
00289         *info = -1;
00290     } else if (ijobvr <= 0) {
00291         *info = -2;
00292     } else if (*n < 0) {
00293         *info = -3;
00294     } else if (*lda < max(1,*n)) {
00295         *info = -5;
00296     } else if (*ldb < max(1,*n)) {
00297         *info = -7;
00298     } else if (*ldvl < 1 || ilvl && *ldvl < *n) {
00299         *info = -12;
00300     } else if (*ldvr < 1 || ilvr && *ldvr < *n) {
00301         *info = -14;
00302     }
00303 
00304 /*     Compute workspace */
00305 /*      (Note: Comments in the code beginning "Workspace:" describe the */
00306 /*       minimal amount of workspace needed at that point in the code, */
00307 /*       as well as the preferred amount for good performance. */
00308 /*       NB refers to the optimal block size for the immediately */
00309 /*       following subroutine, as returned by ILAENV. The workspace is */
00310 /*       computed assuming ILO = 1 and IHI = N, the worst case.) */
00311 
00312     if (*info == 0) {
00313 /* Computing MAX */
00314         i__1 = 1, i__2 = *n << 3;
00315         minwrk = max(i__1,i__2);
00316 /* Computing MAX */
00317         i__1 = 1, i__2 = *n * (ilaenv_(&c__1, "DGEQRF", " ", n, &c__1, n, &
00318                 c__0) + 7);
00319         maxwrk = max(i__1,i__2);
00320 /* Computing MAX */
00321         i__1 = maxwrk, i__2 = *n * (ilaenv_(&c__1, "DORMQR", " ", n, &c__1, n, 
00322                  &c__0) + 7);
00323         maxwrk = max(i__1,i__2);
00324         if (ilvl) {
00325 /* Computing MAX */
00326             i__1 = maxwrk, i__2 = *n * (ilaenv_(&c__1, "DORGQR", " ", n, &
00327                     c__1, n, &c_n1) + 7);
00328             maxwrk = max(i__1,i__2);
00329         }
00330         work[1] = (doublereal) maxwrk;
00331 
00332         if (*lwork < minwrk && ! lquery) {
00333             *info = -16;
00334         }
00335     }
00336 
00337     if (*info != 0) {
00338         i__1 = -(*info);
00339         xerbla_("DGGEV ", &i__1);
00340         return 0;
00341     } else if (lquery) {
00342         return 0;
00343     }
00344 
00345 /*     Quick return if possible */
00346 
00347     if (*n == 0) {
00348         return 0;
00349     }
00350 
00351 /*     Get machine constants */
00352 
00353     eps = dlamch_("P");
00354     smlnum = dlamch_("S");
00355     bignum = 1. / smlnum;
00356     dlabad_(&smlnum, &bignum);
00357     smlnum = sqrt(smlnum) / eps;
00358     bignum = 1. / smlnum;
00359 
00360 /*     Scale A if max element outside range [SMLNUM,BIGNUM] */
00361 
00362     anrm = dlange_("M", n, n, &a[a_offset], lda, &work[1]);
00363     ilascl = FALSE_;
00364     if (anrm > 0. && anrm < smlnum) {
00365         anrmto = smlnum;
00366         ilascl = TRUE_;
00367     } else if (anrm > bignum) {
00368         anrmto = bignum;
00369         ilascl = TRUE_;
00370     }
00371     if (ilascl) {
00372         dlascl_("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, &
00373                 ierr);
00374     }
00375 
00376 /*     Scale B if max element outside range [SMLNUM,BIGNUM] */
00377 
00378     bnrm = dlange_("M", n, n, &b[b_offset], ldb, &work[1]);
00379     ilbscl = FALSE_;
00380     if (bnrm > 0. && bnrm < smlnum) {
00381         bnrmto = smlnum;
00382         ilbscl = TRUE_;
00383     } else if (bnrm > bignum) {
00384         bnrmto = bignum;
00385         ilbscl = TRUE_;
00386     }
00387     if (ilbscl) {
00388         dlascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, &
00389                 ierr);
00390     }
00391 
00392 /*     Permute the matrices A, B to isolate eigenvalues if possible */
00393 /*     (Workspace: need 6*N) */
00394 
00395     ileft = 1;
00396     iright = *n + 1;
00397     iwrk = iright + *n;
00398     dggbal_("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &work[
00399             ileft], &work[iright], &work[iwrk], &ierr);
00400 
00401 /*     Reduce B to triangular form (QR decomposition of B) */
00402 /*     (Workspace: need N, prefer N*NB) */
00403 
00404     irows = ihi + 1 - ilo;
00405     if (ilv) {
00406         icols = *n + 1 - ilo;
00407     } else {
00408         icols = irows;
00409     }
00410     itau = iwrk;
00411     iwrk = itau + irows;
00412     i__1 = *lwork + 1 - iwrk;
00413     dgeqrf_(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[
00414             iwrk], &i__1, &ierr);
00415 
00416 /*     Apply the orthogonal transformation to matrix A */
00417 /*     (Workspace: need N, prefer N*NB) */
00418 
00419     i__1 = *lwork + 1 - iwrk;
00420     dormqr_("L", "T", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, &
00421             work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, &
00422             ierr);
00423 
00424 /*     Initialize VL */
00425 /*     (Workspace: need N, prefer N*NB) */
00426 
00427     if (ilvl) {
00428         dlaset_("Full", n, n, &c_b36, &c_b37, &vl[vl_offset], ldvl)
00429                 ;
00430         if (irows > 1) {
00431             i__1 = irows - 1;
00432             i__2 = irows - 1;
00433             dlacpy_("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vl[
00434                     ilo + 1 + ilo * vl_dim1], ldvl);
00435         }
00436         i__1 = *lwork + 1 - iwrk;
00437         dorgqr_(&irows, &irows, &irows, &vl[ilo + ilo * vl_dim1], ldvl, &work[
00438                 itau], &work[iwrk], &i__1, &ierr);
00439     }
00440 
00441 /*     Initialize VR */
00442 
00443     if (ilvr) {
00444         dlaset_("Full", n, n, &c_b36, &c_b37, &vr[vr_offset], ldvr)
00445                 ;
00446     }
00447 
00448 /*     Reduce to generalized Hessenberg form */
00449 /*     (Workspace: none needed) */
00450 
00451     if (ilv) {
00452 
00453 /*        Eigenvectors requested -- work on whole matrix. */
00454 
00455         dgghrd_(jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], 
00456                 ldb, &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, &ierr);
00457     } else {
00458         dgghrd_("N", "N", &irows, &c__1, &irows, &a[ilo + ilo * a_dim1], lda, 
00459                 &b[ilo + ilo * b_dim1], ldb, &vl[vl_offset], ldvl, &vr[
00460                 vr_offset], ldvr, &ierr);
00461     }
00462 
00463 /*     Perform QZ algorithm (Compute eigenvalues, and optionally, the */
00464 /*     Schur forms and Schur vectors) */
00465 /*     (Workspace: need N) */
00466 
00467     iwrk = itau;
00468     if (ilv) {
00469         *(unsigned char *)chtemp = 'S';
00470     } else {
00471         *(unsigned char *)chtemp = 'E';
00472     }
00473     i__1 = *lwork + 1 - iwrk;
00474     dhgeqz_(chtemp, jobvl, jobvr, n, &ilo, &ihi, &a[a_offset], lda, &b[
00475             b_offset], ldb, &alphar[1], &alphai[1], &beta[1], &vl[vl_offset], 
00476             ldvl, &vr[vr_offset], ldvr, &work[iwrk], &i__1, &ierr);
00477     if (ierr != 0) {
00478         if (ierr > 0 && ierr <= *n) {
00479             *info = ierr;
00480         } else if (ierr > *n && ierr <= *n << 1) {
00481             *info = ierr - *n;
00482         } else {
00483             *info = *n + 1;
00484         }
00485         goto L110;
00486     }
00487 
00488 /*     Compute Eigenvectors */
00489 /*     (Workspace: need 6*N) */
00490 
00491     if (ilv) {
00492         if (ilvl) {
00493             if (ilvr) {
00494                 *(unsigned char *)chtemp = 'B';
00495             } else {
00496                 *(unsigned char *)chtemp = 'L';
00497             }
00498         } else {
00499             *(unsigned char *)chtemp = 'R';
00500         }
00501         dtgevc_(chtemp, "B", ldumma, n, &a[a_offset], lda, &b[b_offset], ldb, 
00502                 &vl[vl_offset], ldvl, &vr[vr_offset], ldvr, n, &in, &work[
00503                 iwrk], &ierr);
00504         if (ierr != 0) {
00505             *info = *n + 2;
00506             goto L110;
00507         }
00508 
00509 /*        Undo balancing on VL and VR and normalization */
00510 /*        (Workspace: none needed) */
00511 
00512         if (ilvl) {
00513             dggbak_("P", "L", n, &ilo, &ihi, &work[ileft], &work[iright], n, &
00514                     vl[vl_offset], ldvl, &ierr);
00515             i__1 = *n;
00516             for (jc = 1; jc <= i__1; ++jc) {
00517                 if (alphai[jc] < 0.) {
00518                     goto L50;
00519                 }
00520                 temp = 0.;
00521                 if (alphai[jc] == 0.) {
00522                     i__2 = *n;
00523                     for (jr = 1; jr <= i__2; ++jr) {
00524 /* Computing MAX */
00525                         d__2 = temp, d__3 = (d__1 = vl[jr + jc * vl_dim1], 
00526                                 abs(d__1));
00527                         temp = max(d__2,d__3);
00528 /* L10: */
00529                     }
00530                 } else {
00531                     i__2 = *n;
00532                     for (jr = 1; jr <= i__2; ++jr) {
00533 /* Computing MAX */
00534                         d__3 = temp, d__4 = (d__1 = vl[jr + jc * vl_dim1], 
00535                                 abs(d__1)) + (d__2 = vl[jr + (jc + 1) * 
00536                                 vl_dim1], abs(d__2));
00537                         temp = max(d__3,d__4);
00538 /* L20: */
00539                     }
00540                 }
00541                 if (temp < smlnum) {
00542                     goto L50;
00543                 }
00544                 temp = 1. / temp;
00545                 if (alphai[jc] == 0.) {
00546                     i__2 = *n;
00547                     for (jr = 1; jr <= i__2; ++jr) {
00548                         vl[jr + jc * vl_dim1] *= temp;
00549 /* L30: */
00550                     }
00551                 } else {
00552                     i__2 = *n;
00553                     for (jr = 1; jr <= i__2; ++jr) {
00554                         vl[jr + jc * vl_dim1] *= temp;
00555                         vl[jr + (jc + 1) * vl_dim1] *= temp;
00556 /* L40: */
00557                     }
00558                 }
00559 L50:
00560                 ;
00561             }
00562         }
00563         if (ilvr) {
00564             dggbak_("P", "R", n, &ilo, &ihi, &work[ileft], &work[iright], n, &
00565                     vr[vr_offset], ldvr, &ierr);
00566             i__1 = *n;
00567             for (jc = 1; jc <= i__1; ++jc) {
00568                 if (alphai[jc] < 0.) {
00569                     goto L100;
00570                 }
00571                 temp = 0.;
00572                 if (alphai[jc] == 0.) {
00573                     i__2 = *n;
00574                     for (jr = 1; jr <= i__2; ++jr) {
00575 /* Computing MAX */
00576                         d__2 = temp, d__3 = (d__1 = vr[jr + jc * vr_dim1], 
00577                                 abs(d__1));
00578                         temp = max(d__2,d__3);
00579 /* L60: */
00580                     }
00581                 } else {
00582                     i__2 = *n;
00583                     for (jr = 1; jr <= i__2; ++jr) {
00584 /* Computing MAX */
00585                         d__3 = temp, d__4 = (d__1 = vr[jr + jc * vr_dim1], 
00586                                 abs(d__1)) + (d__2 = vr[jr + (jc + 1) * 
00587                                 vr_dim1], abs(d__2));
00588                         temp = max(d__3,d__4);
00589 /* L70: */
00590                     }
00591                 }
00592                 if (temp < smlnum) {
00593                     goto L100;
00594                 }
00595                 temp = 1. / temp;
00596                 if (alphai[jc] == 0.) {
00597                     i__2 = *n;
00598                     for (jr = 1; jr <= i__2; ++jr) {
00599                         vr[jr + jc * vr_dim1] *= temp;
00600 /* L80: */
00601                     }
00602                 } else {
00603                     i__2 = *n;
00604                     for (jr = 1; jr <= i__2; ++jr) {
00605                         vr[jr + jc * vr_dim1] *= temp;
00606                         vr[jr + (jc + 1) * vr_dim1] *= temp;
00607 /* L90: */
00608                     }
00609                 }
00610 L100:
00611                 ;
00612             }
00613         }
00614 
00615 /*        End of eigenvector calculation */
00616 
00617     }
00618 
00619 /*     Undo scaling if necessary */
00620 
00621     if (ilascl) {
00622         dlascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphar[1], n, &
00623                 ierr);
00624         dlascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alphai[1], n, &
00625                 ierr);
00626     }
00627 
00628     if (ilbscl) {
00629         dlascl_("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, &
00630                 ierr);
00631     }
00632 
00633 L110:
00634 
00635     work[1] = (doublereal) maxwrk;
00636 
00637     return 0;
00638 
00639 /*     End of DGGEV */
00640 
00641 } /* dggev_ */


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