kusano 2b45e8
      REAL             FUNCTION SCNRM2F( N, X, INCX )
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      INTEGER                           INCX, N
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      COMPLEX                           X( * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  SCNRM2 returns the euclidean norm of a vector via the function
kusano 2b45e8
*  name, so that
kusano 2b45e8
*
kusano 2b45e8
*     SCNRM2 := sqrt( conjg( 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 CLASSQ.
kusano 2b45e8
*     Sven Hammarling, Nag Ltd.
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      REAL                  ONE         , ZERO
kusano 2b45e8
      PARAMETER           ( ONE = 1.0E+0, ZERO = 0.0E+0 )
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      INTEGER               IX
kusano 2b45e8
      REAL                  NORM, SCALE, SSQ, TEMP
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC             ABS, AIMAG, REAL, SQRT
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
      IF( N.LT.1 .OR. INCX.LT.1 )THEN
kusano 2b45e8
         NORM  = ZERO
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 CLASSQ( N, X, INCX, SCALE, SSQ )
kusano 2b45e8
*
kusano 2b45e8
         DO 10, IX = 1, 1 + ( N - 1 )*INCX, INCX
kusano 2b45e8
            IF( REAL( X( IX ) ).NE.ZERO )THEN
kusano 2b45e8
               TEMP = ABS( REAL( X( IX ) ) )
kusano 2b45e8
               IF( SCALE.LT.TEMP )THEN
kusano 2b45e8
                  SSQ   = ONE   + SSQ*( SCALE/TEMP )**2
kusano 2b45e8
                  SCALE = TEMP
kusano 2b45e8
               ELSE
kusano 2b45e8
                  SSQ   = SSQ   +     ( TEMP/SCALE )**2
kusano 2b45e8
               END IF
kusano 2b45e8
            END IF
kusano 2b45e8
            IF( AIMAG( X( IX ) ).NE.ZERO )THEN
kusano 2b45e8
               TEMP = ABS( AIMAG( X( IX ) ) )
kusano 2b45e8
               IF( SCALE.LT.TEMP )THEN
kusano 2b45e8
                  SSQ   = ONE   + SSQ*( SCALE/TEMP )**2
kusano 2b45e8
                  SCALE = TEMP
kusano 2b45e8
               ELSE
kusano 2b45e8
                  SSQ   = SSQ   +     ( TEMP/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
      SCNRM2F = NORM
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of SCNRM2.
kusano 2b45e8
*
kusano 2b45e8
      END