Rate This Document
Findability
Accuracy
Completeness
Readability

?nrm2

Compute the euclidean norm of a vector.

That is, . X is a vector that contains n elements. ||X|| is equivalent to .

Interface Definition

C interface:

float cblas_snrm2 (const BLASINT N, const float *X, const BLASINT incX);

double cblas_dnrm2 (const BLASINT N, const double *X, const BLASINT incX);

float cblas_scnrm2 (const BLASINT N, const float *X, const BLASINT incX);

double cblas_dznrm2 (const BLASINT N, const double *X, const BLASINT incX);

Fortran interface:

RES = SNRM2(N, X, INCX)

RES = DNRM2(N, X, INCX)

RES = SCNRM2(N, X, INCX)

RES = DZNRM2(N, X, INCX)

Parameters

Parameter

Type

Description

Input/Output

N

Integer

Number of elements in the X vector.

Input

X

  • Single-precision floating-point type for snrm2
  • Double-precision floating-point type for dnrm2
  • Single-precision complex type for scnrm2
  • Double-precision complex type for dznrm2

Vector X. The vector size is at least (1+(n-1)*abs(incX)).

Input/Output

incX

Integer

Increment for the elements of vector X.

Input

Return Value

Vector norm. Float or double-precision floating-point type.

Dependency

#include "kblas.h"

Examples

C interface:

    int n = 5, incx = 1; 
    float res; 
    /** 
     *    X: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647 
     */ 
    float x[5] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647}; 
 
    res = cblas_snrm2(n, x, incx); 
    /** 
     *    Output: 0.682310 
     */

Fortran interface:

      INTEGER :: N=5 
      INTEGER :: INCX=1 
      REAL(4) :: RES 
      REAL(4) :: X(5) 
      DATA X/0.340188, -0.105617, 0.283099, 0.298440, 0.411647/ 
      EXTERNAL SNRM2 
      RES=SNRM2(N, X, INCX) 
 
*     Output : 0.682310