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


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