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


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