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


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