clascl.c
Go to the documentation of this file.
00001 /* clascl.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 clascl_(char *type__, integer *kl, integer *ku, real *
00017         cfrom, real *cto, integer *m, integer *n, complex *a, integer *lda, 
00018         integer *info)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2, i__3, i__4, i__5;
00022     complex q__1;
00023 
00024     /* Local variables */
00025     integer i__, j, k1, k2, k3, k4;
00026     real mul, cto1;
00027     logical done;
00028     real ctoc;
00029     extern logical lsame_(char *, char *);
00030     integer itype;
00031     real cfrom1;
00032     extern doublereal slamch_(char *);
00033     real cfromc;
00034     extern /* Subroutine */ int xerbla_(char *, integer *);
00035     real bignum;
00036     extern logical sisnan_(real *);
00037     real smlnum;
00038 
00039 
00040 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00041 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00042 /*     November 2006 */
00043 
00044 /*     .. Scalar Arguments .. */
00045 /*     .. */
00046 /*     .. Array Arguments .. */
00047 /*     .. */
00048 
00049 /*  Purpose */
00050 /*  ======= */
00051 
00052 /*  CLASCL multiplies the M by N complex matrix A by the real scalar */
00053 /*  CTO/CFROM.  This is done without over/underflow as long as the final */
00054 /*  result CTO*A(I,J)/CFROM does not over/underflow. TYPE specifies that */
00055 /*  A may be full, upper triangular, lower triangular, upper Hessenberg, */
00056 /*  or banded. */
00057 
00058 /*  Arguments */
00059 /*  ========= */
00060 
00061 /*  TYPE    (input) CHARACTER*1 */
00062 /*          TYPE indices the storage type of the input matrix. */
00063 /*          = 'G':  A is a full matrix. */
00064 /*          = 'L':  A is a lower triangular matrix. */
00065 /*          = 'U':  A is an upper triangular matrix. */
00066 /*          = 'H':  A is an upper Hessenberg matrix. */
00067 /*          = 'B':  A is a symmetric band matrix with lower bandwidth KL */
00068 /*                  and upper bandwidth KU and with the only the lower */
00069 /*                  half stored. */
00070 /*          = 'Q':  A is a symmetric band matrix with lower bandwidth KL */
00071 /*                  and upper bandwidth KU and with the only the upper */
00072 /*                  half stored. */
00073 /*          = 'Z':  A is a band matrix with lower bandwidth KL and upper */
00074 /*                  bandwidth KU. */
00075 
00076 /*  KL      (input) INTEGER */
00077 /*          The lower bandwidth of A.  Referenced only if TYPE = 'B', */
00078 /*          'Q' or 'Z'. */
00079 
00080 /*  KU      (input) INTEGER */
00081 /*          The upper bandwidth of A.  Referenced only if TYPE = 'B', */
00082 /*          'Q' or 'Z'. */
00083 
00084 /*  CFROM   (input) REAL */
00085 /*  CTO     (input) REAL */
00086 /*          The matrix A is multiplied by CTO/CFROM. A(I,J) is computed */
00087 /*          without over/underflow if the final result CTO*A(I,J)/CFROM */
00088 /*          can be represented without over/underflow.  CFROM must be */
00089 /*          nonzero. */
00090 
00091 /*  M       (input) INTEGER */
00092 /*          The number of rows of the matrix A.  M >= 0. */
00093 
00094 /*  N       (input) INTEGER */
00095 /*          The number of columns of the matrix A.  N >= 0. */
00096 
00097 /*  A       (input/output) COMPLEX array, dimension (LDA,N) */
00098 /*          The matrix to be multiplied by CTO/CFROM.  See TYPE for the */
00099 /*          storage type. */
00100 
00101 /*  LDA     (input) INTEGER */
00102 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00103 
00104 /*  INFO    (output) INTEGER */
00105 /*          0  - successful exit */
00106 /*          <0 - if INFO = -i, the i-th argument had an illegal value. */
00107 
00108 /*  ===================================================================== */
00109 
00110 /*     .. Parameters .. */
00111 /*     .. */
00112 /*     .. Local Scalars .. */
00113 /*     .. */
00114 /*     .. External Functions .. */
00115 /*     .. */
00116 /*     .. Intrinsic Functions .. */
00117 /*     .. */
00118 /*     .. External Subroutines .. */
00119 /*     .. */
00120 /*     .. Executable Statements .. */
00121 
00122 /*     Test the input arguments */
00123 
00124     /* Parameter adjustments */
00125     a_dim1 = *lda;
00126     a_offset = 1 + a_dim1;
00127     a -= a_offset;
00128 
00129     /* Function Body */
00130     *info = 0;
00131 
00132     if (lsame_(type__, "G")) {
00133         itype = 0;
00134     } else if (lsame_(type__, "L")) {
00135         itype = 1;
00136     } else if (lsame_(type__, "U")) {
00137         itype = 2;
00138     } else if (lsame_(type__, "H")) {
00139         itype = 3;
00140     } else if (lsame_(type__, "B")) {
00141         itype = 4;
00142     } else if (lsame_(type__, "Q")) {
00143         itype = 5;
00144     } else if (lsame_(type__, "Z")) {
00145         itype = 6;
00146     } else {
00147         itype = -1;
00148     }
00149 
00150     if (itype == -1) {
00151         *info = -1;
00152     } else if (*cfrom == 0.f || sisnan_(cfrom)) {
00153         *info = -4;
00154     } else if (sisnan_(cto)) {
00155         *info = -5;
00156     } else if (*m < 0) {
00157         *info = -6;
00158     } else if (*n < 0 || itype == 4 && *n != *m || itype == 5 && *n != *m) {
00159         *info = -7;
00160     } else if (itype <= 3 && *lda < max(1,*m)) {
00161         *info = -9;
00162     } else if (itype >= 4) {
00163 /* Computing MAX */
00164         i__1 = *m - 1;
00165         if (*kl < 0 || *kl > max(i__1,0)) {
00166             *info = -2;
00167         } else /* if(complicated condition) */ {
00168 /* Computing MAX */
00169             i__1 = *n - 1;
00170             if (*ku < 0 || *ku > max(i__1,0) || (itype == 4 || itype == 5) && 
00171                     *kl != *ku) {
00172                 *info = -3;
00173             } else if (itype == 4 && *lda < *kl + 1 || itype == 5 && *lda < *
00174                     ku + 1 || itype == 6 && *lda < (*kl << 1) + *ku + 1) {
00175                 *info = -9;
00176             }
00177         }
00178     }
00179 
00180     if (*info != 0) {
00181         i__1 = -(*info);
00182         xerbla_("CLASCL", &i__1);
00183         return 0;
00184     }
00185 
00186 /*     Quick return if possible */
00187 
00188     if (*n == 0 || *m == 0) {
00189         return 0;
00190     }
00191 
00192 /*     Get machine parameters */
00193 
00194     smlnum = slamch_("S");
00195     bignum = 1.f / smlnum;
00196 
00197     cfromc = *cfrom;
00198     ctoc = *cto;
00199 
00200 L10:
00201     cfrom1 = cfromc * smlnum;
00202     if (cfrom1 == cfromc) {
00203 /*        CFROMC is an inf.  Multiply by a correctly signed zero for */
00204 /*        finite CTOC, or a NaN if CTOC is infinite. */
00205         mul = ctoc / cfromc;
00206         done = TRUE_;
00207         cto1 = ctoc;
00208     } else {
00209         cto1 = ctoc / bignum;
00210         if (cto1 == ctoc) {
00211 /*           CTOC is either 0 or an inf.  In both cases, CTOC itself */
00212 /*           serves as the correct multiplication factor. */
00213             mul = ctoc;
00214             done = TRUE_;
00215             cfromc = 1.f;
00216         } else if (dabs(cfrom1) > dabs(ctoc) && ctoc != 0.f) {
00217             mul = smlnum;
00218             done = FALSE_;
00219             cfromc = cfrom1;
00220         } else if (dabs(cto1) > dabs(cfromc)) {
00221             mul = bignum;
00222             done = FALSE_;
00223             ctoc = cto1;
00224         } else {
00225             mul = ctoc / cfromc;
00226             done = TRUE_;
00227         }
00228     }
00229 
00230     if (itype == 0) {
00231 
00232 /*        Full matrix */
00233 
00234         i__1 = *n;
00235         for (j = 1; j <= i__1; ++j) {
00236             i__2 = *m;
00237             for (i__ = 1; i__ <= i__2; ++i__) {
00238                 i__3 = i__ + j * a_dim1;
00239                 i__4 = i__ + j * a_dim1;
00240                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00241                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00242 /* L20: */
00243             }
00244 /* L30: */
00245         }
00246 
00247     } else if (itype == 1) {
00248 
00249 /*        Lower triangular matrix */
00250 
00251         i__1 = *n;
00252         for (j = 1; j <= i__1; ++j) {
00253             i__2 = *m;
00254             for (i__ = j; i__ <= i__2; ++i__) {
00255                 i__3 = i__ + j * a_dim1;
00256                 i__4 = i__ + j * a_dim1;
00257                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00258                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00259 /* L40: */
00260             }
00261 /* L50: */
00262         }
00263 
00264     } else if (itype == 2) {
00265 
00266 /*        Upper triangular matrix */
00267 
00268         i__1 = *n;
00269         for (j = 1; j <= i__1; ++j) {
00270             i__2 = min(j,*m);
00271             for (i__ = 1; i__ <= i__2; ++i__) {
00272                 i__3 = i__ + j * a_dim1;
00273                 i__4 = i__ + j * a_dim1;
00274                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00275                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00276 /* L60: */
00277             }
00278 /* L70: */
00279         }
00280 
00281     } else if (itype == 3) {
00282 
00283 /*        Upper Hessenberg matrix */
00284 
00285         i__1 = *n;
00286         for (j = 1; j <= i__1; ++j) {
00287 /* Computing MIN */
00288             i__3 = j + 1;
00289             i__2 = min(i__3,*m);
00290             for (i__ = 1; i__ <= i__2; ++i__) {
00291                 i__3 = i__ + j * a_dim1;
00292                 i__4 = i__ + j * a_dim1;
00293                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00294                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00295 /* L80: */
00296             }
00297 /* L90: */
00298         }
00299 
00300     } else if (itype == 4) {
00301 
00302 /*        Lower half of a symmetric band matrix */
00303 
00304         k3 = *kl + 1;
00305         k4 = *n + 1;
00306         i__1 = *n;
00307         for (j = 1; j <= i__1; ++j) {
00308 /* Computing MIN */
00309             i__3 = k3, i__4 = k4 - j;
00310             i__2 = min(i__3,i__4);
00311             for (i__ = 1; i__ <= i__2; ++i__) {
00312                 i__3 = i__ + j * a_dim1;
00313                 i__4 = i__ + j * a_dim1;
00314                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00315                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00316 /* L100: */
00317             }
00318 /* L110: */
00319         }
00320 
00321     } else if (itype == 5) {
00322 
00323 /*        Upper half of a symmetric band matrix */
00324 
00325         k1 = *ku + 2;
00326         k3 = *ku + 1;
00327         i__1 = *n;
00328         for (j = 1; j <= i__1; ++j) {
00329 /* Computing MAX */
00330             i__2 = k1 - j;
00331             i__3 = k3;
00332             for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00333                 i__2 = i__ + j * a_dim1;
00334                 i__4 = i__ + j * a_dim1;
00335                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00336                 a[i__2].r = q__1.r, a[i__2].i = q__1.i;
00337 /* L120: */
00338             }
00339 /* L130: */
00340         }
00341 
00342     } else if (itype == 6) {
00343 
00344 /*        Band matrix */
00345 
00346         k1 = *kl + *ku + 2;
00347         k2 = *kl + 1;
00348         k3 = (*kl << 1) + *ku + 1;
00349         k4 = *kl + *ku + 1 + *m;
00350         i__1 = *n;
00351         for (j = 1; j <= i__1; ++j) {
00352 /* Computing MAX */
00353             i__3 = k1 - j;
00354 /* Computing MIN */
00355             i__4 = k3, i__5 = k4 - j;
00356             i__2 = min(i__4,i__5);
00357             for (i__ = max(i__3,k2); i__ <= i__2; ++i__) {
00358                 i__3 = i__ + j * a_dim1;
00359                 i__4 = i__ + j * a_dim1;
00360                 q__1.r = mul * a[i__4].r, q__1.i = mul * a[i__4].i;
00361                 a[i__3].r = q__1.r, a[i__3].i = q__1.i;
00362 /* L140: */
00363             }
00364 /* L150: */
00365         }
00366 
00367     }
00368 
00369     if (! done) {
00370         goto L10;
00371     }
00372 
00373     return 0;
00374 
00375 /*     End of CLASCL */
00376 
00377 } /* clascl_ */


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