1 SUBROUTINE DLASSQ( N, X, INCX, SCALE, SUMSQ )
3 ! -- LAPACK auxiliary routine (version 3.1) --
4 ! Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
7 ! .. Scalar Arguments ..
9 DOUBLE PRECISION SCALE, SUMSQ
11 ! .. Array Arguments ..
12 DOUBLE PRECISION X( * )
18 ! DLASSQ returns the values scl and smsq such that
20 ! ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
22 ! where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
23 ! assumed to be non-negative and scl returns the value
25 ! scl = max( scale, abs( x( i ) ) ).
27 ! scale and sumsq must be supplied in SCALE and SUMSQ and
28 ! scl and smsq are overwritten on SCALE and SUMSQ respectively.
30 ! The routine makes only one pass through the vector x.
36 ! The number of elements to be used from the vector X.
38 ! X (input) DOUBLE PRECISION array, dimension (N)
39 ! The vector for which a scaled sum of squares is computed.
40 ! x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
42 ! INCX (input) INTEGER
43 ! The increment between successive values of the vector X.
46 ! SCALE (input/output) DOUBLE PRECISION
47 ! On entry, the value scale in the equation above.
48 ! On exit, SCALE is overwritten with scl , the scaling factor
49 ! for the sum of squares.
51 ! SUMSQ (input/output) DOUBLE PRECISION
52 ! On entry, the value sumsq in the equation above.
53 ! On exit, SUMSQ is overwritten with smsq , the basic sum of
54 ! squares from which scl has been factored out.
56 ! =====================================================================
60 PARAMETER ( ZERO = 0.0D+0 )
64 DOUBLE PRECISION ABSXI
66 ! .. Intrinsic Functions ..
69 ! .. Executable Statements ..
72 DO 10 IX = 1, 1 + ( N-1 )*INCX, INCX
73 IF( X( IX ).NE.ZERO ) THEN
74 ABSXI = ABS( X( IX ) )
75 IF( SCALE.LT.ABSXI ) THEN
76 SUMSQ = 1 + SUMSQ*( SCALE / ABSXI )**2
79 SUMSQ = SUMSQ + ( ABSXI / SCALE )**2