3 /* Subroutine */ int dlassq_(integer *n, doublereal *x, integer *incx,
4 doublereal *scale, doublereal *sumsq)
6 /* System generated locals */
15 /* -- LAPACK auxiliary routine (version 3.1) -- */
16 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
19 /* .. Scalar Arguments .. */
21 /* .. Array Arguments .. */
27 /* DLASSQ returns the values scl and smsq such that */
29 /* ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, */
31 /* where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is */
32 /* assumed to be non-negative and scl returns the value */
34 /* scl = max( scale, abs( x( i ) ) ). */
36 /* scale and sumsq must be supplied in SCALE and SUMSQ and */
37 /* scl and smsq are overwritten on SCALE and SUMSQ respectively. */
39 /* The routine makes only one pass through the vector x. */
44 /* N (input) INTEGER */
45 /* The number of elements to be used from the vector X. */
47 /* X (input) DOUBLE PRECISION array, dimension (N) */
48 /* The vector for which a scaled sum of squares is computed. */
49 /* x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. */
51 /* INCX (input) INTEGER */
52 /* The increment between successive values of the vector X. */
55 /* SCALE (input/output) DOUBLE PRECISION */
56 /* On entry, the value scale in the equation above. */
57 /* On exit, SCALE is overwritten with scl , the scaling factor */
58 /* for the sum of squares. */
60 /* SUMSQ (input/output) DOUBLE PRECISION */
61 /* On entry, the value sumsq in the equation above. */
62 /* On exit, SUMSQ is overwritten with smsq , the basic sum of */
63 /* squares from which scl has been factored out. */
65 /* ===================================================================== */
67 /* .. Parameters .. */
69 /* .. Local Scalars .. */
71 /* .. Intrinsic Functions .. */
73 /* .. Executable Statements .. */
75 /* Parameter adjustments */
80 i__1 = (*n - 1) * *incx + 1;
82 for (ix = 1; i__2 < 0 ? ix >= i__1 : ix <= i__1; ix += i__2) {
84 absxi = (d__1 = x[ix], abs(d__1));
86 /* Computing 2nd power */
87 d__1 = *scale / absxi;
88 *sumsq = *sumsq * (d__1 * d__1) + 1;
91 /* Computing 2nd power */
92 d__1 = absxi / *scale;
93 *sumsq += d__1 * d__1;