1 DOUBLE PRECISION FUNCTION DNRM2 ( N, X, INCX )
2 ! .. Scalar Arguments ..
4 ! .. Array Arguments ..
5 DOUBLE PRECISION X( * )
8 ! DNRM2 returns the euclidean norm of a vector via the function
11 ! DNRM2 := sqrt( x'*x )
15 ! -- This version written on 25-October-1982.
16 ! Modified on 14-October-1993 to inline the call to DLASSQ.
17 ! Sven Hammarling, Nag Ltd.
21 DOUBLE PRECISION ONE , ZERO
22 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
25 DOUBLE PRECISION ABSXI, NORM, SCALE, SSQ
26 ! .. Intrinsic Functions ..
29 ! .. Executable Statements ..
30 IF( N.LT.1 .OR. INCX.LT.1 )THEN
37 ! The following loop is equivalent to this call to the LAPACK
39 ! CALL DLASSQ( N, X, INCX, SCALE, SSQ )
41 DO 10, IX = 1, 1 + ( N - 1 )*INCX, INCX
42 IF( X( IX ).NE.ZERO )THEN
43 ABSXI = ABS( X( IX ) )
44 IF( SCALE.LT.ABSXI )THEN
45 SSQ = ONE + SSQ*( SCALE/ABSXI )**2
48 SSQ = SSQ + ( ABSXI/SCALE )**2
52 NORM = SCALE * SQRT( SSQ )