CXML

snrm2, dnrm2, scnrm2, dznrm2 


FORMAT

  {S,D}NRM2 (n, x, incx) SCNRM2 (n, x, incx) DZNRM2 (n, x, incx)

Function Value

  e_norm: real*4 | real*8
  The Euclidean norm of the vector x, that is, the square root of the
  conjugated dot product of x with itself.

       If n<=0, e_norm returns the value 0.0.

Arguments

  n                   integer*4
                      On entry, the number of elements in 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|).
                      On exit, incx is unchanged.

Description

  SNRM2 and DNRM2 compute the Euclidean norm of a real vector; SCNRM2 and
  DZNRM2 compute the Euclidean norm of a complex vector. The Euclidean norm
  is the square root of the conjugated dot product of a vector with itself.

  For real vectors: (SUM(i=1...n,x(i)**(2))**(1/2) = (x(1)**(2) + x(2)**(2)
   + ... + x(n)**(2))**(1/2)
  For complex vectors: (SUM(i=1...n,conjugate(x(i))*x(i))**(1/2) =
  ((conjugate(x)(1) * x(1)) + (conjugate(x)(2) * x(2)) + ... +
  (conjugate(x)(n) * x(n)))**(1/2)

  The order of operations is different from the order in a sequential
  evaluation of the Euclidean norm. The final result can differ from the
  result of a sequential evaluation.

  If incx < 0, the result is identical to using |incx|.  If incx = 0, the
  computation is a time-consuming way of setting e_norm =
  (n*x(1)**(2))**(1/2).

Example

  INTEGER*4 INCX, N
  REAL*4 X(20), E_NORM
  INCX = 1
  N = 20
  E_NORM = SNRM2(N,X,INCX)

  This FORTRAN code shows how to compute the Euclidean norm of a real vector.

CXML Home Page

Index of CXML Routines