slascl.c
Go to the documentation of this file.
00001 /* slascl.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 slascl_(char *type__, integer *kl, integer *ku, real *
00017         cfrom, real *cto, integer *m, integer *n, real *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 
00023     /* Local variables */
00024     integer i__, j, k1, k2, k3, k4;
00025     real mul, cto1;
00026     logical done;
00027     real ctoc;
00028     extern logical lsame_(char *, char *);
00029     integer itype;
00030     real cfrom1;
00031     extern doublereal slamch_(char *);
00032     real cfromc;
00033     extern /* Subroutine */ int xerbla_(char *, integer *);
00034     real bignum;
00035     extern logical sisnan_(real *);
00036     real 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 /*  SLASCL multiplies the M by N real 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) REAL */
00084 /*  CTO     (input) REAL */
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) REAL 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.f || sisnan_(cfrom)) {
00152         *info = -4;
00153     } else if (sisnan_(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_("SLASCL", &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 = slamch_("S");
00194     bignum = 1.f / 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.f;
00215         } else if (dabs(cfrom1) > dabs(ctoc) && ctoc != 0.f) {
00216             mul = smlnum;
00217             done = FALSE_;
00218             cfromc = cfrom1;
00219         } else if (dabs(cto1) > dabs(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                 a[i__ + j * a_dim1] *= mul;
00238 /* L20: */
00239             }
00240 /* L30: */
00241         }
00242 
00243     } else if (itype == 1) {
00244 
00245 /*        Lower triangular matrix */
00246 
00247         i__1 = *n;
00248         for (j = 1; j <= i__1; ++j) {
00249             i__2 = *m;
00250             for (i__ = j; i__ <= i__2; ++i__) {
00251                 a[i__ + j * a_dim1] *= mul;
00252 /* L40: */
00253             }
00254 /* L50: */
00255         }
00256 
00257     } else if (itype == 2) {
00258 
00259 /*        Upper triangular matrix */
00260 
00261         i__1 = *n;
00262         for (j = 1; j <= i__1; ++j) {
00263             i__2 = min(j,*m);
00264             for (i__ = 1; i__ <= i__2; ++i__) {
00265                 a[i__ + j * a_dim1] *= mul;
00266 /* L60: */
00267             }
00268 /* L70: */
00269         }
00270 
00271     } else if (itype == 3) {
00272 
00273 /*        Upper Hessenberg matrix */
00274 
00275         i__1 = *n;
00276         for (j = 1; j <= i__1; ++j) {
00277 /* Computing MIN */
00278             i__3 = j + 1;
00279             i__2 = min(i__3,*m);
00280             for (i__ = 1; i__ <= i__2; ++i__) {
00281                 a[i__ + j * a_dim1] *= mul;
00282 /* L80: */
00283             }
00284 /* L90: */
00285         }
00286 
00287     } else if (itype == 4) {
00288 
00289 /*        Lower half of a symmetric band matrix */
00290 
00291         k3 = *kl + 1;
00292         k4 = *n + 1;
00293         i__1 = *n;
00294         for (j = 1; j <= i__1; ++j) {
00295 /* Computing MIN */
00296             i__3 = k3, i__4 = k4 - j;
00297             i__2 = min(i__3,i__4);
00298             for (i__ = 1; i__ <= i__2; ++i__) {
00299                 a[i__ + j * a_dim1] *= mul;
00300 /* L100: */
00301             }
00302 /* L110: */
00303         }
00304 
00305     } else if (itype == 5) {
00306 
00307 /*        Upper half of a symmetric band matrix */
00308 
00309         k1 = *ku + 2;
00310         k3 = *ku + 1;
00311         i__1 = *n;
00312         for (j = 1; j <= i__1; ++j) {
00313 /* Computing MAX */
00314             i__2 = k1 - j;
00315             i__3 = k3;
00316             for (i__ = max(i__2,1); i__ <= i__3; ++i__) {
00317                 a[i__ + j * a_dim1] *= mul;
00318 /* L120: */
00319             }
00320 /* L130: */
00321         }
00322 
00323     } else if (itype == 6) {
00324 
00325 /*        Band matrix */
00326 
00327         k1 = *kl + *ku + 2;
00328         k2 = *kl + 1;
00329         k3 = (*kl << 1) + *ku + 1;
00330         k4 = *kl + *ku + 1 + *m;
00331         i__1 = *n;
00332         for (j = 1; j <= i__1; ++j) {
00333 /* Computing MAX */
00334             i__3 = k1 - j;
00335 /* Computing MIN */
00336             i__4 = k3, i__5 = k4 - j;
00337             i__2 = min(i__4,i__5);
00338             for (i__ = max(i__3,k2); i__ <= i__2; ++i__) {
00339                 a[i__ + j * a_dim1] *= mul;
00340 /* L140: */
00341             }
00342 /* L150: */
00343         }
00344 
00345     }
00346 
00347     if (! done) {
00348         goto L10;
00349     }
00350 
00351     return 0;
00352 
00353 /*     End of SLASCL */
00354 
00355 } /* slascl_ */


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