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


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