LAPACK  3.9.0
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.
Date
November 2017
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 76 of file dnrm2.f.

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