KTH framework for Nek5000 toolboxes; testing version  0.0.1
dlassq.f
Go to the documentation of this file.
1  SUBROUTINE dlassq( N, X, INCX, SCALE, SUMSQ )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * June 30, 1999
7 *
8 * .. Scalar Arguments ..
9  INTEGER INCX, N
10  DOUBLE PRECISION SCALE, SUMSQ
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION X( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DLASSQ returns the values scl and smsq such that
20 *
21 * ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
22 *
23 * where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is
24 * assumed to be non-negative and scl returns the value
25 *
26 * scl = max( scale, abs( x( i ) ) ).
27 *
28 * scale and sumsq must be supplied in SCALE and SUMSQ and
29 * scl and smsq are overwritten on SCALE and SUMSQ respectively.
30 *
31 * The routine makes only one pass through the vector x.
32 *
33 * Arguments
34 * =========
35 *
36 * N (input) INTEGER
37 * The number of elements to be used from the vector X.
38 *
39 * X (input) DOUBLE PRECISION array, dimension (N)
40 * The vector for which a scaled sum of squares is computed.
41 * x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
42 *
43 * INCX (input) INTEGER
44 * The increment between successive values of the vector X.
45 * INCX > 0.
46 *
47 * SCALE (input/output) DOUBLE PRECISION
48 * On entry, the value scale in the equation above.
49 * On exit, SCALE is overwritten with scl , the scaling factor
50 * for the sum of squares.
51 *
52 * SUMSQ (input/output) DOUBLE PRECISION
53 * On entry, the value sumsq in the equation above.
54 * On exit, SUMSQ is overwritten with smsq , the basic sum of
55 * squares from which scl has been factored out.
56 *
57 * =====================================================================
58 *
59 * .. Parameters ..
60  DOUBLE PRECISION ZERO
61  parameter( zero = 0.0d+0 )
62 * ..
63 * .. Local Scalars ..
64  INTEGER IX
65  DOUBLE PRECISION ABSXI
66 * ..
67 * .. Intrinsic Functions ..
68  INTRINSIC abs
69 * ..
70 * .. Executable Statements ..
71 *
72  IF( n.GT.0 ) THEN
73  DO 10 ix = 1, 1 + ( n-1 )*incx, incx
74  IF( x( ix ).NE.zero ) THEN
75  absxi = abs( x( ix ) )
76  IF( scale.LT.absxi ) THEN
77  sumsq = 1 + sumsq*( scale / absxi )**2
78  scale = absxi
79  ELSE
80  sumsq = sumsq + ( absxi / scale )**2
81  END IF
82  END IF
83  10 CONTINUE
84  END IF
85  RETURN
86 *
87 * End of DLASSQ
88 *
89  END
subroutine dlassq(N, X, INCX, SCALE, SUMSQ)
Definition: dlassq.f:2