00001 /* DRSCL.F -- translated by f2c (version 19941215). 00002 You must link the resulting object file with the libraries: 00003 -lf2c -lm (in that order) 00004 */ 00005 00006 #include "f2c.h" 00007 00008 /* Subroutine */ int drscl_(n, sa, sx, incx) 00009 integer *n; 00010 doublereal *sa, *sx; 00011 integer *incx; 00012 { 00013 static doublereal cden; 00014 static logical done; 00015 static doublereal cnum, cden1, cnum1; 00016 extern /* Subroutine */ int dscal_(), dlabad_(); 00017 extern doublereal dlamch_(); 00018 static doublereal bignum, smlnum, mul; 00019 00020 00021 /* -- LAPACK auxiliary routine (version 1.1) -- */ 00022 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */ 00023 /* Courant Institute, Argonne National Lab, and Rice University */ 00024 /* October 31, 1992 */ 00025 00026 /* .. Scalar Arguments .. */ 00027 /* .. */ 00028 /* .. Array Arguments .. */ 00029 /* .. */ 00030 00031 /* Purpose */ 00032 /* ======= */ 00033 00034 /* DRSCL multiplies an n-element real vector x by the real scalar 1/a. */ 00035 /* This is done without overflow or underflow as long as */ 00036 /* the final result x/a does not overflow or underflow. */ 00037 00038 /* Arguments */ 00039 /* ========= */ 00040 00041 /* N (input) INTEGER */ 00042 /* The number of components of the vector x. */ 00043 00044 /* SA (input) DOUBLE PRECISION */ 00045 /* The scalar a which is used to divide each component of x. */ 00046 /* SA must be >= 0, or the subroutine will divide by zero. */ 00047 00048 /* SX (input/output) DOUBLE PRECISION array, dimension */ 00049 /* (1+(N-1)*abs(INCX)) */ 00050 /* The n-element vector x. */ 00051 00052 /* INCX (input) INTEGER */ 00053 /* The increment between successive values of the vector SX. */ 00054 /* > 0: SX(1) = X(1) and SX(1+(i-1)*INCX) = x(i), 1< i<= n 00055 */ 00056 /* < 0: SX(1) = X(n) and SX(1+(i-1)*INCX) = x(n-i+1), 1< i<= n 00057 */ 00058 00059 /* ===================================================================== 00060 */ 00061 00062 /* .. Parameters .. */ 00063 /* .. */ 00064 /* .. Local Scalars .. */ 00065 /* .. */ 00066 /* .. External Functions .. */ 00067 /* .. */ 00068 /* .. External Subroutines .. */ 00069 /* .. */ 00070 /* .. Intrinsic Functions .. */ 00071 /* .. */ 00072 /* .. Executable Statements .. */ 00073 00074 /* Quick return if possible */ 00075 00076 /* Parameter adjustments */ 00077 --sx; 00078 00079 /* Function Body */ 00080 if (*n <= 0) { 00081 return 0; 00082 } 00083 00084 /* Get machine parameters */ 00085 00086 smlnum = dlamch_("S", 1L); 00087 bignum = 1. / smlnum; 00088 dlabad_(&smlnum, &bignum); 00089 00090 /* Initialize the denominator to SA and the numerator to 1. */ 00091 00092 cden = *sa; 00093 cnum = 1.; 00094 00095 L10: 00096 cden1 = cden * smlnum; 00097 cnum1 = cnum / bignum; 00098 if (abs(cden1) > abs(cnum) && cnum != 0.) { 00099 00100 /* Pre-multiply X by SMLNUM if CDEN is large compared to CNUM. 00101 */ 00102 00103 mul = smlnum; 00104 done = FALSE_; 00105 cden = cden1; 00106 } else if (abs(cnum1) > abs(cden)) { 00107 00108 /* Pre-multiply X by BIGNUM if CDEN is small compared to CNUM. 00109 */ 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 dscal_(n, &mul, &sx[1], incx); 00125 00126 if (! done) { 00127 goto L10; 00128 } 00129 00130 return 0; 00131 00132 /* End of DRSCL */ 00133 00134 } /* drscl_ */ 00135