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


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