LAPACK  3.9.1
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.
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 73 of file snrm2.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  REAL X(*)
84 * ..
85 *
86 * =====================================================================
87 *
88 * .. Parameters ..
89  REAL ONE,ZERO
90  parameter(one=1.0e+0,zero=0.0e+0)
91 * ..
92 * .. Local Scalars ..
93  REAL 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 SLASSQ( 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  snrm2 = norm
125  RETURN
126 *
127 * End of SNRM2.
128 *
real function snrm2(N, X, INCX)
SNRM2
Definition: snrm2.f:74
Here is the caller graph for this function: