dgeesx.c
Go to the documentation of this file.
00001 /* dgeesx.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 
00022 /* Subroutine */ int dgeesx_(char *jobvs, char *sort, L_fp select, char *
00023         sense, integer *n, doublereal *a, integer *lda, integer *sdim, 
00024         doublereal *wr, doublereal *wi, doublereal *vs, integer *ldvs, 
00025         doublereal *rconde, doublereal *rcondv, doublereal *work, integer *
00026         lwork, integer *iwork, integer *liwork, logical *bwork, integer *info)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, vs_dim1, vs_offset, i__1, i__2, i__3;
00030 
00031     /* Builtin functions */
00032     double sqrt(doublereal);
00033 
00034     /* Local variables */
00035     integer i__, i1, i2, ip, ihi, ilo;
00036     doublereal dum[1], eps;
00037     integer ibal;
00038     doublereal anrm;
00039     integer ierr, itau, iwrk, lwrk, inxt, icond, ieval;
00040     extern logical lsame_(char *, char *);
00041     extern /* Subroutine */ int dcopy_(integer *, doublereal *, integer *, 
00042             doublereal *, integer *), dswap_(integer *, doublereal *, integer 
00043             *, doublereal *, integer *);
00044     logical cursl;
00045     integer liwrk;
00046     extern /* Subroutine */ int dlabad_(doublereal *, doublereal *), dgebak_(
00047             char *, char *, integer *, integer *, integer *, doublereal *, 
00048             integer *, doublereal *, integer *, integer *), 
00049             dgebal_(char *, integer *, doublereal *, integer *, integer *, 
00050             integer *, doublereal *, integer *);
00051     logical lst2sl, scalea;
00052     extern doublereal dlamch_(char *);
00053     doublereal cscale;
00054     extern doublereal dlange_(char *, integer *, integer *, doublereal *, 
00055             integer *, doublereal *);
00056     extern /* Subroutine */ int dgehrd_(integer *, integer *, integer *, 
00057             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00058             integer *), dlascl_(char *, integer *, integer *, doublereal *, 
00059             doublereal *, integer *, integer *, doublereal *, integer *, 
00060             integer *), dlacpy_(char *, integer *, integer *, 
00061             doublereal *, integer *, doublereal *, integer *), 
00062             xerbla_(char *, integer *);
00063     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00064             integer *, integer *);
00065     doublereal bignum;
00066     extern /* Subroutine */ int dorghr_(integer *, integer *, integer *, 
00067             doublereal *, integer *, doublereal *, doublereal *, integer *, 
00068             integer *), dhseqr_(char *, char *, integer *, integer *, integer 
00069             *, doublereal *, integer *, doublereal *, doublereal *, 
00070             doublereal *, integer *, doublereal *, integer *, integer *);
00071     logical wantsb;
00072     extern /* Subroutine */ int dtrsen_(char *, char *, logical *, integer *, 
00073             doublereal *, integer *, doublereal *, integer *, doublereal *, 
00074             doublereal *, integer *, doublereal *, doublereal *, doublereal *, 
00075              integer *, integer *, integer *, integer *);
00076     logical wantse, lastsl;
00077     integer minwrk, maxwrk;
00078     logical wantsn;
00079     doublereal smlnum;
00080     integer hswork;
00081     logical wantst, lquery, wantsv, wantvs;
00082 
00083 
00084 /*  -- LAPACK driver routine (version 3.2) -- */
00085 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00086 /*     November 2006 */
00087 
00088 /*     .. Scalar Arguments .. */
00089 /*     .. */
00090 /*     .. Array Arguments .. */
00091 /*     .. */
00092 /*     .. Function Arguments .. */
00093 /*     .. */
00094 
00095 /*  Purpose */
00096 /*  ======= */
00097 
00098 /*  DGEESX computes for an N-by-N real nonsymmetric matrix A, the */
00099 /*  eigenvalues, the real Schur form T, and, optionally, the matrix of */
00100 /*  Schur vectors Z.  This gives the Schur factorization A = Z*T*(Z**T). */
00101 
00102 /*  Optionally, it also orders the eigenvalues on the diagonal of the */
00103 /*  real Schur form so that selected eigenvalues are at the top left; */
00104 /*  computes a reciprocal condition number for the average of the */
00105 /*  selected eigenvalues (RCONDE); and computes a reciprocal condition */
00106 /*  number for the right invariant subspace corresponding to the */
00107 /*  selected eigenvalues (RCONDV).  The leading columns of Z form an */
00108 /*  orthonormal basis for this invariant subspace. */
00109 
00110 /*  For further explanation of the reciprocal condition numbers RCONDE */
00111 /*  and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where */
00112 /*  these quantities are called s and sep respectively). */
00113 
00114 /*  A real matrix is in real Schur form if it is upper quasi-triangular */
00115 /*  with 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in */
00116 /*  the form */
00117 /*            [  a  b  ] */
00118 /*            [  c  a  ] */
00119 
00120 /*  where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc). */
00121 
00122 /*  Arguments */
00123 /*  ========= */
00124 
00125 /*  JOBVS   (input) CHARACTER*1 */
00126 /*          = 'N': Schur vectors are not computed; */
00127 /*          = 'V': Schur vectors are computed. */
00128 
00129 /*  SORT    (input) CHARACTER*1 */
00130 /*          Specifies whether or not to order the eigenvalues on the */
00131 /*          diagonal of the Schur form. */
00132 /*          = 'N': Eigenvalues are not ordered; */
00133 /*          = 'S': Eigenvalues are ordered (see SELECT). */
00134 
00135 /*  SELECT  (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments */
00136 /*          SELECT must be declared EXTERNAL in the calling subroutine. */
00137 /*          If SORT = 'S', SELECT is used to select eigenvalues to sort */
00138 /*          to the top left of the Schur form. */
00139 /*          If SORT = 'N', SELECT is not referenced. */
00140 /*          An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if */
00141 /*          SELECT(WR(j),WI(j)) is true; i.e., if either one of a */
00142 /*          complex conjugate pair of eigenvalues is selected, then both */
00143 /*          are.  Note that a selected complex eigenvalue may no longer */
00144 /*          satisfy SELECT(WR(j),WI(j)) = .TRUE. after ordering, since */
00145 /*          ordering may change the value of complex eigenvalues */
00146 /*          (especially if the eigenvalue is ill-conditioned); in this */
00147 /*          case INFO may be set to N+3 (see INFO below). */
00148 
00149 /*  SENSE   (input) CHARACTER*1 */
00150 /*          Determines which reciprocal condition numbers are computed. */
00151 /*          = 'N': None are computed; */
00152 /*          = 'E': Computed for average of selected eigenvalues only; */
00153 /*          = 'V': Computed for selected right invariant subspace only; */
00154 /*          = 'B': Computed for both. */
00155 /*          If SENSE = 'E', 'V' or 'B', SORT must equal 'S'. */
00156 
00157 /*  N       (input) INTEGER */
00158 /*          The order of the matrix A. N >= 0. */
00159 
00160 /*  A       (input/output) DOUBLE PRECISION array, dimension (LDA, N) */
00161 /*          On entry, the N-by-N matrix A. */
00162 /*          On exit, A is overwritten by its real Schur form T. */
00163 
00164 /*  LDA     (input) INTEGER */
00165 /*          The leading dimension of the array A.  LDA >= max(1,N). */
00166 
00167 /*  SDIM    (output) INTEGER */
00168 /*          If SORT = 'N', SDIM = 0. */
00169 /*          If SORT = 'S', SDIM = number of eigenvalues (after sorting) */
00170 /*                         for which SELECT is true. (Complex conjugate */
00171 /*                         pairs for which SELECT is true for either */
00172 /*                         eigenvalue count as 2.) */
00173 
00174 /*  WR      (output) DOUBLE PRECISION array, dimension (N) */
00175 /*  WI      (output) DOUBLE PRECISION array, dimension (N) */
00176 /*          WR and WI contain the real and imaginary parts, respectively, */
00177 /*          of the computed eigenvalues, in the same order that they */
00178 /*          appear on the diagonal of the output Schur form T.  Complex */
00179 /*          conjugate pairs of eigenvalues appear consecutively with the */
00180 /*          eigenvalue having the positive imaginary part first. */
00181 
00182 /*  VS      (output) DOUBLE PRECISION array, dimension (LDVS,N) */
00183 /*          If JOBVS = 'V', VS contains the orthogonal matrix Z of Schur */
00184 /*          vectors. */
00185 /*          If JOBVS = 'N', VS is not referenced. */
00186 
00187 /*  LDVS    (input) INTEGER */
00188 /*          The leading dimension of the array VS.  LDVS >= 1, and if */
00189 /*          JOBVS = 'V', LDVS >= N. */
00190 
00191 /*  RCONDE  (output) DOUBLE PRECISION */
00192 /*          If SENSE = 'E' or 'B', RCONDE contains the reciprocal */
00193 /*          condition number for the average of the selected eigenvalues. */
00194 /*          Not referenced if SENSE = 'N' or 'V'. */
00195 
00196 /*  RCONDV  (output) DOUBLE PRECISION */
00197 /*          If SENSE = 'V' or 'B', RCONDV contains the reciprocal */
00198 /*          condition number for the selected right invariant subspace. */
00199 /*          Not referenced if SENSE = 'N' or 'E'. */
00200 
00201 /*  WORK    (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
00202 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00203 
00204 /*  LWORK   (input) INTEGER */
00205 /*          The dimension of the array WORK.  LWORK >= max(1,3*N). */
00206 /*          Also, if SENSE = 'E' or 'V' or 'B', */
00207 /*          LWORK >= N+2*SDIM*(N-SDIM), where SDIM is the number of */
00208 /*          selected eigenvalues computed by this routine.  Note that */
00209 /*          N+2*SDIM*(N-SDIM) <= N+N*N/2. Note also that an error is only */
00210 /*          returned if LWORK < max(1,3*N), but if SENSE = 'E' or 'V' or */
00211 /*          'B' this may not be large enough. */
00212 /*          For good performance, LWORK must generally be larger. */
00213 
00214 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00215 /*          only calculates upper bounds on the optimal sizes of the */
00216 /*          arrays WORK and IWORK, returns these values as the first */
00217 /*          entries of the WORK and IWORK arrays, and no error messages */
00218 /*          related to LWORK or LIWORK are issued by XERBLA. */
00219 
00220 /*  IWORK   (workspace/output) INTEGER array, dimension (MAX(1,LIWORK)) */
00221 /*          On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK. */
00222 
00223 /*  LIWORK  (input) INTEGER */
00224 /*          The dimension of the array IWORK. */
00225 /*          LIWORK >= 1; if SENSE = 'V' or 'B', LIWORK >= SDIM*(N-SDIM). */
00226 /*          Note that SDIM*(N-SDIM) <= N*N/4. Note also that an error is */
00227 /*          only returned if LIWORK < 1, but if SENSE = 'V' or 'B' this */
00228 /*          may not be large enough. */
00229 
00230 /*          If LIWORK = -1, then a workspace query is assumed; the */
00231 /*          routine only calculates upper bounds on the optimal sizes of */
00232 /*          the arrays WORK and IWORK, returns these values as the first */
00233 /*          entries of the WORK and IWORK arrays, and no error messages */
00234 /*          related to LWORK or LIWORK are issued by XERBLA. */
00235 
00236 /*  BWORK   (workspace) LOGICAL array, dimension (N) */
00237 /*          Not referenced if SORT = 'N'. */
00238 
00239 /*  INFO    (output) INTEGER */
00240 /*          = 0: successful exit */
00241 /*          < 0: if INFO = -i, the i-th argument had an illegal value. */
00242 /*          > 0: if INFO = i, and i is */
00243 /*             <= N: the QR algorithm failed to compute all the */
00244 /*                   eigenvalues; elements 1:ILO-1 and i+1:N of WR and WI */
00245 /*                   contain those eigenvalues which have converged; if */
00246 /*                   JOBVS = 'V', VS contains the transformation which */
00247 /*                   reduces A to its partially converged Schur form. */
00248 /*             = N+1: the eigenvalues could not be reordered because some */
00249 /*                   eigenvalues were too close to separate (the problem */
00250 /*                   is very ill-conditioned); */
00251 /*             = N+2: after reordering, roundoff changed values of some */
00252 /*                   complex eigenvalues so that leading eigenvalues in */
00253 /*                   the Schur form no longer satisfy SELECT=.TRUE.  This */
00254 /*                   could also be caused by underflow due to scaling. */
00255 
00256 /*  ===================================================================== */
00257 
00258 /*     .. Parameters .. */
00259 /*     .. */
00260 /*     .. Local Scalars .. */
00261 /*     .. */
00262 /*     .. Local Arrays .. */
00263 /*     .. */
00264 /*     .. External Subroutines .. */
00265 /*     .. */
00266 /*     .. External Functions .. */
00267 /*     .. */
00268 /*     .. Intrinsic Functions .. */
00269 /*     .. */
00270 /*     .. Executable Statements .. */
00271 
00272 /*     Test the input arguments */
00273 
00274     /* Parameter adjustments */
00275     a_dim1 = *lda;
00276     a_offset = 1 + a_dim1;
00277     a -= a_offset;
00278     --wr;
00279     --wi;
00280     vs_dim1 = *ldvs;
00281     vs_offset = 1 + vs_dim1;
00282     vs -= vs_offset;
00283     --work;
00284     --iwork;
00285     --bwork;
00286 
00287     /* Function Body */
00288     *info = 0;
00289     wantvs = lsame_(jobvs, "V");
00290     wantst = lsame_(sort, "S");
00291     wantsn = lsame_(sense, "N");
00292     wantse = lsame_(sense, "E");
00293     wantsv = lsame_(sense, "V");
00294     wantsb = lsame_(sense, "B");
00295     lquery = *lwork == -1 || *liwork == -1;
00296     if (! wantvs && ! lsame_(jobvs, "N")) {
00297         *info = -1;
00298     } else if (! wantst && ! lsame_(sort, "N")) {
00299         *info = -2;
00300     } else if (! (wantsn || wantse || wantsv || wantsb) || ! wantst && ! 
00301             wantsn) {
00302         *info = -4;
00303     } else if (*n < 0) {
00304         *info = -5;
00305     } else if (*lda < max(1,*n)) {
00306         *info = -7;
00307     } else if (*ldvs < 1 || wantvs && *ldvs < *n) {
00308         *info = -12;
00309     }
00310 
00311 /*     Compute workspace */
00312 /*      (Note: Comments in the code beginning "RWorkspace:" describe the */
00313 /*       minimal amount of real workspace needed at that point in the */
00314 /*       code, as well as the preferred amount for good performance. */
00315 /*       IWorkspace refers to integer workspace. */
00316 /*       NB refers to the optimal block size for the immediately */
00317 /*       following subroutine, as returned by ILAENV. */
00318 /*       HSWORK refers to the workspace preferred by DHSEQR, as */
00319 /*       calculated below. HSWORK is computed assuming ILO=1 and IHI=N, */
00320 /*       the worst case. */
00321 /*       If SENSE = 'E', 'V' or 'B', then the amount of workspace needed */
00322 /*       depends on SDIM, which is computed by the routine DTRSEN later */
00323 /*       in the code.) */
00324 
00325     if (*info == 0) {
00326         liwrk = 1;
00327         if (*n == 0) {
00328             minwrk = 1;
00329             lwrk = 1;
00330         } else {
00331             maxwrk = (*n << 1) + *n * ilaenv_(&c__1, "DGEHRD", " ", n, &c__1, 
00332                     n, &c__0);
00333             minwrk = *n * 3;
00334 
00335             dhseqr_("S", jobvs, n, &c__1, n, &a[a_offset], lda, &wr[1], &wi[1]
00336 , &vs[vs_offset], ldvs, &work[1], &c_n1, &ieval);
00337             hswork = (integer) work[1];
00338 
00339             if (! wantvs) {
00340 /* Computing MAX */
00341                 i__1 = maxwrk, i__2 = *n + hswork;
00342                 maxwrk = max(i__1,i__2);
00343             } else {
00344 /* Computing MAX */
00345                 i__1 = maxwrk, i__2 = (*n << 1) + (*n - 1) * ilaenv_(&c__1, 
00346                         "DORGHR", " ", n, &c__1, n, &c_n1);
00347                 maxwrk = max(i__1,i__2);
00348 /* Computing MAX */
00349                 i__1 = maxwrk, i__2 = *n + hswork;
00350                 maxwrk = max(i__1,i__2);
00351             }
00352             lwrk = maxwrk;
00353             if (! wantsn) {
00354 /* Computing MAX */
00355                 i__1 = lwrk, i__2 = *n + *n * *n / 2;
00356                 lwrk = max(i__1,i__2);
00357             }
00358             if (wantsv || wantsb) {
00359                 liwrk = *n * *n / 4;
00360             }
00361         }
00362         iwork[1] = liwrk;
00363         work[1] = (doublereal) lwrk;
00364 
00365         if (*lwork < minwrk && ! lquery) {
00366             *info = -16;
00367         } else if (*liwork < 1 && ! lquery) {
00368             *info = -18;
00369         }
00370     }
00371 
00372     if (*info != 0) {
00373         i__1 = -(*info);
00374         xerbla_("DGEESX", &i__1);
00375         return 0;
00376     }
00377 
00378 /*     Quick return if possible */
00379 
00380     if (*n == 0) {
00381         *sdim = 0;
00382         return 0;
00383     }
00384 
00385 /*     Get machine constants */
00386 
00387     eps = dlamch_("P");
00388     smlnum = dlamch_("S");
00389     bignum = 1. / smlnum;
00390     dlabad_(&smlnum, &bignum);
00391     smlnum = sqrt(smlnum) / eps;
00392     bignum = 1. / smlnum;
00393 
00394 /*     Scale A if max element outside range [SMLNUM,BIGNUM] */
00395 
00396     anrm = dlange_("M", n, n, &a[a_offset], lda, dum);
00397     scalea = FALSE_;
00398     if (anrm > 0. && anrm < smlnum) {
00399         scalea = TRUE_;
00400         cscale = smlnum;
00401     } else if (anrm > bignum) {
00402         scalea = TRUE_;
00403         cscale = bignum;
00404     }
00405     if (scalea) {
00406         dlascl_("G", &c__0, &c__0, &anrm, &cscale, n, n, &a[a_offset], lda, &
00407                 ierr);
00408     }
00409 
00410 /*     Permute the matrix to make it more nearly triangular */
00411 /*     (RWorkspace: need N) */
00412 
00413     ibal = 1;
00414     dgebal_("P", n, &a[a_offset], lda, &ilo, &ihi, &work[ibal], &ierr);
00415 
00416 /*     Reduce to upper Hessenberg form */
00417 /*     (RWorkspace: need 3*N, prefer 2*N+N*NB) */
00418 
00419     itau = *n + ibal;
00420     iwrk = *n + itau;
00421     i__1 = *lwork - iwrk + 1;
00422     dgehrd_(n, &ilo, &ihi, &a[a_offset], lda, &work[itau], &work[iwrk], &i__1, 
00423              &ierr);
00424 
00425     if (wantvs) {
00426 
00427 /*        Copy Householder vectors to VS */
00428 
00429         dlacpy_("L", n, n, &a[a_offset], lda, &vs[vs_offset], ldvs)
00430                 ;
00431 
00432 /*        Generate orthogonal matrix in VS */
00433 /*        (RWorkspace: need 3*N-1, prefer 2*N+(N-1)*NB) */
00434 
00435         i__1 = *lwork - iwrk + 1;
00436         dorghr_(n, &ilo, &ihi, &vs[vs_offset], ldvs, &work[itau], &work[iwrk], 
00437                  &i__1, &ierr);
00438     }
00439 
00440     *sdim = 0;
00441 
00442 /*     Perform QR iteration, accumulating Schur vectors in VS if desired */
00443 /*     (RWorkspace: need N+1, prefer N+HSWORK (see comments) ) */
00444 
00445     iwrk = itau;
00446     i__1 = *lwork - iwrk + 1;
00447     dhseqr_("S", jobvs, n, &ilo, &ihi, &a[a_offset], lda, &wr[1], &wi[1], &vs[
00448             vs_offset], ldvs, &work[iwrk], &i__1, &ieval);
00449     if (ieval > 0) {
00450         *info = ieval;
00451     }
00452 
00453 /*     Sort eigenvalues if desired */
00454 
00455     if (wantst && *info == 0) {
00456         if (scalea) {
00457             dlascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wr[1], n, &
00458                     ierr);
00459             dlascl_("G", &c__0, &c__0, &cscale, &anrm, n, &c__1, &wi[1], n, &
00460                     ierr);
00461         }
00462         i__1 = *n;
00463         for (i__ = 1; i__ <= i__1; ++i__) {
00464             bwork[i__] = (*select)(&wr[i__], &wi[i__]);
00465 /* L10: */
00466         }
00467 
00468 /*        Reorder eigenvalues, transform Schur vectors, and compute */
00469 /*        reciprocal condition numbers */
00470 /*        (RWorkspace: if SENSE is not 'N', need N+2*SDIM*(N-SDIM) */
00471 /*                     otherwise, need N ) */
00472 /*        (IWorkspace: if SENSE is 'V' or 'B', need SDIM*(N-SDIM) */
00473 /*                     otherwise, need 0 ) */
00474 
00475         i__1 = *lwork - iwrk + 1;
00476         dtrsen_(sense, jobvs, &bwork[1], n, &a[a_offset], lda, &vs[vs_offset], 
00477                  ldvs, &wr[1], &wi[1], sdim, rconde, rcondv, &work[iwrk], &
00478                 i__1, &iwork[1], liwork, &icond);
00479         if (! wantsn) {
00480 /* Computing MAX */
00481             i__1 = maxwrk, i__2 = *n + (*sdim << 1) * (*n - *sdim);
00482             maxwrk = max(i__1,i__2);
00483         }
00484         if (icond == -15) {
00485 
00486 /*           Not enough real workspace */
00487 
00488             *info = -16;
00489         } else if (icond == -17) {
00490 
00491 /*           Not enough integer workspace */
00492 
00493             *info = -18;
00494         } else if (icond > 0) {
00495 
00496 /*           DTRSEN failed to reorder or to restore standard Schur form */
00497 
00498             *info = icond + *n;
00499         }
00500     }
00501 
00502     if (wantvs) {
00503 
00504 /*        Undo balancing */
00505 /*        (RWorkspace: need N) */
00506 
00507         dgebak_("P", "R", n, &ilo, &ihi, &work[ibal], n, &vs[vs_offset], ldvs, 
00508                  &ierr);
00509     }
00510 
00511     if (scalea) {
00512 
00513 /*        Undo scaling for the Schur form of A */
00514 
00515         dlascl_("H", &c__0, &c__0, &cscale, &anrm, n, n, &a[a_offset], lda, &
00516                 ierr);
00517         i__1 = *lda + 1;
00518         dcopy_(n, &a[a_offset], &i__1, &wr[1], &c__1);
00519         if ((wantsv || wantsb) && *info == 0) {
00520             dum[0] = *rcondv;
00521             dlascl_("G", &c__0, &c__0, &cscale, &anrm, &c__1, &c__1, dum, &
00522                     c__1, &ierr);
00523             *rcondv = dum[0];
00524         }
00525         if (cscale == smlnum) {
00526 
00527 /*           If scaling back towards underflow, adjust WI if an */
00528 /*           offdiagonal element of a 2-by-2 block in the Schur form */
00529 /*           underflows. */
00530 
00531             if (ieval > 0) {
00532                 i1 = ieval + 1;
00533                 i2 = ihi - 1;
00534                 i__1 = ilo - 1;
00535                 dlascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[
00536                         1], n, &ierr);
00537             } else if (wantst) {
00538                 i1 = 1;
00539                 i2 = *n - 1;
00540             } else {
00541                 i1 = ilo;
00542                 i2 = ihi - 1;
00543             }
00544             inxt = i1 - 1;
00545             i__1 = i2;
00546             for (i__ = i1; i__ <= i__1; ++i__) {
00547                 if (i__ < inxt) {
00548                     goto L20;
00549                 }
00550                 if (wi[i__] == 0.) {
00551                     inxt = i__ + 1;
00552                 } else {
00553                     if (a[i__ + 1 + i__ * a_dim1] == 0.) {
00554                         wi[i__] = 0.;
00555                         wi[i__ + 1] = 0.;
00556                     } else if (a[i__ + 1 + i__ * a_dim1] != 0. && a[i__ + (
00557                             i__ + 1) * a_dim1] == 0.) {
00558                         wi[i__] = 0.;
00559                         wi[i__ + 1] = 0.;
00560                         if (i__ > 1) {
00561                             i__2 = i__ - 1;
00562                             dswap_(&i__2, &a[i__ * a_dim1 + 1], &c__1, &a[(
00563                                     i__ + 1) * a_dim1 + 1], &c__1);
00564                         }
00565                         if (*n > i__ + 1) {
00566                             i__2 = *n - i__ - 1;
00567                             dswap_(&i__2, &a[i__ + (i__ + 2) * a_dim1], lda, &
00568                                     a[i__ + 1 + (i__ + 2) * a_dim1], lda);
00569                         }
00570                         dswap_(n, &vs[i__ * vs_dim1 + 1], &c__1, &vs[(i__ + 1)
00571                                  * vs_dim1 + 1], &c__1);
00572                         a[i__ + (i__ + 1) * a_dim1] = a[i__ + 1 + i__ * 
00573                                 a_dim1];
00574                         a[i__ + 1 + i__ * a_dim1] = 0.;
00575                     }
00576                     inxt = i__ + 2;
00577                 }
00578 L20:
00579                 ;
00580             }
00581         }
00582         i__1 = *n - ieval;
00583 /* Computing MAX */
00584         i__3 = *n - ieval;
00585         i__2 = max(i__3,1);
00586         dlascl_("G", &c__0, &c__0, &cscale, &anrm, &i__1, &c__1, &wi[ieval + 
00587                 1], &i__2, &ierr);
00588     }
00589 
00590     if (wantst && *info == 0) {
00591 
00592 /*        Check if reordering successful */
00593 
00594         lastsl = TRUE_;
00595         lst2sl = TRUE_;
00596         *sdim = 0;
00597         ip = 0;
00598         i__1 = *n;
00599         for (i__ = 1; i__ <= i__1; ++i__) {
00600             cursl = (*select)(&wr[i__], &wi[i__]);
00601             if (wi[i__] == 0.) {
00602                 if (cursl) {
00603                     ++(*sdim);
00604                 }
00605                 ip = 0;
00606                 if (cursl && ! lastsl) {
00607                     *info = *n + 2;
00608                 }
00609             } else {
00610                 if (ip == 1) {
00611 
00612 /*                 Last eigenvalue of conjugate pair */
00613 
00614                     cursl = cursl || lastsl;
00615                     lastsl = cursl;
00616                     if (cursl) {
00617                         *sdim += 2;
00618                     }
00619                     ip = -1;
00620                     if (cursl && ! lst2sl) {
00621                         *info = *n + 2;
00622                     }
00623                 } else {
00624 
00625 /*                 First eigenvalue of conjugate pair */
00626 
00627                     ip = 1;
00628                 }
00629             }
00630             lst2sl = lastsl;
00631             lastsl = cursl;
00632 /* L30: */
00633         }
00634     }
00635 
00636     work[1] = (doublereal) maxwrk;
00637     if (wantsv || wantsb) {
00638 /* Computing MAX */
00639         i__1 = 1, i__2 = *sdim * (*n - *sdim);
00640         iwork[1] = max(i__1,i__2);
00641     } else {
00642         iwork[1] = 1;
00643     }
00644 
00645     return 0;
00646 
00647 /*     End of DGEESX */
00648 
00649 } /* dgeesx_ */


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