LAPACK 3.3.0
|
00001 SUBROUTINE SLASSQ( N, X, INCX, SCALE, SUMSQ ) 00002 * 00003 * -- LAPACK auxiliary routine (version 3.2) -- 00004 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00005 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00006 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 INTEGER INCX, N 00010 REAL SCALE, SUMSQ 00011 * .. 00012 * .. Array Arguments .. 00013 REAL X( * ) 00014 * .. 00015 * 00016 * Purpose 00017 * ======= 00018 * 00019 * SLASSQ returns the values scl and smsq such that 00020 * 00021 * ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq, 00022 * 00023 * where x( i ) = X( 1 + ( i - 1 )*INCX ). The value of sumsq is 00024 * assumed to be non-negative and scl returns the value 00025 * 00026 * scl = max( scale, abs( x( i ) ) ). 00027 * 00028 * scale and sumsq must be supplied in SCALE and SUMSQ and 00029 * scl and smsq are overwritten on SCALE and SUMSQ respectively. 00030 * 00031 * The routine makes only one pass through the vector x. 00032 * 00033 * Arguments 00034 * ========= 00035 * 00036 * N (input) INTEGER 00037 * The number of elements to be used from the vector X. 00038 * 00039 * X (input) REAL array, dimension (N) 00040 * The vector for which a scaled sum of squares is computed. 00041 * x( i ) = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n. 00042 * 00043 * INCX (input) INTEGER 00044 * The increment between successive values of the vector X. 00045 * INCX > 0. 00046 * 00047 * SCALE (input/output) REAL 00048 * On entry, the value scale in the equation above. 00049 * On exit, SCALE is overwritten with scl , the scaling factor 00050 * for the sum of squares. 00051 * 00052 * SUMSQ (input/output) REAL 00053 * On entry, the value sumsq in the equation above. 00054 * On exit, SUMSQ is overwritten with smsq , the basic sum of 00055 * squares from which scl has been factored out. 00056 * 00057 * ===================================================================== 00058 * 00059 * .. Parameters .. 00060 REAL ZERO 00061 PARAMETER ( ZERO = 0.0E+0 ) 00062 * .. 00063 * .. Local Scalars .. 00064 INTEGER IX 00065 REAL ABSXI 00066 * .. 00067 * .. Intrinsic Functions .. 00068 INTRINSIC ABS 00069 * .. 00070 * .. Executable Statements .. 00071 * 00072 IF( N.GT.0 ) THEN 00073 DO 10 IX = 1, 1 + ( N-1 )*INCX, INCX 00074 IF( X( IX ).NE.ZERO ) THEN 00075 ABSXI = ABS( X( IX ) ) 00076 IF( SCALE.LT.ABSXI ) THEN 00077 SUMSQ = 1 + SUMSQ*( SCALE / ABSXI )**2 00078 SCALE = ABSXI 00079 ELSE 00080 SUMSQ = SUMSQ + ( ABSXI / SCALE )**2 00081 END IF 00082 END IF 00083 10 CONTINUE 00084 END IF 00085 RETURN 00086 * 00087 * End of SLASSQ 00088 * 00089 END