srscl.c
Go to the documentation of this file.
00001 /* srscl.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 srscl_(integer *n, real *sa, real *sx, integer *incx)
00017 {
00018     real mul, cden;
00019     logical done;
00020     real cnum, cden1, cnum1;
00021     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *), 
00022             slabad_(real *, real *);
00023     extern doublereal slamch_(char *);
00024     real bignum, smlnum;
00025 
00026 
00027 /*  -- LAPACK auxiliary routine (version 3.2) -- */
00028 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00029 /*     November 2006 */
00030 
00031 /*     .. Scalar Arguments .. */
00032 /*     .. */
00033 /*     .. Array Arguments .. */
00034 /*     .. */
00035 
00036 /*  Purpose */
00037 /*  ======= */
00038 
00039 /*  SRSCL multiplies an n-element real vector x by the real scalar 1/a. */
00040 /*  This is done without overflow or underflow as long as */
00041 /*  the final result x/a does not overflow or underflow. */
00042 
00043 /*  Arguments */
00044 /*  ========= */
00045 
00046 /*  N       (input) INTEGER */
00047 /*          The number of components of the vector x. */
00048 
00049 /*  SA      (input) REAL */
00050 /*          The scalar a which is used to divide each component of x. */
00051 /*          SA must be >= 0, or the subroutine will divide by zero. */
00052 
00053 /*  SX      (input/output) REAL array, dimension */
00054 /*                         (1+(N-1)*abs(INCX)) */
00055 /*          The n-element vector x. */
00056 
00057 /*  INCX    (input) INTEGER */
00058 /*          The increment between successive values of the vector SX. */
00059 /*          > 0:  SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i),     1< i<= n */
00060 
00061 /* ===================================================================== */
00062 
00063 /*     .. Parameters .. */
00064 /*     .. */
00065 /*     .. Local Scalars .. */
00066 /*     .. */
00067 /*     .. External Functions .. */
00068 /*     .. */
00069 /*     .. External Subroutines .. */
00070 /*     .. */
00071 /*     .. Intrinsic Functions .. */
00072 /*     .. */
00073 /*     .. Executable Statements .. */
00074 
00075 /*     Quick return if possible */
00076 
00077     /* Parameter adjustments */
00078     --sx;
00079 
00080     /* Function Body */
00081     if (*n <= 0) {
00082         return 0;
00083     }
00084 
00085 /*     Get machine parameters */
00086 
00087     smlnum = slamch_("S");
00088     bignum = 1.f / smlnum;
00089     slabad_(&smlnum, &bignum);
00090 
00091 /*     Initialize the denominator to SA and the numerator to 1. */
00092 
00093     cden = *sa;
00094     cnum = 1.f;
00095 
00096 L10:
00097     cden1 = cden * smlnum;
00098     cnum1 = cnum / bignum;
00099     if (dabs(cden1) > dabs(cnum) && cnum != 0.f) {
00100 
00101 /*        Pre-multiply X by SMLNUM if CDEN is large compared to CNUM. */
00102 
00103         mul = smlnum;
00104         done = FALSE_;
00105         cden = cden1;
00106     } else if (dabs(cnum1) > dabs(cden)) {
00107 
00108 /*        Pre-multiply X by BIGNUM if CDEN is small compared to CNUM. */
00109 
00110         mul = bignum;
00111         done = FALSE_;
00112         cnum = cnum1;
00113     } else {
00114 
00115 /*        Multiply X by CNUM / CDEN and return. */
00116 
00117         mul = cnum / cden;
00118         done = TRUE_;
00119     }
00120 
00121 /*     Scale the vector X by MUL */
00122 
00123     sscal_(n, &mul, &sx[1], incx);
00124 
00125     if (! done) {
00126         goto L10;
00127     }
00128 
00129     return 0;
00130 
00131 /*     End of SRSCL */
00132 
00133 } /* srscl_ */


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