zgges.c
Go to the documentation of this file.
00001 /* zgges.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 doublecomplex c_b1 = {0.,0.};
00019 static doublecomplex c_b2 = {1.,0.};
00020 static integer c__1 = 1;
00021 static integer c__0 = 0;
00022 static integer c_n1 = -1;
00023 
00024 /* Subroutine */ int zgges_(char *jobvsl, char *jobvsr, char *sort, L_fp 
00025         selctg, integer *n, doublecomplex *a, integer *lda, doublecomplex *b, 
00026         integer *ldb, integer *sdim, doublecomplex *alpha, doublecomplex *
00027         beta, doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, integer 
00028         *ldvsr, doublecomplex *work, integer *lwork, doublereal *rwork, 
00029         logical *bwork, integer *info)
00030 {
00031     /* System generated locals */
00032     integer a_dim1, a_offset, b_dim1, b_offset, vsl_dim1, vsl_offset, 
00033             vsr_dim1, vsr_offset, i__1, i__2;
00034 
00035     /* Builtin functions */
00036     double sqrt(doublereal);
00037 
00038     /* Local variables */
00039     integer i__;
00040     doublereal dif[2];
00041     integer ihi, ilo;
00042     doublereal eps, anrm, bnrm;
00043     integer idum[1], ierr, itau, iwrk;
00044     doublereal pvsl, pvsr;
00045     extern logical lsame_(char *, char *);
00046     integer ileft, icols;
00047     logical cursl, ilvsl, ilvsr;
00048     integer irwrk, irows;
00049     extern /* Subroutine */ int dlabad_(doublereal *, doublereal *);
00050     extern doublereal dlamch_(char *);
00051     extern /* Subroutine */ int zggbak_(char *, char *, integer *, integer *, 
00052             integer *, doublereal *, doublereal *, integer *, doublecomplex *, 
00053              integer *, integer *), zggbal_(char *, integer *, 
00054              doublecomplex *, integer *, doublecomplex *, integer *, integer *
00055 , integer *, doublereal *, doublereal *, doublereal *, integer *);
00056     logical ilascl, ilbscl;
00057     extern /* Subroutine */ int xerbla_(char *, integer *);
00058     extern integer ilaenv_(integer *, char *, char *, integer *, integer *, 
00059             integer *, integer *);
00060     extern doublereal zlange_(char *, integer *, integer *, doublecomplex *, 
00061             integer *, doublereal *);
00062     doublereal bignum;
00063     integer ijobvl, iright;
00064     extern /* Subroutine */ int zgghrd_(char *, char *, integer *, integer *, 
00065             integer *, doublecomplex *, integer *, doublecomplex *, integer *, 
00066              doublecomplex *, integer *, doublecomplex *, integer *, integer *
00067 ), zlascl_(char *, integer *, integer *, 
00068             doublereal *, doublereal *, integer *, integer *, doublecomplex *, 
00069              integer *, integer *);
00070     integer ijobvr;
00071     extern /* Subroutine */ int zgeqrf_(integer *, integer *, doublecomplex *, 
00072              integer *, doublecomplex *, doublecomplex *, integer *, integer *
00073 );
00074     doublereal anrmto;
00075     integer lwkmin;
00076     logical lastsl;
00077     doublereal bnrmto;
00078     extern /* Subroutine */ int zlacpy_(char *, integer *, integer *, 
00079             doublecomplex *, integer *, doublecomplex *, integer *), 
00080             zlaset_(char *, integer *, integer *, doublecomplex *, 
00081             doublecomplex *, doublecomplex *, integer *), zhgeqz_(
00082             char *, char *, char *, integer *, integer *, integer *, 
00083             doublecomplex *, integer *, doublecomplex *, integer *, 
00084             doublecomplex *, doublecomplex *, doublecomplex *, integer *, 
00085             doublecomplex *, integer *, doublecomplex *, integer *, 
00086             doublereal *, integer *), ztgsen_(integer 
00087             *, logical *, logical *, logical *, integer *, doublecomplex *, 
00088             integer *, doublecomplex *, integer *, doublecomplex *, 
00089             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00090             integer *, integer *, doublereal *, doublereal *, doublereal *, 
00091             doublecomplex *, integer *, integer *, integer *, integer *);
00092     doublereal smlnum;
00093     logical wantst, lquery;
00094     integer lwkopt;
00095     extern /* Subroutine */ int zungqr_(integer *, integer *, integer *, 
00096             doublecomplex *, integer *, doublecomplex *, doublecomplex *, 
00097             integer *, integer *), zunmqr_(char *, char *, integer *, integer 
00098             *, integer *, doublecomplex *, integer *, doublecomplex *, 
00099             doublecomplex *, integer *, doublecomplex *, integer *, integer *);
00100 
00101 
00102 /*  -- LAPACK driver routine (version 3.2) -- */
00103 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00104 /*     November 2006 */
00105 
00106 /*     .. Scalar Arguments .. */
00107 /*     .. */
00108 /*     .. Array Arguments .. */
00109 /*     .. */
00110 /*     .. Function Arguments .. */
00111 /*     .. */
00112 
00113 /*  Purpose */
00114 /*  ======= */
00115 
00116 /*  ZGGES computes for a pair of N-by-N complex nonsymmetric matrices */
00117 /*  (A,B), the generalized eigenvalues, the generalized complex Schur */
00118 /*  form (S, T), and optionally left and/or right Schur vectors (VSL */
00119 /*  and VSR). This gives the generalized Schur factorization */
00120 
00121 /*          (A,B) = ( (VSL)*S*(VSR)**H, (VSL)*T*(VSR)**H ) */
00122 
00123 /*  where (VSR)**H is the conjugate-transpose of VSR. */
00124 
00125 /*  Optionally, it also orders the eigenvalues so that a selected cluster */
00126 /*  of eigenvalues appears in the leading diagonal blocks of the upper */
00127 /*  triangular matrix S and the upper triangular matrix T. The leading */
00128 /*  columns of VSL and VSR then form an unitary basis for the */
00129 /*  corresponding left and right eigenspaces (deflating subspaces). */
00130 
00131 /*  (If only the generalized eigenvalues are needed, use the driver */
00132 /*  ZGGEV instead, which is faster.) */
00133 
00134 /*  A generalized eigenvalue for a pair of matrices (A,B) is a scalar w */
00135 /*  or a ratio alpha/beta = w, such that  A - w*B is singular.  It is */
00136 /*  usually represented as the pair (alpha,beta), as there is a */
00137 /*  reasonable interpretation for beta=0, and even for both being zero. */
00138 
00139 /*  A pair of matrices (S,T) is in generalized complex Schur form if S */
00140 /*  and T are upper triangular and, in addition, the diagonal elements */
00141 /*  of T are non-negative real numbers. */
00142 
00143 /*  Arguments */
00144 /*  ========= */
00145 
00146 /*  JOBVSL  (input) CHARACTER*1 */
00147 /*          = 'N':  do not compute the left Schur vectors; */
00148 /*          = 'V':  compute the left Schur vectors. */
00149 
00150 /*  JOBVSR  (input) CHARACTER*1 */
00151 /*          = 'N':  do not compute the right Schur vectors; */
00152 /*          = 'V':  compute the right Schur vectors. */
00153 
00154 /*  SORT    (input) CHARACTER*1 */
00155 /*          Specifies whether or not to order the eigenvalues on the */
00156 /*          diagonal of the generalized Schur form. */
00157 /*          = 'N':  Eigenvalues are not ordered; */
00158 /*          = 'S':  Eigenvalues are ordered (see SELCTG). */
00159 
00160 /*  SELCTG  (external procedure) LOGICAL FUNCTION of two COMPLEX*16 arguments */
00161 /*          SELCTG must be declared EXTERNAL in the calling subroutine. */
00162 /*          If SORT = 'N', SELCTG is not referenced. */
00163 /*          If SORT = 'S', SELCTG is used to select eigenvalues to sort */
00164 /*          to the top left of the Schur form. */
00165 /*          An eigenvalue ALPHA(j)/BETA(j) is selected if */
00166 /*          SELCTG(ALPHA(j),BETA(j)) is true. */
00167 
00168 /*          Note that a selected complex eigenvalue may no longer satisfy */
00169 /*          SELCTG(ALPHA(j),BETA(j)) = .TRUE. after ordering, since */
00170 /*          ordering may change the value of complex eigenvalues */
00171 /*          (especially if the eigenvalue is ill-conditioned), in this */
00172 /*          case INFO is set to N+2 (See INFO below). */
00173 
00174 /*  N       (input) INTEGER */
00175 /*          The order of the matrices A, B, VSL, and VSR.  N >= 0. */
00176 
00177 /*  A       (input/output) COMPLEX*16 array, dimension (LDA, N) */
00178 /*          On entry, the first of the pair of matrices. */
00179 /*          On exit, A has been overwritten by its generalized Schur */
00180 /*          form S. */
00181 
00182 /*  LDA     (input) INTEGER */
00183 /*          The leading dimension of A.  LDA >= max(1,N). */
00184 
00185 /*  B       (input/output) COMPLEX*16 array, dimension (LDB, N) */
00186 /*          On entry, the second of the pair of matrices. */
00187 /*          On exit, B has been overwritten by its generalized Schur */
00188 /*          form T. */
00189 
00190 /*  LDB     (input) INTEGER */
00191 /*          The leading dimension of B.  LDB >= max(1,N). */
00192 
00193 /*  SDIM    (output) INTEGER */
00194 /*          If SORT = 'N', SDIM = 0. */
00195 /*          If SORT = 'S', SDIM = number of eigenvalues (after sorting) */
00196 /*          for which SELCTG is true. */
00197 
00198 /*  ALPHA   (output) COMPLEX*16 array, dimension (N) */
00199 /*  BETA    (output) COMPLEX*16 array, dimension (N) */
00200 /*          On exit,  ALPHA(j)/BETA(j), j=1,...,N, will be the */
00201 /*          generalized eigenvalues.  ALPHA(j), j=1,...,N  and  BETA(j), */
00202 /*          j=1,...,N  are the diagonals of the complex Schur form (A,B) */
00203 /*          output by ZGGES. The  BETA(j) will be non-negative real. */
00204 
00205 /*          Note: the quotients ALPHA(j)/BETA(j) may easily over- or */
00206 /*          underflow, and BETA(j) may even be zero.  Thus, the user */
00207 /*          should avoid naively computing the ratio alpha/beta. */
00208 /*          However, ALPHA will be always less than and usually */
00209 /*          comparable with norm(A) in magnitude, and BETA always less */
00210 /*          than and usually comparable with norm(B). */
00211 
00212 /*  VSL     (output) COMPLEX*16 array, dimension (LDVSL,N) */
00213 /*          If JOBVSL = 'V', VSL will contain the left Schur vectors. */
00214 /*          Not referenced if JOBVSL = 'N'. */
00215 
00216 /*  LDVSL   (input) INTEGER */
00217 /*          The leading dimension of the matrix VSL. LDVSL >= 1, and */
00218 /*          if JOBVSL = 'V', LDVSL >= N. */
00219 
00220 /*  VSR     (output) COMPLEX*16 array, dimension (LDVSR,N) */
00221 /*          If JOBVSR = 'V', VSR will contain the right Schur vectors. */
00222 /*          Not referenced if JOBVSR = 'N'. */
00223 
00224 /*  LDVSR   (input) INTEGER */
00225 /*          The leading dimension of the matrix VSR. LDVSR >= 1, and */
00226 /*          if JOBVSR = 'V', LDVSR >= N. */
00227 
00228 /*  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK)) */
00229 /*          On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
00230 
00231 /*  LWORK   (input) INTEGER */
00232 /*          The dimension of the array WORK.  LWORK >= max(1,2*N). */
00233 /*          For good performance, LWORK must generally be larger. */
00234 
00235 /*          If LWORK = -1, then a workspace query is assumed; the routine */
00236 /*          only calculates the optimal size of the WORK array, returns */
00237 /*          this value as the first entry of the WORK array, and no error */
00238 /*          message related to LWORK is issued by XERBLA. */
00239 
00240 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (8*N) */
00241 
00242 /*  BWORK   (workspace) LOGICAL array, dimension (N) */
00243 /*          Not referenced if SORT = 'N'. */
00244 
00245 /*  INFO    (output) INTEGER */
00246 /*          = 0:  successful exit */
00247 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00248 /*          =1,...,N: */
00249 /*                The QZ iteration failed.  (A,B) are not in Schur */
00250 /*                form, but ALPHA(j) and BETA(j) should be correct for */
00251 /*                j=INFO+1,...,N. */
00252 /*          > N:  =N+1: other than QZ iteration failed in ZHGEQZ */
00253 /*                =N+2: after reordering, roundoff changed values of */
00254 /*                      some complex eigenvalues so that leading */
00255 /*                      eigenvalues in the Generalized Schur form no */
00256 /*                      longer satisfy SELCTG=.TRUE.  This could also */
00257 /*                      be caused due to scaling. */
00258 /*                =N+3: reordering falied in ZTGSEN. */
00259 
00260 /*  ===================================================================== */
00261 
00262 /*     .. Parameters .. */
00263 /*     .. */
00264 /*     .. Local Scalars .. */
00265 /*     .. */
00266 /*     .. Local Arrays .. */
00267 /*     .. */
00268 /*     .. External Subroutines .. */
00269 /*     .. */
00270 /*     .. External Functions .. */
00271 /*     .. */
00272 /*     .. Intrinsic Functions .. */
00273 /*     .. */
00274 /*     .. Executable Statements .. */
00275 
00276 /*     Decode the input arguments */
00277 
00278     /* Parameter adjustments */
00279     a_dim1 = *lda;
00280     a_offset = 1 + a_dim1;
00281     a -= a_offset;
00282     b_dim1 = *ldb;
00283     b_offset = 1 + b_dim1;
00284     b -= b_offset;
00285     --alpha;
00286     --beta;
00287     vsl_dim1 = *ldvsl;
00288     vsl_offset = 1 + vsl_dim1;
00289     vsl -= vsl_offset;
00290     vsr_dim1 = *ldvsr;
00291     vsr_offset = 1 + vsr_dim1;
00292     vsr -= vsr_offset;
00293     --work;
00294     --rwork;
00295     --bwork;
00296 
00297     /* Function Body */
00298     if (lsame_(jobvsl, "N")) {
00299         ijobvl = 1;
00300         ilvsl = FALSE_;
00301     } else if (lsame_(jobvsl, "V")) {
00302         ijobvl = 2;
00303         ilvsl = TRUE_;
00304     } else {
00305         ijobvl = -1;
00306         ilvsl = FALSE_;
00307     }
00308 
00309     if (lsame_(jobvsr, "N")) {
00310         ijobvr = 1;
00311         ilvsr = FALSE_;
00312     } else if (lsame_(jobvsr, "V")) {
00313         ijobvr = 2;
00314         ilvsr = TRUE_;
00315     } else {
00316         ijobvr = -1;
00317         ilvsr = FALSE_;
00318     }
00319 
00320     wantst = lsame_(sort, "S");
00321 
00322 /*     Test the input arguments */
00323 
00324     *info = 0;
00325     lquery = *lwork == -1;
00326     if (ijobvl <= 0) {
00327         *info = -1;
00328     } else if (ijobvr <= 0) {
00329         *info = -2;
00330     } else if (! wantst && ! lsame_(sort, "N")) {
00331         *info = -3;
00332     } else if (*n < 0) {
00333         *info = -5;
00334     } else if (*lda < max(1,*n)) {
00335         *info = -7;
00336     } else if (*ldb < max(1,*n)) {
00337         *info = -9;
00338     } else if (*ldvsl < 1 || ilvsl && *ldvsl < *n) {
00339         *info = -14;
00340     } else if (*ldvsr < 1 || ilvsr && *ldvsr < *n) {
00341         *info = -16;
00342     }
00343 
00344 /*     Compute workspace */
00345 /*      (Note: Comments in the code beginning "Workspace:" describe the */
00346 /*       minimal amount of workspace needed at that point in the code, */
00347 /*       as well as the preferred amount for good performance. */
00348 /*       NB refers to the optimal block size for the immediately */
00349 /*       following subroutine, as returned by ILAENV.) */
00350 
00351     if (*info == 0) {
00352 /* Computing MAX */
00353         i__1 = 1, i__2 = *n << 1;
00354         lwkmin = max(i__1,i__2);
00355 /* Computing MAX */
00356         i__1 = 1, i__2 = *n + *n * ilaenv_(&c__1, "ZGEQRF", " ", n, &c__1, n, 
00357                 &c__0);
00358         lwkopt = max(i__1,i__2);
00359 /* Computing MAX */
00360         i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "ZUNMQR", " ", n, &
00361                 c__1, n, &c_n1);
00362         lwkopt = max(i__1,i__2);
00363         if (ilvsl) {
00364 /* Computing MAX */
00365             i__1 = lwkopt, i__2 = *n + *n * ilaenv_(&c__1, "ZUNGQR", " ", n, &
00366                     c__1, n, &c_n1);
00367             lwkopt = max(i__1,i__2);
00368         }
00369         work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00370 
00371         if (*lwork < lwkmin && ! lquery) {
00372             *info = -18;
00373         }
00374     }
00375 
00376     if (*info != 0) {
00377         i__1 = -(*info);
00378         xerbla_("ZGGES ", &i__1);
00379         return 0;
00380     } else if (lquery) {
00381         return 0;
00382     }
00383 
00384 /*     Quick return if possible */
00385 
00386     if (*n == 0) {
00387         *sdim = 0;
00388         return 0;
00389     }
00390 
00391 /*     Get machine constants */
00392 
00393     eps = dlamch_("P");
00394     smlnum = dlamch_("S");
00395     bignum = 1. / smlnum;
00396     dlabad_(&smlnum, &bignum);
00397     smlnum = sqrt(smlnum) / eps;
00398     bignum = 1. / smlnum;
00399 
00400 /*     Scale A if max element outside range [SMLNUM,BIGNUM] */
00401 
00402     anrm = zlange_("M", n, n, &a[a_offset], lda, &rwork[1]);
00403     ilascl = FALSE_;
00404     if (anrm > 0. && anrm < smlnum) {
00405         anrmto = smlnum;
00406         ilascl = TRUE_;
00407     } else if (anrm > bignum) {
00408         anrmto = bignum;
00409         ilascl = TRUE_;
00410     }
00411 
00412     if (ilascl) {
00413         zlascl_("G", &c__0, &c__0, &anrm, &anrmto, n, n, &a[a_offset], lda, &
00414                 ierr);
00415     }
00416 
00417 /*     Scale B if max element outside range [SMLNUM,BIGNUM] */
00418 
00419     bnrm = zlange_("M", n, n, &b[b_offset], ldb, &rwork[1]);
00420     ilbscl = FALSE_;
00421     if (bnrm > 0. && bnrm < smlnum) {
00422         bnrmto = smlnum;
00423         ilbscl = TRUE_;
00424     } else if (bnrm > bignum) {
00425         bnrmto = bignum;
00426         ilbscl = TRUE_;
00427     }
00428 
00429     if (ilbscl) {
00430         zlascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, n, &b[b_offset], ldb, &
00431                 ierr);
00432     }
00433 
00434 /*     Permute the matrix to make it more nearly triangular */
00435 /*     (Real Workspace: need 6*N) */
00436 
00437     ileft = 1;
00438     iright = *n + 1;
00439     irwrk = iright + *n;
00440     zggbal_("P", n, &a[a_offset], lda, &b[b_offset], ldb, &ilo, &ihi, &rwork[
00441             ileft], &rwork[iright], &rwork[irwrk], &ierr);
00442 
00443 /*     Reduce B to triangular form (QR decomposition of B) */
00444 /*     (Complex Workspace: need N, prefer N*NB) */
00445 
00446     irows = ihi + 1 - ilo;
00447     icols = *n + 1 - ilo;
00448     itau = 1;
00449     iwrk = itau + irows;
00450     i__1 = *lwork + 1 - iwrk;
00451     zgeqrf_(&irows, &icols, &b[ilo + ilo * b_dim1], ldb, &work[itau], &work[
00452             iwrk], &i__1, &ierr);
00453 
00454 /*     Apply the orthogonal transformation to matrix A */
00455 /*     (Complex Workspace: need N, prefer N*NB) */
00456 
00457     i__1 = *lwork + 1 - iwrk;
00458     zunmqr_("L", "C", &irows, &icols, &irows, &b[ilo + ilo * b_dim1], ldb, &
00459             work[itau], &a[ilo + ilo * a_dim1], lda, &work[iwrk], &i__1, &
00460             ierr);
00461 
00462 /*     Initialize VSL */
00463 /*     (Complex Workspace: need N, prefer N*NB) */
00464 
00465     if (ilvsl) {
00466         zlaset_("Full", n, n, &c_b1, &c_b2, &vsl[vsl_offset], ldvsl);
00467         if (irows > 1) {
00468             i__1 = irows - 1;
00469             i__2 = irows - 1;
00470             zlacpy_("L", &i__1, &i__2, &b[ilo + 1 + ilo * b_dim1], ldb, &vsl[
00471                     ilo + 1 + ilo * vsl_dim1], ldvsl);
00472         }
00473         i__1 = *lwork + 1 - iwrk;
00474         zungqr_(&irows, &irows, &irows, &vsl[ilo + ilo * vsl_dim1], ldvsl, &
00475                 work[itau], &work[iwrk], &i__1, &ierr);
00476     }
00477 
00478 /*     Initialize VSR */
00479 
00480     if (ilvsr) {
00481         zlaset_("Full", n, n, &c_b1, &c_b2, &vsr[vsr_offset], ldvsr);
00482     }
00483 
00484 /*     Reduce to generalized Hessenberg form */
00485 /*     (Workspace: none needed) */
00486 
00487     zgghrd_(jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[b_offset], 
00488             ldb, &vsl[vsl_offset], ldvsl, &vsr[vsr_offset], ldvsr, &ierr);
00489 
00490     *sdim = 0;
00491 
00492 /*     Perform QZ algorithm, computing Schur vectors if desired */
00493 /*     (Complex Workspace: need N) */
00494 /*     (Real Workspace: need N) */
00495 
00496     iwrk = itau;
00497     i__1 = *lwork + 1 - iwrk;
00498     zhgeqz_("S", jobvsl, jobvsr, n, &ilo, &ihi, &a[a_offset], lda, &b[
00499             b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl, &
00500             vsr[vsr_offset], ldvsr, &work[iwrk], &i__1, &rwork[irwrk], &ierr);
00501     if (ierr != 0) {
00502         if (ierr > 0 && ierr <= *n) {
00503             *info = ierr;
00504         } else if (ierr > *n && ierr <= *n << 1) {
00505             *info = ierr - *n;
00506         } else {
00507             *info = *n + 1;
00508         }
00509         goto L30;
00510     }
00511 
00512 /*     Sort eigenvalues ALPHA/BETA if desired */
00513 /*     (Workspace: none needed) */
00514 
00515     if (wantst) {
00516 
00517 /*        Undo scaling on eigenvalues before selecting */
00518 
00519         if (ilascl) {
00520             zlascl_("G", &c__0, &c__0, &anrm, &anrmto, n, &c__1, &alpha[1], n, 
00521                      &ierr);
00522         }
00523         if (ilbscl) {
00524             zlascl_("G", &c__0, &c__0, &bnrm, &bnrmto, n, &c__1, &beta[1], n, 
00525                     &ierr);
00526         }
00527 
00528 /*        Select eigenvalues */
00529 
00530         i__1 = *n;
00531         for (i__ = 1; i__ <= i__1; ++i__) {
00532             bwork[i__] = (*selctg)(&alpha[i__], &beta[i__]);
00533 /* L10: */
00534         }
00535 
00536         i__1 = *lwork - iwrk + 1;
00537         ztgsen_(&c__0, &ilvsl, &ilvsr, &bwork[1], n, &a[a_offset], lda, &b[
00538                 b_offset], ldb, &alpha[1], &beta[1], &vsl[vsl_offset], ldvsl, 
00539                 &vsr[vsr_offset], ldvsr, sdim, &pvsl, &pvsr, dif, &work[iwrk], 
00540                  &i__1, idum, &c__1, &ierr);
00541         if (ierr == 1) {
00542             *info = *n + 3;
00543         }
00544 
00545     }
00546 
00547 /*     Apply back-permutation to VSL and VSR */
00548 /*     (Workspace: none needed) */
00549 
00550     if (ilvsl) {
00551         zggbak_("P", "L", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, &
00552                 vsl[vsl_offset], ldvsl, &ierr);
00553     }
00554     if (ilvsr) {
00555         zggbak_("P", "R", n, &ilo, &ihi, &rwork[ileft], &rwork[iright], n, &
00556                 vsr[vsr_offset], ldvsr, &ierr);
00557     }
00558 
00559 /*     Undo scaling */
00560 
00561     if (ilascl) {
00562         zlascl_("U", &c__0, &c__0, &anrmto, &anrm, n, n, &a[a_offset], lda, &
00563                 ierr);
00564         zlascl_("G", &c__0, &c__0, &anrmto, &anrm, n, &c__1, &alpha[1], n, &
00565                 ierr);
00566     }
00567 
00568     if (ilbscl) {
00569         zlascl_("U", &c__0, &c__0, &bnrmto, &bnrm, n, n, &b[b_offset], ldb, &
00570                 ierr);
00571         zlascl_("G", &c__0, &c__0, &bnrmto, &bnrm, n, &c__1, &beta[1], n, &
00572                 ierr);
00573     }
00574 
00575     if (wantst) {
00576 
00577 /*        Check if reordering is correct */
00578 
00579         lastsl = TRUE_;
00580         *sdim = 0;
00581         i__1 = *n;
00582         for (i__ = 1; i__ <= i__1; ++i__) {
00583             cursl = (*selctg)(&alpha[i__], &beta[i__]);
00584             if (cursl) {
00585                 ++(*sdim);
00586             }
00587             if (cursl && ! lastsl) {
00588                 *info = *n + 2;
00589             }
00590             lastsl = cursl;
00591 /* L20: */
00592         }
00593 
00594     }
00595 
00596 L30:
00597 
00598     work[1].r = (doublereal) lwkopt, work[1].i = 0.;
00599 
00600     return 0;
00601 
00602 /*     End of ZGGES */
00603 
00604 } /* zgges_ */


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