Norm

Usage

use Norm;

or

import Norm;

Matrix and Vector Norms

The Norm module currently defines:

  • 1-norm, 2-norm, infinity norm and Frobenius norm for 1D arrays
  • 1-norm, infinity norm and Frobenius norm for 2D arrays

The normType argument for the first few overloads of norm is an enumeration indicating the norm to compute.

The norm function may also be called without specifying the normType, in which case the default norm for that array rank will be used.

enum normType { norm1, norm2, normInf, normFrob }

Indicates the different types of norms supported by this module:

  • 1-norm
  • 2-norm
  • Infinity norm
  • Frobenius norm
proc norm(x: [], p: normType)

Compute the norm indicated by p on the 1D array x.

Return type:x.eltType
proc norm(x: [?D], p: normType)

Compute the norm indicated by p on the 2D array x.

p cannot be normType.norm2.

Return type:x.eltType
proc norm(x: [])

Compute the default norm on x.

For a 1D array this is the 2-norm, for a 2D array, this is the Frobenius norm.

Return type:x.eltType