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


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