00001 /* dlassq.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 dlassq_(n, x, incx, scale, sumsq) 00009 integer *n; 00010 doublereal *x; 00011 integer *incx; 00012 doublereal *scale, *sumsq; 00013 { 00014 /* System generated locals */ 00015 integer i__1, i__2; 00016 doublereal d__1; 00017 00018 /* Local variables */ 00019 static doublereal absxi; 00020 static integer ix; 00021 00022 00023 /* -- LAPACK auxiliary routine (version 1.1) -- */ 00024 /* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */ 00025 /* Courant Institute, Argonne National Lab, and Rice University */ 00026 /* October 31, 1992 */ 00027 00028 /* .. Scalar Arguments .. */ 00029 /* .. */ 00030 /* .. Array Arguments .. */ 00031 /* .. */ 00032 00033 /* Purpose */ 00034 /* ======= */ 00035 00036 /* DLASSQ returns the values scl and smsq such that */ 00037 00038 /* ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, 00039 */ 00040 00041 /* where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is */ 00042 /* assumed to be non-negative and scl returns the value */ 00043 00044 /* scl = max( scale, abs( x( i ) ) ). */ 00045 00046 /* scale and sumsq must be supplied in SCALE and SUMSQ and */ 00047 /* scl and smsq are overwritten on SCALE and SUMSQ respectively. */ 00048 00049 /* The routine makes only one pass through the vector x. */ 00050 00051 /* Arguments */ 00052 /* ========= */ 00053 00054 /* N (input) INTEGER */ 00055 /* The number of elements to be used from the vector X. */ 00056 00057 /* X (input) DOUBLE PRECISION */ 00058 /* The vector for which a scaled sum of squares is computed. */ 00059 /* x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. */ 00060 00061 /* INCX (input) INTEGER */ 00062 /* The increment between successive values of the vector X. */ 00063 /* INCX > 0. */ 00064 00065 /* SCALE (input/output) DOUBLE PRECISION */ 00066 /* On entry, the value scale in the equation above. */ 00067 /* On exit, SCALE is overwritten with scl , the scaling factor 00068 */ 00069 /* for the sum of squares. */ 00070 00071 /* SUMSQ (input/output) DOUBLE PRECISION */ 00072 /* On entry, the value sumsq in the equation above. */ 00073 /* On exit, SUMSQ is overwritten with smsq , the basic sum of */ 00074 /* squares from which scl has been factored out. */ 00075 00076 /* ===================================================================== 00077 */ 00078 00079 /* .. Parameters .. */ 00080 /* .. */ 00081 /* .. Local Scalars .. */ 00082 /* .. */ 00083 /* .. Intrinsic Functions .. */ 00084 /* .. */ 00085 /* .. Executable Statements .. */ 00086 00087 /* Parameter adjustments */ 00088 --x; 00089 00090 /* Function Body */ 00091 if (*n > 0) { 00092 i__1 = (*n - 1) * *incx + 1; 00093 i__2 = *incx; 00094 for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) { 00095 if (x[ix] != 0.) { 00096 absxi = (d__1 = x[ix], abs(d__1)); 00097 if (*scale < absxi) { 00098 /* Computing 2nd power */ 00099 d__1 = *scale / absxi; 00100 *sumsq = *sumsq * (d__1 * d__1) + 1; 00101 *scale = absxi; 00102 } else { 00103 /* Computing 2nd power */ 00104 d__1 = absxi / *scale; 00105 *sumsq += d__1 * d__1; 00106 } 00107 } 00108 /* L10: */ 00109 } 00110 } 00111 return 0; 00112 00113 /* End of DLASSQ */ 00114 00115 } /* dlassq_ */ 00116