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


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