LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ snrm2()

real function snrm2 ( integer  N,
real, dimension(*)  X,
integer  INCX 
)

SNRM2

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

    SNRM2 := sqrt( x'*x ).
Parameters
[in]N
          N is INTEGER
         number of elements in input vector(s)
[in]X
          X is REAL array, dimension ( 1 + ( N - 1 )*abs( INCX ) )
[in]INCX
          INCX is INTEGER
         storage spacing between elements of SX
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 SLASSQ.
     Sven Hammarling, Nag Ltd.

Definition at line 76 of file snrm2.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  REAL x(*)
87 * ..
88 *
89 * =====================================================================
90 *
91 * .. Parameters ..
92  REAL one,zero
93  parameter(one=1.0e+0,zero=0.0e+0)
94 * ..
95 * .. Local Scalars ..
96  REAL 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 SLASSQ( 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  snrm2 = norm
128  RETURN
129 *
130 * End of SNRM2.
131 *
real function snrm2(N, X, INCX)
SNRM2
Definition: snrm2.f:76
Here is the caller graph for this function: