NORM
(x, <, method> ) ;
The NORM function computes the vector or matrix norm of x. The norm depends on the metric specified by the method argument. The arguments are as follows:
specifies a numeric vector with elements or an numeric matrix.
is an optional argument that specifies the method used to specify the norm. The method argument is either a numeric value, method, or a case-insensitive character value. The valid options are given in the following sections.
If x is a vector, then a vector norm is computed. The following are valid values of the method argument:
specifies that the function compute the 1-norm: . An equivalent alias is “CityBlock” or “Manhattan”.
specifies that the function compute the Euclidean 2-norm: . This is the default value. An equivalent alias is “Euclidean” or “Frobenius”.
specifies that the function compute the -norm: .
An equivalent alias is “Chebyshev”.
is a numeric value, , that specifies the -norm: , .
For an matrix such that and , the method argument has the following valid values:
specifies the Frobenius norm: . This is the default value.
specifies the matrix 1-norm: . This norm computes the maximum of the absolute column sums.
specifies the matrix -norm, which is equivalent to the square root of the largest eigenvalue of the matrix. This quantity can be expensive to compute because the function internally computes eigenvalues.
specifies the -norm: . This norm computes the maximum of the absolute row sums.
The matrix -norm is not available unless .
The following statements compute vector norms:
/* compute vector norms */ v = 1:5; vn1 = norm(v, "L1"); vn2 = norm(v, "L2"); vnInf = norm(v, "LInf"); print vn1 vn2 vnInf;
Figure 23.211: Vector Norms
vn1 | vn2 | vnInf |
---|---|---|
15 | 7.4161985 | 5 |
You can also compute matrix norms, as follows:
x = {1 2, 3 4}; mn1 = norm(x, "L1"); mnF = norm(x, "Frobenius"); mnInf = norm(x, "LInf"); print mn1 mnF mnInf;
Figure 23.212: Matrix Norms
mn1 | mnF | mnInf |
---|---|---|
6 | 5.4772256 | 7 |
The NORM function returns a missing value if any element of the argument contains a missing value.