pagepinv - Page-wise Moore-Penrose pseudoinverse - MATLAB (original) (raw)
Page-wise Moore-Penrose pseudoinverse
Since R2024a
Syntax
Description
`B` = pagepinv([A](#mw%5Fa3662f13-24e6-4748-84b6-cf5c6740ad69))
computes the Moore-Penrose pseudoinverse of each page of N-D array A
. Each page of the output array B
is given by B(:,:,i) = pinv(A(:,:,i))
.
If A
has more than three dimensions, thenpagepinv
returns an N-D array with the same dimensions, as inB(:,:,i,j,k) = pinv(A(:,:,i,j,k))
.
`B` = pagepinv([A](#mw%5Fa3662f13-24e6-4748-84b6-cf5c6740ad69),[tol](#mw%5Fdf03f294-0b64-4514-ba8c-b58e50b3b022))
specifies a value for one or more tolerances. pagepinv
treats singular values of the pages of A
that are less than or equal to the corresponding tolerance as zero.
Examples
Create a 3-by-3-by-3 array.
A = cat(3,magic(3),hilb(3),pascal(3))
A = A(:,:,1) =
8 1 6
3 5 7
4 9 2
A(:,:,2) =
1.0000 0.5000 0.3333
0.5000 0.3333 0.2500
0.3333 0.2500 0.2000
A(:,:,3) =
1 1 1
1 2 3
1 3 6
Calculate the matrix pseudoinverse of each array page.
B = B(:,:,1) =
0.1472 -0.1444 0.0639
-0.0611 0.0222 0.1056 -0.0194 0.1889 -0.1028
B(:,:,2) =
9.0000 -36.0000 30.0000
-36.0000 192.0000 -180.0000 30.0000 -180.0000 180.0000
B(:,:,3) =
3.0000 -3.0000 1.0000
-3.0000 5.0000 -2.0000 1.0000 -2.0000 1.0000
Create a 3-by-3-by-3 array.
A = cat(3,magic(3),hilb(3),pascal(3))
A = A(:,:,1) =
8 1 6
3 5 7
4 9 2
A(:,:,2) =
1.0000 0.5000 0.3333
0.5000 0.3333 0.2500
0.3333 0.2500 0.2000
A(:,:,3) =
1 1 1
1 2 3
1 3 6
Create a 1-by-1-by-3 array of tolerances.
tol = tol(:,:,1) =
2
tol(:,:,2) =
0.2000
tol(:,:,3) =
1
Calculate the matrix pseudoinverse of each page with the corresponding tolerance value.
B = B(:,:,1) =
0.1472 -0.1444 0.0639
-0.0611 0.0222 0.1056 -0.0194 0.1889 -0.1028
B(:,:,2) =
0.4857 0.2701 0.1899
0.2701 0.1502 0.1056
0.1899 0.1056 0.0742
B(:,:,3) =
0.0048 0.0116 0.0212
0.0116 0.0283 0.0516
0.0212 0.0516 0.0939
Input Arguments
Input array, specified as a matrix or multidimensional array.
Data Types: single
| double
Complex Number Support: Yes
Singular value tolerance, specified as a scalar or a multidimensional array of size[1 1 size(A, 3:ndims(A))]
. Specify a scalar tolerance to use the same tolerance for all array pages. Specify an array of tolerances to use a different tolerance for each page. pagepinv
treats singular values that are less than or equal to tol
as zeros during the computation of the pseudoinverse.
The default tolerance is max(size(A, [1 2])) * eps(pagenorm(A))
.
Example: pagepinv(A,1e-4)
More About
Page-wise functions like pagepinv
operate on 2-D matrices that have been arranged into a multidimensional array. For example, the elements in the third dimension of a 3-D array are commonly called pages because they stack on top of each other like pages in a book. Each page is a matrix that the function operates on.
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 pagepinv
still treats the fundamental unit of the array as a 2-D matrix that the function operates on, such asX(:,:,i,j,k,l)
.
The 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.
Tips
- Results obtained using
pagepinv
are numerically equivalent to computing the pseudoinverses of each of the same matrices in afor
-loop. However, the two results might differ slightly due to floating-point round-off error.
Extended Capabilities
The pagepinv
function supports GPU array input with these usage notes and limitations:
- The row and column sizes of the input array must not be larger than 32.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2024a