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


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