kusano 2b45e8
      DOUBLE PRECISION FUNCTION DNRM2F ( N, X, INCX )
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      INTEGER                           INCX, N
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      DOUBLE PRECISION                  X( * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  DNRM2 returns the euclidean norm of a vector via the function
kusano 2b45e8
*  name, so that
kusano 2b45e8
*
kusano 2b45e8
*     DNRM2 := sqrt( x'*x )
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*  -- This version written on 25-October-1982.
kusano 2b45e8
*     Modified on 14-October-1993 to inline the call to DLASSQ.
kusano 2b45e8
*     Sven Hammarling, Nag Ltd.
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      DOUBLE PRECISION      ONE         , ZERO
kusano 2b45e8
      PARAMETER           ( ONE = 1.0D+0, ZERO = 0.0D+0 )
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      INTEGER               IX
kusano 2b45e8
      DOUBLE PRECISION      ABSXI, NORM, SCALE, SSQ
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC             ABS, SQRT
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
kusano 2b45e8
      IF( N.LT.1 .OR. INCX.LT.1 )THEN
kusano 2b45e8
         NORM  = ZERO
kusano 2b45e8
      ELSE IF( N.EQ.1 )THEN
kusano 2b45e8
         NORM  = ABS( X( 1 ) )
kusano 2b45e8
      ELSE
kusano 2b45e8
         SCALE = ZERO
kusano 2b45e8
         SSQ   = ONE
kusano 2b45e8
*        The following loop is equivalent to this call to the LAPACK
kusano 2b45e8
*        auxiliary routine:
kusano 2b45e8
*        CALL DLASSQ( N, X, INCX, SCALE, SSQ )
kusano 2b45e8
*
kusano 2b45e8
         DO 10, IX = 1, 1 + ( N - 1 )*INCX, INCX
kusano 2b45e8
            IF( X( IX ).NE.ZERO )THEN
kusano 2b45e8
               ABSXI = ABS( X( IX ) )
kusano 2b45e8
               IF( SCALE.LT.ABSXI )THEN
kusano 2b45e8
                  SSQ   = ONE   + SSQ*( SCALE/ABSXI )**2
kusano 2b45e8
                  SCALE = ABSXI
kusano 2b45e8
               ELSE
kusano 2b45e8
                  SSQ   = SSQ   +     ( ABSXI/SCALE )**2
kusano 2b45e8
               END IF
kusano 2b45e8
            END IF
kusano 2b45e8
   10    CONTINUE
kusano 2b45e8
         NORM  = SCALE * SQRT( SSQ )
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
      DNRM2F = NORM
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of DNRM2.
kusano 2b45e8
*
kusano 2b45e8
      END