Page-wise matrix or vector norm
returns the p-norm of each page of
N = pagenorm(
p = 1, then
Ncontains the maximum absolute column sum of each page of
p = 2, then
Ncontains the maximum singular value of each page of
p = Inf, then
Ncontains the maximum absolute row sum of each page of
Norm of Matrix Pages
Create a 3-D array with a matrix on each of two pages.
a = magic(3); b = pascal(3); A = cat(3,a,b);
Calculate the 2-norm of each page. This command returns the maximum singular value of each matrix.
N = pagenorm(A)
N = N(:,:,1) = 15.0000 N(:,:,2) = 7.8730
Now calculate the infinity norm of each page. This command returns the maximum absolute row sum of each matrix.
Ninf = pagenorm(A,Inf)
Ninf = Ninf(:,:,1) = 15 Ninf(:,:,2) = 10
Norm of Vector Pages
When each page of a multidimensional array contains a vector, you can use
pagenorm to calculate vector norms of each page.
Create a 3-D array with a vector on each of three pages.
a = 1:10; b = 11:20; c = 21:30; V = cat(3,a,b,c);
Calculate the 2-norm of each page in the array. This command returns the magnitude of each vector.
N = pagenorm(V)
N = N(:,:,1) = 19.6214 N(:,:,2) = 49.8498 N(:,:,3) = 81.1480
Now calculate the 1-norm of each page. This command returns the sum of the element magnitudes for each vector.
N1 = pagenorm(V,1)
N1 = N1(:,:,1) = 55 N1(:,:,2) = 155 N1(:,:,3) = 255
Frobenius Norm of Matrix Pages
Create a 3-D array with a matrix on each of three pages.
a = randi(10,3,3); b = hilb(3); c = pascal(3); A = cat(3,a,b,c);
Calculate the Frobenius norm of each page.
N = pagenorm(A,"fro")
N = N(:,:,1) = 21.9089 N(:,:,2) = 1.4136 N(:,:,3) = 7.9373
X — Input array with matrix pages
matrix | multidimensional array
Input array with matrix pages, specified as a matrix or multidimensional array.
Complex Number Support: Yes
V — Input array with vector pages
vector | multidimensional array
Input array with vector pages, specified as a vector or multidimensional array.
Complex Number Support: Yes
p — Norm type
2 (default) | positive real scalar |
Norm type, specified as
2 (default), a positive real scalar, or
Inf. The valid values of
p and what they return
depend on whether each page of the input array is a matrix or vector, as shown in the
norm for definitions of each norm
This table does not reflect the actual algorithms used in calculations.
|p||Matrix pages||Vector pages|
|Positive, real-valued numeric scalar||—|
pagenorm(X,Inf) returns the maximum absolute row sum of
each matrix page in
pagenorm(V,2) returns the magnitude of each vector page
N — Norm value
scalar | multidimensional array
Norm value, returned as a scalar or multidimensional array. The norm gives a measure
of the magnitude of the elements. By convention,
NaN if the input contains any
NaN values on
Page-wise functions like
pagenorm operate on 2-D
matrices that have been arranged into a multidimensional array. For example, with a 3-D
array the elements in the third dimension of the array are commonly called
pages because they stack on top of each other like pages in a
book. Each page is a matrix that gets operated on by the function.
You can also assemble a collection of 2-D matrices into a higher dimensional array, like a 4-D
or 5-D array, and in these cases
pagenorm still treats the
fundamental unit of the array as a 2-D matrix that gets operated on, such as
cat function is useful for assembling a
collection of matrices into a multidimensional array, and the
zeros function is useful for preallocating a multidimensional array.
squeezefunction is useful to reshape results from
pagenormas a column vector.
Results obtained using
pagenormare numerically equivalent to computing the norm of each of the same matrices in a
for-loop. However, the two results might differ slightly due to floating-point round-off error.
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
Usage notes and limitations:
Pages larger than 32x32 are not supported when calculating the 2-norm of each matrix page using
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced in R2022b