LAPACK  3.9.1
LAPACK: Linear Algebra PACKage

◆ dnrm2()

double precision function dnrm2 ( integer  N,
double precision, dimension(*)  X,
integer  INCX 
)

DNRM2

Purpose:
 DNRM2 returns the euclidean norm of a vector via the function
 name, so that

    DNRM2 := sqrt( x'*x )
Parameters
[in]N
          N is INTEGER
         number of elements in input vector(s)
[in]X
          X is DOUBLE PRECISION array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
[in]INCX
          INCX is INTEGER
         storage spacing between elements of DX
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  -- This version written on 25-October-1982.
     Modified on 14-October-1993 to inline the call to DLASSQ.
     Sven Hammarling, Nag Ltd.

Definition at line 73 of file dnrm2.f.

74 *
75 * -- Reference BLAS level1 routine --
76 * -- Reference BLAS is a software package provided by Univ. of Tennessee, --
77 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
78 *
79 * .. Scalar Arguments ..
80  INTEGER INCX,N
81 * ..
82 * .. Array Arguments ..
83  DOUBLE PRECISION X(*)
84 * ..
85 *
86 * =====================================================================
87 *
88 * .. Parameters ..
89  DOUBLE PRECISION ONE,ZERO
90  parameter(one=1.0d+0,zero=0.0d+0)
91 * ..
92 * .. Local Scalars ..
93  DOUBLE PRECISION ABSXI,NORM,SCALE,SSQ
94  INTEGER IX
95 * ..
96 * .. Intrinsic Functions ..
97  INTRINSIC abs,sqrt
98 * ..
99  IF (n.LT.1 .OR. incx.LT.1) THEN
100  norm = zero
101  ELSE IF (n.EQ.1) THEN
102  norm = abs(x(1))
103  ELSE
104  scale = zero
105  ssq = one
106 * The following loop is equivalent to this call to the LAPACK
107 * auxiliary routine:
108 * CALL DLASSQ( N, X, INCX, SCALE, SSQ )
109 *
110  DO 10 ix = 1,1 + (n-1)*incx,incx
111  IF (x(ix).NE.zero) THEN
112  absxi = abs(x(ix))
113  IF (scale.LT.absxi) THEN
114  ssq = one + ssq* (scale/absxi)**2
115  scale = absxi
116  ELSE
117  ssq = ssq + (absxi/scale)**2
118  END IF
119  END IF
120  10 CONTINUE
121  norm = scale*sqrt(ssq)
122  END IF
123 *
124  dnrm2 = norm
125  RETURN
126 *
127 * End of DNRM2.
128 *
double precision function dnrm2(N, X, INCX)
DNRM2
Definition: dnrm2.f:74
Here is the caller graph for this function: