Rate This Document
Findability
Accuracy
Completeness
Readability

?nrm2

Compute the euclidean norm of the 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

  • For snrm2, X is of single-precision floating-point type.
  • For dnrm2, X is of double-precision floating-point type.
  • For scnrm2, X is of single-precision complex number type.
  • For dznrm2, X is of double-precision complex number type.

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.

Dependencies

#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