cgebak.c
Go to the documentation of this file.
00001 /* cgebak.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 cgebak_(char *job, char *side, integer *n, integer *ilo, 
00017         integer *ihi, real *scale, integer *m, complex *v, integer *ldv, 
00018         integer *info)
00019 {
00020     /* System generated locals */
00021     integer v_dim1, v_offset, i__1;
00022 
00023     /* Local variables */
00024     integer i__, k;
00025     real s;
00026     integer ii;
00027     extern logical lsame_(char *, char *);
00028     extern /* Subroutine */ int cswap_(integer *, complex *, integer *, 
00029             complex *, integer *);
00030     logical leftv;
00031     extern /* Subroutine */ int csscal_(integer *, real *, complex *, integer 
00032             *), xerbla_(char *, integer *);
00033     logical rightv;
00034 
00035 
00036 /*  -- LAPACK routine (version 3.2) -- */
00037 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00038 /*     November 2006 */
00039 
00040 /*     .. Scalar Arguments .. */
00041 /*     .. */
00042 /*     .. Array Arguments .. */
00043 /*     .. */
00044 
00045 /*  Purpose */
00046 /*  ======= */
00047 
00048 /*  CGEBAK forms the right or left eigenvectors of a complex general */
00049 /*  matrix by backward transformation on the computed eigenvectors of the */
00050 /*  balanced matrix output by CGEBAL. */
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 CGEBAL. */
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 CGEBAL. */
00074 /*          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0. */
00075 
00076 /*  SCALE   (input) REAL array, dimension (N) */
00077 /*          Details of the permutation and scaling factors, as returned */
00078 /*          by CGEBAL. */
00079 
00080 /*  M       (input) INTEGER */
00081 /*          The number of columns of the matrix V.  M >= 0. */
00082 
00083 /*  V       (input/output) COMPLEX array, dimension (LDV,M) */
00084 /*          On entry, the matrix of right or left eigenvectors to be */
00085 /*          transformed, as returned by CHSEIN or CTREVC. */
00086 /*          On exit, V is overwritten by the transformed eigenvectors. */
00087 
00088 /*  LDV     (input) INTEGER */
00089 /*          The leading dimension of the array V. LDV >= max(1,N). */
00090 
00091 /*  INFO    (output) INTEGER */
00092 /*          = 0:  successful exit */
00093 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00094 
00095 /*  ===================================================================== */
00096 
00097 /*     .. Parameters .. */
00098 /*     .. */
00099 /*     .. Local Scalars .. */
00100 /*     .. */
00101 /*     .. External Functions .. */
00102 /*     .. */
00103 /*     .. External Subroutines .. */
00104 /*     .. */
00105 /*     .. Intrinsic Functions .. */
00106 /*     .. */
00107 /*     .. Executable Statements .. */
00108 
00109 /*     Decode and Test the input parameters */
00110 
00111     /* Parameter adjustments */
00112     --scale;
00113     v_dim1 = *ldv;
00114     v_offset = 1 + v_dim1;
00115     v -= v_offset;
00116 
00117     /* Function Body */
00118     rightv = lsame_(side, "R");
00119     leftv = lsame_(side, "L");
00120 
00121     *info = 0;
00122     if (! lsame_(job, "N") && ! lsame_(job, "P") && ! lsame_(job, "S") 
00123             && ! lsame_(job, "B")) {
00124         *info = -1;
00125     } else if (! rightv && ! leftv) {
00126         *info = -2;
00127     } else if (*n < 0) {
00128         *info = -3;
00129     } else if (*ilo < 1 || *ilo > max(1,*n)) {
00130         *info = -4;
00131     } else if (*ihi < min(*ilo,*n) || *ihi > *n) {
00132         *info = -5;
00133     } else if (*m < 0) {
00134         *info = -7;
00135     } else if (*ldv < max(1,*n)) {
00136         *info = -9;
00137     }
00138     if (*info != 0) {
00139         i__1 = -(*info);
00140         xerbla_("CGEBAK", &i__1);
00141         return 0;
00142     }
00143 
00144 /*     Quick return if possible */
00145 
00146     if (*n == 0) {
00147         return 0;
00148     }
00149     if (*m == 0) {
00150         return 0;
00151     }
00152     if (lsame_(job, "N")) {
00153         return 0;
00154     }
00155 
00156     if (*ilo == *ihi) {
00157         goto L30;
00158     }
00159 
00160 /*     Backward balance */
00161 
00162     if (lsame_(job, "S") || lsame_(job, "B")) {
00163 
00164         if (rightv) {
00165             i__1 = *ihi;
00166             for (i__ = *ilo; i__ <= i__1; ++i__) {
00167                 s = scale[i__];
00168                 csscal_(m, &s, &v[i__ + v_dim1], ldv);
00169 /* L10: */
00170             }
00171         }
00172 
00173         if (leftv) {
00174             i__1 = *ihi;
00175             for (i__ = *ilo; i__ <= i__1; ++i__) {
00176                 s = 1.f / scale[i__];
00177                 csscal_(m, &s, &v[i__ + v_dim1], ldv);
00178 /* L20: */
00179             }
00180         }
00181 
00182     }
00183 
00184 /*     Backward permutation */
00185 
00186 /*     For  I = ILO-1 step -1 until 1, */
00187 /*              IHI+1 step 1 until N do -- */
00188 
00189 L30:
00190     if (lsame_(job, "P") || lsame_(job, "B")) {
00191         if (rightv) {
00192             i__1 = *n;
00193             for (ii = 1; ii <= i__1; ++ii) {
00194                 i__ = ii;
00195                 if (i__ >= *ilo && i__ <= *ihi) {
00196                     goto L40;
00197                 }
00198                 if (i__ < *ilo) {
00199                     i__ = *ilo - ii;
00200                 }
00201                 k = scale[i__];
00202                 if (k == i__) {
00203                     goto L40;
00204                 }
00205                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00206 L40:
00207                 ;
00208             }
00209         }
00210 
00211         if (leftv) {
00212             i__1 = *n;
00213             for (ii = 1; ii <= i__1; ++ii) {
00214                 i__ = ii;
00215                 if (i__ >= *ilo && i__ <= *ihi) {
00216                     goto L50;
00217                 }
00218                 if (i__ < *ilo) {
00219                     i__ = *ilo - ii;
00220                 }
00221                 k = scale[i__];
00222                 if (k == i__) {
00223                     goto L50;
00224                 }
00225                 cswap_(m, &v[i__ + v_dim1], ldv, &v[k + v_dim1], ldv);
00226 L50:
00227                 ;
00228             }
00229         }
00230     }
00231 
00232     return 0;
00233 
00234 /*     End of CGEBAK */
00235 
00236 } /* cgebak_ */


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