Calculate the norm of a vector. More...

template<typename ty >
ty norm (const array &in, float p=af::NaN)
 Matrix or vector norm. More...

Detailed Description

Calculate the norm of a vector.

Detailed description of norm TODO:

Function Documentation

ty af::norm ( const array &  in,
float  p = af::NaN 

Matrix or vector norm.

Some options require ArrayFire Pro.

// compute norm of vector x
array x = randu(1e5);
print(norm< float >(x));
[in]ptype of norm:
  • p == Inf returns max(abs(in)) for vectors, infinity norm for matrices
  • p == -Inf returns min(abs(in)) for vectors, not supported for matrices
  • p == NaN (default) returns Euclidean norm for both vectors and matrices
  • p (anything else) returns p norm of the input
if p is 2 and the input is vector, ArrayFire Pro license is required.