LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
dlassq.f
Go to the documentation of this file.
00001 *> \brief \b DLASSQ
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *> \htmlonly
00009 *> Download DLASSQ + dependencies 
00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlassq.f"> 
00011 *> [TGZ]</a> 
00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlassq.f"> 
00013 *> [ZIP]</a> 
00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlassq.f"> 
00015 *> [TXT]</a>
00016 *> \endhtmlonly 
00017 *
00018 *  Definition:
00019 *  ===========
00020 *
00021 *       SUBROUTINE DLASSQ( N, X, INCX, SCALE, SUMSQ )
00022 * 
00023 *       .. Scalar Arguments ..
00024 *       INTEGER            INCX, N
00025 *       DOUBLE PRECISION   SCALE, SUMSQ
00026 *       ..
00027 *       .. Array Arguments ..
00028 *       DOUBLE PRECISION   X( * )
00029 *       ..
00030 *  
00031 *
00032 *> \par Purpose:
00033 *  =============
00034 *>
00035 *> \verbatim
00036 *>
00037 *> DLASSQ  returns the values  scl  and  smsq  such that
00038 *>
00039 *>    ( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,
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 *> \endverbatim
00051 *
00052 *  Arguments:
00053 *  ==========
00054 *
00055 *> \param[in] N
00056 *> \verbatim
00057 *>          N is INTEGER
00058 *>          The number of elements to be used from the vector X.
00059 *> \endverbatim
00060 *>
00061 *> \param[in] X
00062 *> \verbatim
00063 *>          X is DOUBLE PRECISION array, dimension (N)
00064 *>          The vector for which a scaled sum of squares is computed.
00065 *>             x( i )  = X( 1 + ( i - 1 )*INCX ), 1 <= i <= n.
00066 *> \endverbatim
00067 *>
00068 *> \param[in] INCX
00069 *> \verbatim
00070 *>          INCX is INTEGER
00071 *>          The increment between successive values of the vector X.
00072 *>          INCX > 0.
00073 *> \endverbatim
00074 *>
00075 *> \param[in,out] SCALE
00076 *> \verbatim
00077 *>          SCALE is DOUBLE PRECISION
00078 *>          On entry, the value  scale  in the equation above.
00079 *>          On exit, SCALE is overwritten with  scl , the scaling factor
00080 *>          for the sum of squares.
00081 *> \endverbatim
00082 *>
00083 *> \param[in,out] SUMSQ
00084 *> \verbatim
00085 *>          SUMSQ is DOUBLE PRECISION
00086 *>          On entry, the value  sumsq  in the equation above.
00087 *>          On exit, SUMSQ is overwritten with  smsq , the basic sum of
00088 *>          squares from which  scl  has been factored out.
00089 *> \endverbatim
00090 *
00091 *  Authors:
00092 *  ========
00093 *
00094 *> \author Univ. of Tennessee 
00095 *> \author Univ. of California Berkeley 
00096 *> \author Univ. of Colorado Denver 
00097 *> \author NAG Ltd. 
00098 *
00099 *> \date November 2011
00100 *
00101 *> \ingroup auxOTHERauxiliary
00102 *
00103 *  =====================================================================
00104       SUBROUTINE DLASSQ( N, X, INCX, SCALE, SUMSQ )
00105 *
00106 *  -- LAPACK auxiliary routine (version 3.4.0) --
00107 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00108 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00109 *     November 2011
00110 *
00111 *     .. Scalar Arguments ..
00112       INTEGER            INCX, N
00113       DOUBLE PRECISION   SCALE, SUMSQ
00114 *     ..
00115 *     .. Array Arguments ..
00116       DOUBLE PRECISION   X( * )
00117 *     ..
00118 *
00119 * =====================================================================
00120 *
00121 *     .. Parameters ..
00122       DOUBLE PRECISION   ZERO
00123       PARAMETER          ( ZERO = 0.0D+0 )
00124 *     ..
00125 *     .. Local Scalars ..
00126       INTEGER            IX
00127       DOUBLE PRECISION   ABSXI
00128 *     ..
00129 *     .. Intrinsic Functions ..
00130       INTRINSIC          ABS
00131 *     ..
00132 *     .. Executable Statements ..
00133 *
00134       IF( N.GT.0 ) THEN
00135          DO 10 IX = 1, 1 + ( N-1 )*INCX, INCX
00136             IF( X( IX ).NE.ZERO ) THEN
00137                ABSXI = ABS( X( IX ) )
00138                IF( SCALE.LT.ABSXI ) THEN
00139                   SUMSQ = 1 + SUMSQ*( SCALE / ABSXI )**2
00140                   SCALE = ABSXI
00141                ELSE
00142                   SUMSQ = SUMSQ + ( ABSXI / SCALE )**2
00143                END IF
00144             END IF
00145    10    CONTINUE
00146       END IF
00147       RETURN
00148 *
00149 *     End of DLASSQ
00150 *
00151       END
 All Files Functions