{S,D}NORM2 (n, x, incx) SCNORM2 (n, x, incx) DZNORM2 (n, x, incx)
sum real*4 | real*8 | complex*8 | complex*16 The Euclidean norm of the vector x, that is, the square root of the sum of the squares of the elements of a real vector or the square root of the sum of the squares of the absolute value of the elements of the complex vector. If n<=0, (sum = 0.0.)
n integer*4 On entry, the number of elements of the vector x. On exit, n is unchanged. x real*4 | real*8 | complex*8 | complex*16 On entry, a one-dimensional array X of length at least (1+(n-1)*|incx|), containing the elements of the vector x. On exit, x is unchanged. incx integer*4 On entry, the increment for the array X. If incx > 0, vector x is stored forward in the array, so that x(i) is stored in location X(1+(i-1)*incx). If incx < 0, vector x is stored backward in the array, so that x(i) is stored in location X(1+(n-i)*|incx|). If incx = 0, only the first element is accessed. On exit, incx is unchanged.
SNORM2 and DNORM2 compute the Euclidean norm of a real vector x. The Euclidean norm is the square root of the sum of the squares of the elements of the vector: SUM(i=1...n,x(i)**2)**(1/2) SCNORM2 and DZNORM2 compute the square root of the sum of the squares of the absolute value of the elements of a complex vector x: SUM(i=1...n,|x(i)|**2)**(1/2) For complex vectors, each element x(j) is a complex number. In this subprogram, the absolute value of a complex number is defined as the square root of the sum of the squares of the real part and the imaginary part: |x(j)| = (a(j)**2 + b(j)**2) **(1/2) = ((real)**2 + (imaginary)**2) **(1/2) If incx < 0, the result is identical to using |incx|. If incx = 0, the computation is a time-consuming way of setting sum = (n*x(1)**2)**(1/2) for real operations, and sum = |x(i)| (n)**(1/2). for complex operations. Because of efficient coding, rounding errors can cause the final result to differ from the result computed by a sequential evaluation of the Euclidean norm. Unlike the _NRM2 and __NRM2 subprograms in BLAS Level 1, the _NORM2 and __NORM2 subprograms do not perform any special scaling to ensure that intermediate results do not overflow or underflow. Therefore, these routines must use an input vector x so that |(min)**(1/2)| <= |x(i)| <= |(max)**(1/2)| The largest value of x must not overflow when it is squared; the smallest value must not underflow when it is squared.
INTEGER*4 N, INCX REAL*4 X(20), SUM INCX = 1 N = 20 SUM = SNORM2(N,X,INCX) This FORTRAN example shows how to compute the Euclidean norm of the vector x.