Euclidean norm

SNRM2/DNRM2/SCNRM2/DZNRM2

Name SNRM2/DNRM2/SCNRM2/DZNRM2

Euclidean norm

Purpose Given a real or complex vector x of length n, these subprograms compute the Euclidean (that is, l2) norm of the vector

 

 

 

 

 

n

 

1 2

s =

 

x

 

2

=

xi

2

 

 

 

 

 

i = 1

 

 

 

 

 

 

 

 

 

The vector can be stored in a one-dimensional array or in either a row or a column of a two-dimensional array.

Usage

VECLIB:

 

 

INTEGER*4

n, incx

 

REAL*4

s, SNRM2, x(lenx)

 

s = SNRM2(n, x, incx)

 

INTEGER*4

n, incx

 

REAL*8

s, DNRM2, x(lenx)

 

s = DNRM2(n, x, incx)

 

INTEGER*4

n, incx

 

REAL*4

s, SCNRM2

 

COMPLEX*8

x(lenx)

 

s = SCNRM2(n, x, incx)

 

INTEGER*4

n, incx

 

REAL*8

s, DZNRM2

 

COMPLEX*16

x(lenx)

s = DZNRM2(n, x, incx)

VECLIB8:

INTEGER*8

n, incx

REAL*4

s, SNRM2, x(lenx)

s = SNRM2(n, x, incx)

INTEGER*8

n, incx

REAL*8

s, DNRM2, x(lenx)

s = DNRM2(n, x, incx)

INTEGER*8

n, incx

REAL*4

s, SCNRM2

COMPLEX*8

x(lenx)

s = SCNRM2(n, x, incx)

Chapter 2 Basic Vector Operations 107