cggbak.c
Go to the documentation of this file.
00001 /* cggbak.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 /* Subroutine */ int cggbak_(char *job, char *side, integer *n, integer *ilo, 
00017         integer *ihi, real *lscale, real *rscale, integer *m, complex *v, 
00018         integer *ldv, integer *info)
00019 {
00020     /* System generated locals */
00021     integer v_dim1, v_offset, i__1;
00022 
00023     /* Local variables */
00024     integer i__, k;
00025     extern logical lsame_(char *, char *);
00026     extern /* Subroutine */ int cswap_(integer *, complex *, integer *, 
00027             complex *, integer *);
00028     logical leftv;
00029     extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer 
00030             *), xerbla_(char *, integer *);
00031     logical rightv;
00032 
00033 
00034 /*  -- LAPACK routine (version 3.2) -- */
00035 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00036 /*     November 2006 */
00037 
00038 /*     .. Scalar Arguments .. */
00039 /*     .. */
00040 /*     .. Array Arguments .. */
00041 /*     .. */
00042 
00043 /*  Purpose */
00044 /*  ======= */
00045 
00046 /*  CGGBAK forms the right or left eigenvectors of a complex generalized */
00047 /*  eigenvalue problem A*x = lambda*B*x, by backward transformation on */
00048 /*  the computed eigenvectors of the balanced pair of matrices output by */
00049 /*  CGGBAL. */
00050 
00051 /*  Arguments */
00052 /*  ========= */
00053 
00054 /*  JOB     (input) CHARACTER*1 */
00055 /*          Specifies the type of backward transformation required: */
00056 /*          = 'N':  do nothing, return immediately; */
00057 /*          = 'P':  do backward transformation for permutation only; */
00058 /*          = 'S':  do backward transformation for scaling only; */
00059 /*          = 'B':  do backward transformations for both permutation and */
00060 /*                  scaling. */
00061 /*          JOB must be the same as the argument JOB supplied to CGGBAL. */
00062 
00063 /*  SIDE    (input) CHARACTER*1 */
00064 /*          = 'R':  V contains right eigenvectors; */
00065 /*          = 'L':  V contains left eigenvectors. */
00066 
00067 /*  N       (input) INTEGER */
00068 /*          The number of rows of the matrix V.  N >= 0. */
00069 
00070 /*  ILO     (input) INTEGER */
00071 /*  IHI     (input) INTEGER */
00072 /*          The integers ILO and IHI determined by CGGBAL. */
00073 /*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
00074 
00075 /*  LSCALE  (input) REAL array, dimension (N) */
00076 /*          Details of the permutations and/or scaling factors applied */
00077 /*          to the left side of A and B, as returned by CGGBAL. */
00078 
00079 /*  RSCALE  (input) REAL array, dimension (N) */
00080 /*          Details of the permutations and/or scaling factors applied */
00081 /*          to the right side of A and B, as returned by CGGBAL. */
00082 
00083 /*  M       (input) INTEGER */
00084 /*          The number of columns of the matrix V.  M >= 0. */
00085 
00086 /*  V       (input/output) COMPLEX array, dimension (LDV,M) */
00087 /*          On entry, the matrix of right or left eigenvectors to be */
00088 /*          transformed, as returned by CTGEVC. */
00089 /*          On exit, V is overwritten by the transformed eigenvectors. */
00090 
00091 /*  LDV     (input) INTEGER */
00092 /*          The leading dimension of the matrix V. LDV >= max(1,N). */
00093 
00094 /*  INFO    (output) INTEGER */
00095 /*          = 0:  successful exit. */
00096 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00097 
00098 /*  Further Details */
00099 /*  =============== */
00100 
00101 /*  See R.C. Ward, Balancing the generalized eigenvalue problem, */
00102 /*                 SIAM J. Sci. Stat. Comp. 2 (1981), 141-152. */
00103 
00104 /*  ===================================================================== */
00105 
00106 /*     .. Local Scalars .. */
00107 /*     .. */
00108 /*     .. External Functions .. */
00109 /*     .. */
00110 /*     .. External Subroutines .. */
00111 /*     .. */
00112 /*     .. Intrinsic Functions .. */
00113 /*     .. */
00114 /*     .. Executable Statements .. */
00115 
00116 /*     Test the input parameters */
00117 
00118     /* Parameter adjustments */
00119     --lscale;
00120     --rscale;
00121     v_dim1 = *ldv;
00122     v_offset = 1 + v_dim1;
00123     v -= v_offset;
00124 
00125     /* Function Body */
00126     rightv = lsame_(side, "R");
00127     leftv = lsame_(side, "L");
00128 
00129     *info = 0;
00130     if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") 
00131             && ! lsame_(job, "B")) {
00132         *info = -1;
00133     } else if (! rightv && ! leftv) {
00134         *info = -2;
00135     } else if (*n < 0) {
00136         *info = -3;
00137     } else if (*ilo < 1) {
00138         *info = -4;
00139     } else if (*n == 0 && *ihi == 0 && *ilo != 1) {
00140         *info = -4;
00141     } else if (*n > 0 && (*ihi < *ilo || *ihi > max(1,*n))) {
00142         *info = -5;
00143     } else if (*n == 0 && *ilo == 1 && *ihi != 0) {
00144         *info = -5;
00145     } else if (*m < 0) {
00146         *info = -8;
00147     } else if (*ldv < max(1,*n)) {
00148         *info = -10;
00149     }
00150     if (*info != 0) {
00151         i__1 = -(*info);
00152         xerbla_("CGGBAK", &i__1);
00153         return 0;
00154     }
00155 
00156 /*     Quick return if possible */
00157 
00158     if (*n == 0) {
00159         return 0;
00160     }
00161     if (*m == 0) {
00162         return 0;
00163     }
00164     if (lsame_(job, "N")) {
00165         return 0;
00166     }
00167 
00168     if (*ilo == *ihi) {
00169         goto L30;
00170     }
00171 
00172 /*     Backward balance */
00173 
00174     if (lsame_(job, "S") || lsame_(job, "B")) {
00175 
00176 /*        Backward transformation on right eigenvectors */
00177 
00178         if (rightv) {
00179             i__1 = *ihi;
00180             for (i__ = *ilo; i__ <= i__1; ++i__) {
00181                 csscal_(m, &rscale[i__], &v[i__ + v_dim1], ldv);
00182 /* L10: */
00183             }
00184         }
00185 
00186 /*        Backward transformation on left eigenvectors */
00187 
00188         if (leftv) {
00189             i__1 = *ihi;
00190             for (i__ = *ilo; i__ <= i__1; ++i__) {
00191                 csscal_(m, &lscale[i__], &v[i__ + v_dim1], ldv);
00192 /* L20: */
00193             }
00194         }
00195     }
00196 
00197 /*     Backward permutation */
00198 
00199 L30:
00200     if (lsame_(job, "P") || lsame_(job, "B")) {
00201 
00202 /*        Backward permutation on right eigenvectors */
00203 
00204         if (rightv) {
00205             if (*ilo == 1) {
00206                 goto L50;
00207             }
00208             for (i__ = *ilo - 1; i__ >= 1; --i__) {
00209                 k = rscale[i__];
00210                 if (k == i__) {
00211                     goto L40;
00212                 }
00213                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00214 L40:
00215                 ;
00216             }
00217 
00218 L50:
00219             if (*ihi == *n) {
00220                 goto L70;
00221             }
00222             i__1 = *n;
00223             for (i__ = *ihi + 1; i__ <= i__1; ++i__) {
00224                 k = rscale[i__];
00225                 if (k == i__) {
00226                     goto L60;
00227                 }
00228                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00229 L60:
00230                 ;
00231             }
00232         }
00233 
00234 /*        Backward permutation on left eigenvectors */
00235 
00236 L70:
00237         if (leftv) {
00238             if (*ilo == 1) {
00239                 goto L90;
00240             }
00241             for (i__ = *ilo - 1; i__ >= 1; --i__) {
00242                 k = lscale[i__];
00243                 if (k == i__) {
00244                     goto L80;
00245                 }
00246                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00247 L80:
00248                 ;
00249             }
00250 
00251 L90:
00252             if (*ihi == *n) {
00253                 goto L110;
00254             }
00255             i__1 = *n;
00256             for (i__ = *ihi + 1; i__ <= i__1; ++i__) {
00257                 k = lscale[i__];
00258                 if (k == i__) {
00259                     goto L100;
00260                 }
00261                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00262 L100:
00263                 ;
00264             }
00265         }
00266     }
00267 
00268 L110:
00269 
00270     return 0;
00271 
00272 /*     End of CGGBAK */
00273 
00274 } /* cggbak_ */


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